fix: resolve per-session model overrides using app session ID#996
fix: resolve per-session model overrides using app session ID#996Kennems wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
📝 WalkthroughWalkthroughThe change propagates application session IDs into provider model resolution, prioritizes per-session overrides, filters conflicting Claude model environment variables, and updates command model selection to honor valid user overrides. ChangesSession model override handling
Sequence Diagram(s)sequenceDiagram
participant ChatUI
participant ChatWebSocket
participant ProviderRuntime
participant ProviderModelsService
participant ActiveModelStore
ChatUI->>ChatWebSocket: send message with sessionId
ChatWebSocket->>ProviderRuntime: pass appSessionId
ProviderRuntime->>ProviderModelsService: resolveResumeModel(..., appSessionId)
ProviderModelsService->>ActiveModelStore: getChangedActiveModel(appSessionId)
ActiveModelStore-->>ProviderModelsService: model override
ProviderModelsService-->>ProviderRuntime: resolved model
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
resolveCommandModel called getCurrentActiveModel which reads from the JSONL file, never checking session-model-changes.json where the UI stores per-session model overrides via /active-model. Now checks the stored overrides first before falling back to the provider default. Fixes siteboon#981 (display part) Co-Authored-By: Claude <noreply@anthropic.com>
The /active-model endpoint stores model changes keyed by app session ID, but provider runtimes called resolveResumeModel with only the provider- native session ID, so the stored override was never found. - Update resolveResumeModel to accept optional appSessionId parameter - Pass appSessionId from handleChatSend to all provider runtimes - Strip ANTHROPIC_MODEL env vars so explicit model option takes precedence - Add test verifying appSessionId-based model resolution Fixes siteboon#981 (runtime part) Co-Authored-By: Claude <noreply@anthropic.com>
1e1141b to
03c7f1c
Compare
Sunjaieks
left a comment
There was a problem hiding this comment.
@Kennems
I also made a PR just for your reference: https://github.com/siteboon/claudecodeui/pull/998/changes
Following points are missed in your PR:
- https://github.com/siteboon/claudecodeui/pull/998/changes#diff-109e679f789e12dec8fb6884a19ca19526b4e4333fbb8c4d7e02040fda6f6983R146
because in in claude's Jsonl file, field of model can be "<synthetic>"
2.847c9b7#diff-dda58f7c69e200b74287459fcd373aaf41a5ad0b25d31d91c8db2021a62b27e9R544
it will be better that new session will use the latest model which user selected from other session.
3.847c9b7#diff-109e679f789e12dec8fb6884a19ca19526b4e4333fbb8c4d7e02040fda6f6983R248
for highlighting
- maybe anything else?
I am new to this project, so maybe my PR also missed something. you can ask AI to analyze and merge the good point of each other.
Problem
Selecting a model from the Chat UI (
/model) stores the override insession-model-changes.jsonkeyed by the app session ID, but two things prevented it from working:Display was stale —
resolveCommandModel(used by/model,/cost,/status) calledgetCurrentActiveModelwhich reads from the JSONL file, never checking the stored overrides. The UI always showed the old model after switching.Runtime lookup key mismatch — All provider runtimes (cursor, codex, opencode) called
resolveResumeModelwithoutappSessionId, so the lookup key (provider:providerNativeSessionId) never matched the stored key (provider:appSessionId).Env vars could override the model —
ANTHROPIC_MODELand friends inprocess.envwere forwarded to the SDK subprocess, potentially overriding the explicitmodeloption.Changes
commands.js—resolveCommandModelchecksgetChangedActiveModel(session-model-changes.json) before falling back togetCurrentActiveModel(JSONL/provider default). Fixes/model,/cost,/statusshowing stale model.claude-sdk.js,cursor-cli.js,openai-codex.js,opencode-cli.js— PassappSessionIdtoresolveResumeModelso the stored override is found.claude-sdk.js— StripANTHROPIC_MODEL,ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL,ANTHROPIC_DEFAULT_HAIKU_MODELfrom env forwarded to the SDK subprocess so the explicit model argument wins.Test — Existing test
resolveResumeModel uses appSessionId for model override lookupcovers the core resolution logic.Fixes #981
Summary by CodeRabbit
New Features
Bug Fixes
active-modeloverrides before falling back to the current active model or catalog default.Tests