fix: refresh stale fallback model catalog to current Claude models - #78
Conversation
The fallback MODEL_CATALOG (served by models.list until any session runs a turn and the live SDK supportedModels() list is cached) still pointed opus/sonnet at Opus 4.7 / Sonnet 4.6 — so the web UI's model picker showed old models after every daemon restart, since resumed sessions spawn their provider lazily and the live list only arrives once a turn runs. The live-list plumbing itself is intact (provider reports on first query; the picker refetches while the catalog is not live). - opus → claude-opus-4-8 (Opus 4.8), sonnet → claude-sonnet-5 (Sonnet 5); haiku stays claude-haiku-4-5-20251001 - context-window table now recognizes all current 1M families (Fable 5, Opus 4.5-4.8, Sonnet 5, Sonnet 4.6) instead of only opus-4-7 — the sonnet alias and Sonnet 4.6 sessions were being under-reported as 200k, inflating ctx% warnings 5x - stale version comments updated across daemon + TUI status bar Old ids remain valid session values (they're still-served models and resolveModelId passes any claude-* through); only the opinionated alias→current-best mapping and the window table moved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
+ Coverage 80.76% 80.79% +0.03%
==========================================
Files 59 59
Lines 8904 8920 +16
==========================================
+ Hits 7191 7207 +16
Misses 1713 1713
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughUpdates the model catalog to new canonical IDs (claude-opus-4-8, claude-sonnet-5), reworks context-window resolution to use a fragment-based ONE_MILLION_FAMILIES table with updated alias behavior (opus/sonnet now resolve to 1M, haiku to default), and updates related tests and comments across daemon and TUI files. ChangesModel catalog and context-window resolution update
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)Not applicable — changes are limited to lookup-table logic, catalog data, and documentation comments without new multi-component interaction flows. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/daemon/context-windows.ts (2)
25-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider consolidating the 1M-context constant across files.
ONE_MILLION_CONTEXT = 1_000_000here is effectively re-declared as separate hardcoded literals incontext-math.ts(CONTEXT_WINDOW_DEFAULT),session.ts(Session.CONTEXT_WINDOW), andStatusBar.tsx(CONTEXT_WINDOW_FALLBACK), plus per-modelcontextWindowfields inmodels.ts. This exact kind of scatter is what let the fallback catalog go stale in the first place (per the PR description). Centralizing on one exported constant (imported everywhere) would prevent a future drift bug of the same shape.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/daemon/context-windows.ts` around lines 25 - 39, The 1M-context value is duplicated across several places and should be centralized to avoid drift. Move the shared 1_000_000 constant into a single exported source from context-windows.ts (or an equivalent shared module) and update context-math.ts, session.ts, StatusBar.tsx, and models.ts to import and use it instead of hardcoded literals. Keep ONE_MILLION_FAMILIES and any per-model contextWindow definitions aligned with that shared constant so all context-window fallback logic stays in sync.
26-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDot-form family fragments look unused.
Entries like
"opus-4.5","opus-4.6","opus-4.7","opus-4.8"(dot separator) sit alongside their dash equivalents, but Anthropic model ids consistently use the dash form (e.g.claude-opus-4-8). If dot-form ids never actually appear in practice, these entries are dead weight in the match loop.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/daemon/context-windows.ts` around lines 26 - 38, The model-fragment list in the context matching logic includes dot-form aliases that appear unused, so clean up the redundant entries in the match loop. Update the fragment set in the `context-windows` handling code to keep only the actual Anthropic-style dash variants used by the model-id matching path, and remove the dot-separated duplicates if they are not referenced elsewhere. Use the `context-windows.ts` fragment list and its model matching logic as the place to verify and prune these aliases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/daemon/context-windows.ts`:
- Around line 25-39: The 1M-context value is duplicated across several places
and should be centralized to avoid drift. Move the shared 1_000_000 constant
into a single exported source from context-windows.ts (or an equivalent shared
module) and update context-math.ts, session.ts, StatusBar.tsx, and models.ts to
import and use it instead of hardcoded literals. Keep ONE_MILLION_FAMILIES and
any per-model contextWindow definitions aligned with that shared constant so all
context-window fallback logic stays in sync.
- Around line 26-38: The model-fragment list in the context matching logic
includes dot-form aliases that appear unused, so clean up the redundant entries
in the match loop. Update the fragment set in the `context-windows` handling
code to keep only the actual Anthropic-style dash variants used by the model-id
matching path, and remove the dot-separated duplicates if they are not
referenced elsewhere. Use the `context-windows.ts` fragment list and its model
matching logic as the place to verify and prune these aliases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 00af627a-155b-4510-b6af-a6adbeba4f57
📒 Files selected for processing (6)
src/daemon/context-math.tssrc/daemon/context-windows.test.tssrc/daemon/context-windows.tssrc/daemon/models.tssrc/daemon/session.tssrc/tui/components/StatusBar.tsx
|
Both nitpicks acknowledged, skipping as out of scope for this fix:
|
…log (#117) The 0.2.0 entry only covered the protocol/packages train (#100-#116) and missed ten PRs that also ship in this release: the untrusted-content sanitization and cross-tenant memory fixes (#91, #93 — now under a proper Security heading), the performance run (#94-#99), and the model catalog work (#78, #79). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
The model picker in the web UI shows Opus 4.7 / Sonnet 4.6 / Haiku 4.5 — stale names. Two causes:
MODEL_CATALOG(whatmodels.listserves until the live SDKsupportedModels()list is cached) still mappedopus→ Opus 4.7 andsonnet→ Sonnet 4.6.SessionManagercaches them, and the web picker refetches whenever it opens while the catalog isn't live.So the fix is refreshing the fallback (and its dependents), not rewiring.
Changes
opus→claude-opus-4-8(Opus 4.8),sonnet→claude-sonnet-5(Sonnet 5);haikuunchanged (Haiku 4.5 is current)opus-4-7— thesonnetalias and Sonnet 4.6 sessions were under-reported as 200k, inflating ctx% warnings 5×Old ids remain valid session values (still-served models;
resolveModelIdpasses anyclaude-*through) — only the opinionated alias→current-best mapping and the window table moved.Tests
Rewrote
context-windows.test.tsfor the current family table (1M families, alias windows, dated point releases, conservative unknown-model miss). Full suite: 722 pass / 0 fail, tsc + biome clean.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes