MakeSense for GitHub — Make Sense of Any GitHub PR, with full cognitive coverage of every change.
getnao/nao#1360 — 44 files, 60 review comments
Consolidate Model Config into Project Default Models
Overview
Migrate model configuration from per-config columns to a centralized `default_models` JSONB column on the project table. Introduce `resolveDefaultModelSelection` to allow admin-pinned model overrides for background tasks. Update all background task services to use the new centralized resolution.
Technical Highlights
Migrations (0063): Move `model_provider`/`model_id` from `context_recommendation_config` to `default_models` JSONB column on `project`. Backfill uses JOIN, risks data loss with duplicate configs.
`src/utils/llm.ts`: Add `resolveDefaultModelSelection` function for centralized model resolution with fallback logic.
`src/services/*.ts`: Refactor compaction, memory, live-story, cron-nlp, context-recommendations, and automation-title to use `resolveDefaultModelSelection`.
`src/trpc/project.routes.ts`: Expose `getDefaultModels` and `updateDefaultModels` tRPC procedures for admin configuration.
`src/db/pg-schema.ts` / `sqlite-schema.ts`: Add `defaultModels` column, remove `modelProvider`/`modelId` from `contextRecommendationConfig`.
Frontend (`default-models-section.tsx`): New settings component for configuring default models per category or a single default.
`src/services/live-story.ts`: Add LLM inference tracking for live story refresh. Change error handling to throw instead of returning null (breaking change).
`src/queries/usage.queries.ts`: Include `llmInference` table in usage reports for cost tracking.
Impact
Functionality: Admins can centrally pin default models for background tasks (title generation, compaction, live story, context recommendations, memory extraction) per project.
Risk: Data loss possible during migration if multiple `context_recommendation_config` rows exist per project. The `live-story.ts` error handling change (throw vs null) is a breaking change for callers. Dual-write in `context-recommendation.routes.ts` risks inconsistency.
Files reviewed
- apps/backend/migrations-postgres/0063_default_models.sql — 1 comment(s)
- apps/backend/migrations-postgres/meta/0063_snapshot.json — 36 comment(s)
- apps/backend/migrations-postgres/meta/_journal.json — 0 comment(s)
- apps/backend/migrations-sqlite/0063_default_models.sql — 3 comment(s)
- apps/backend/migrations-sqlite/meta/0063_snapshot.json — 20 comment(s)
- apps/backend/migrations-sqlite/meta/_journal.json — 0 comment(s)
- apps/backend/src/db/pg-schema.ts — 0 comment(s)
- apps/backend/src/db/sqlite-schema.ts — 0 comment(s)
- apps/backend/src/queries/activity.queries.ts — 0 comment(s)
- apps/backend/src/queries/project.queries.ts — 0 comment(s)
- apps/backend/src/queries/usage.queries.ts — 0 comment(s)
- apps/backend/src/services/agent.ts — 0 comment(s)
- apps/backend/src/services/automation-title.ts — 0 comment(s)
- apps/backend/src/services/compaction.ts — 0 comment(s)
- apps/backend/src/services/context-recommendations.service.ts — 0 comment(s)
- apps/backend/src/services/cron-nlp.ts — 0 comment(s)
- apps/backend/src/services/live-story.ts — 0 comment(s)
- apps/backend/src/services/memory.ts — 0 comment(s)
- apps/backend/src/trpc/context-recommendation.routes.ts — 0 comment(s)
- apps/backend/src/trpc/project.routes.ts — 0 comment(s)
- apps/backend/src/trpc/shared-story.routes.ts — 0 comment(s)
- apps/backend/src/trpc/story.routes.ts — 0 comment(s)
- apps/backend/src/types/llm.ts — 0 comment(s)
- apps/backend/src/utils/llm.ts — 0 comment(s)
- apps/backend/tests/compaction.test.ts — 0 comment(s)
- apps/backend/tests/usage-queries.test.ts — 0 comment(s)
- apps/frontend/src/components/settings-search-index.ts — 0 comment(s)
- apps/frontend/src/components/settings/default-models-section.tsx — 0 comment(s)
- apps/frontend/src/components/side-panel/hooks/use-story-viewer-content.ts — 0 comment(s)
- apps/frontend/src/components/side-panel/hooks/use-story-viewer-live-settings.ts — 0 comment(s)
- apps/frontend/src/components/side-panel/story-header.tsx — 0 comment(s)
- apps/frontend/src/components/side-panel/story-viewer.tsx — 0 comment(s)
- apps/frontend/src/components/story-page-header.tsx — 0 comment(s)
- apps/frontend/src/hooks/use-llm-providers.ts — 0 comment(s)
- apps/frontend/src/hooks/use-time-ago.ts — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.settings.project.models.tsx — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.settings.recommendations.tsx — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.settings.usage.tsx — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.stories.preview.$chatId.$storySlug.tsx — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.stories.shared.$shareId.tsx — 0 comment(s)
- apps/frontend/src/routes/_sidebar-layout.stories.standalone.$storyId.tsx — 0 comment(s)
- apps/shared/src/background-models.ts — 0 comment(s)
- apps/shared/src/index.ts — 0 comment(s)
- apps/shared/tests/background-models.test.ts — 0 comment(s)
View the full interactive review (JavaScript required).