Skip to content

Dev - #115

Merged
rekabytes merged 4 commits into
mainfrom
dev
Mar 15, 2026
Merged

Dev#115
rekabytes merged 4 commits into
mainfrom
dev

Conversation

@rekabytes

@rekabytes rekabytes commented Mar 15, 2026

Copy link
Copy Markdown
Owner

📝 Description

Brief description of what this PR does.

🔗 Related Issue

Fixes #(issue number)

🏷️ Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧹 Code refactoring (no functional changes)
  • 🧪 Test update (adding or updating tests)

✅ Checklist

  • I have read the Contributing Guidelines
  • My branch is created from dev (not main)
  • I have run pnpm lint:fix
  • I have run pnpm typecheck
  • I have tested my changes locally
  • My code follows the project's coding standards
  • I have updated documentation (if applicable)

📸 Screenshots (if applicable)

Add screenshots to help explain your changes.

🧪 How to Test

Steps to test this PR:

  1. ...
  2. ...
  3. ...

📝 Additional Notes

Any additional information reviewers should know.

Summary by CodeRabbit

  • Chores
    • Optimized build workflows to include backend dependencies in shared build steps.
    • Improved package exports configuration for better module resolution and type declaration support.
    • Cleaned up and reorganized imports across the codebase for consistency.
    • Enhanced TypeScript type safety with stricter type casts.
    • Added caching layer for rate limit settings to improve performance.

- Use type-only imports for NextRequest and FormEvent
- Remove unused imports: useState, format, useMemo, formatDistanceToNow
- Remove unused StatusBadge component in feedback page
- Fix import group ordering (externals before internals, empty lines between groups)
- Prefix unused variables and params with underscore (_isLoading, _currentPreset, _onPageChange, etc.)
- kal-admin/vercel.json: use turbo build pipeline (mirrors kal-frontend)
  so kal-shared and kal-backend are built before kal-admin on Vercel
- kal-shared/package.json: add exports field for NodeNext module resolution
- kal-backend/package.json: add types/exports fields pointing to compiled
  router declarations so consumers don't need deep source imports
- kal-admin/src/lib/trpc.ts: replace deep source import with package root
- kal-frontend/src/lib/trpc.ts: same fix
- Replace all `as any` casts with typed alternatives (Filter<Document>, User['_id'])
- Fix import ordering across multiple files (auto-fixed by eslint --fix)
- Merge duplicate kal-shared imports into single statement
- Rename unused caught error to _error in chat router
- Add eslint-disable comment for unfixable import/order edge case in rate-limit.ts
…kflows

kal-frontend and kal-admin import AppRouter from kal-backend's compiled
dist/. Without building kal-backend first, the module cannot be resolved
in CI causing all trpc.* calls to fail type checking.
@vercel

vercel Bot commented Mar 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kal-admin Ready Ready Preview, Comment Mar 26, 2026 11:14am
kal-frontend Ready Ready Preview, Comment Mar 26, 2026 11:14am

@rekabytes
rekabytes merged commit c9a33f2 into main Mar 15, 2026
11 of 12 checks passed
@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef5aad02-ae84-46f1-80ae-ab2deefdbfaf

📥 Commits

Reviewing files that changed from the base of the PR and between 2ccb6a1 and 4fc9e28.

📒 Files selected for processing (27)
  • .github/workflows/admin.yml
  • .github/workflows/frontend.yml
  • packages/kal-admin/src/app/api/auth/login/route.ts
  • packages/kal-admin/src/app/api/trpc/[...trpc]/route.ts
  • packages/kal-admin/src/app/dashboard/api-keys/page.tsx
  • packages/kal-admin/src/app/dashboard/feedback/page.tsx
  • packages/kal-admin/src/app/dashboard/logs/page.tsx
  • packages/kal-admin/src/app/dashboard/settings/page.tsx
  • packages/kal-admin/src/app/dashboard/users/page.tsx
  • packages/kal-admin/src/app/layout.tsx
  • packages/kal-admin/src/app/login/page.tsx
  • packages/kal-admin/src/lib/trpc.ts
  • packages/kal-admin/vercel.json
  • packages/kal-backend/package.json
  • packages/kal-backend/src/index.ts
  • packages/kal-backend/src/lib/cache.ts
  • packages/kal-backend/src/lib/context.ts
  • packages/kal-backend/src/lib/platform-settings.ts
  • packages/kal-backend/src/lib/wsServer.ts
  • packages/kal-backend/src/middleware/cache-middleware.ts
  • packages/kal-backend/src/middleware/rate-limit.ts
  • packages/kal-backend/src/routers/chat.ts
  • packages/kal-backend/src/routers/food.ts
  • packages/kal-backend/src/routers/platform-settings.ts
  • packages/kal-backend/src/routers/user.ts
  • packages/kal-frontend/src/lib/trpc.ts
  • packages/kal-shared/package.json

📝 Walkthrough

Walkthrough

This PR modernizes the monorepo's module resolution and build setup. It adds kal-backend to GitHub Actions workflows for proper dependency building, updates package.json exports in kal-backend and kal-shared for module resolution, changes cross-package imports to use the new export paths, converts runtime imports to type-only imports, removes unused imports, and applies formatting normalization throughout the codebase.

Changes

Cohort / File(s) Summary
Build Workflow Updates
.github/workflows/admin.yml, .github/workflows/frontend.yml
Both workflows now build kal-backend in addition to kal-shared and kal-baml in their "Build shared dependencies" steps.
Package Export Configuration
packages/kal-backend/package.json, packages/kal-shared/package.json
Both packages now define explicit exports fields with type and import resolution paths, enabling proper module resolution when imported from other packages.
Type-Only Import Conversions
packages/kal-admin/src/app/api/auth/login/route.ts, packages/kal-admin/src/app/api/trpc/[...trpc]/route.ts, packages/kal-admin/src/app/login/page.tsx
NextRequest and FormEvent imports converted to type-only imports, reducing bundled code while preserving type safety.
Cross-Package Import Path Updates
packages/kal-admin/src/lib/trpc.ts, packages/kal-frontend/src/lib/trpc.ts
AppRouter import paths changed from kal-backend/src/routers to kal-backend to use the newly configured package exports.
Unused Import Cleanup
packages/kal-admin/src/app/dashboard/api-keys/page.tsx, packages/kal-admin/src/app/dashboard/feedback/page.tsx
Removed unused imports (useState, format, useMemo, StatusBadge component); feedback page also removed unused StatusBadge component definition.
Page Component Refactoring
packages/kal-admin/src/app/dashboard/logs/page.tsx, packages/kal-admin/src/app/dashboard/users/page.tsx, packages/kal-admin/src/app/dashboard/settings/page.tsx
Internal variable and prop names aliased with underscores; new imports added (formatDistanceToNow); minor formatting adjustments.
Deployment Configuration Update
packages/kal-admin/vercel.json
Install and build commands refactored to use Turbo with monorepo context (cd ../.. && pnpm turbo build --filter=kal-admin...).
Backend Library & Context Updates
packages/kal-backend/src/lib/context.ts, packages/kal-backend/src/lib/platform-settings.ts
Admin virtual user now includes tier: "pro"; platform-settings adds caching logic with Cache integration; type casting improved from as any to explicit as unknown as Filter<Document>.
Backend Import Reordering & Type Casting
packages/kal-backend/src/index.ts, packages/kal-backend/src/lib/cache.ts, packages/kal-backend/src/lib/wsServer.ts, packages/kal-backend/src/middleware/cache-middleware.ts, packages/kal-backend/src/routers/food.ts, packages/kal-backend/src/routers/user.ts
Imports reordered for consistency; no functional changes; minor formatting adjustments.
String Quote Style Normalization
packages/kal-backend/src/routers/chat.ts
All single-quoted string literals converted to double-quoted strings throughout; no behavioral impact.
Rate Limit Middleware & Platform Settings Router
packages/kal-backend/src/middleware/rate-limit.ts, packages/kal-backend/src/routers/platform-settings.ts
Imports reorganized with type annotations; MongoDB filter typing improved; multiline formatting applied for readability; no logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

  • Dev #3: Both PRs update kal-backend package exports and change cross-package AppRouter imports to use the new export path.
  • Dev #114: Both PRs modify how kal-admin/kal-frontend import AppRouter from kal-backend and add build steps to support those imports.
  • fix: show username in profile card from Logto claims #8: Both PRs modify packages/kal-backend/src/lib/context.ts, including changes to user creation and displayName fallback logic.

Poem

🐰 Hoppy coding with TypeScript's gleam,
Exports configured like a well-oiled dream,
Imports refined, quotes polished bright,
Build steps unified, monorepo's just right,
Caching and types in perfect harmony—
A bundled delight for all to see!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant