fix(chat): prefer server session row over stale cache in model dropdown#93623
fix(chat): prefer server session row over stale cache in model dropdown#93623sunlit-deng wants to merge 1 commit into
Conversation
…model dropdown The chat model dropdown could show a cached model selection (e.g. codex/gpt-5.5) while the active session was actually using the default/fallback model. This happened because resolveChatModelOverrideValue always preferred the local chatModelOverrides cache without cross-referencing the server's session row. Now when a cached override exists but the server shows a different runtime model, the server value takes precedence — the dropdown reflects the actual model being used.
|
ClawSweeper review: did not complete due to Codex infrastructure failure. Reviewed June 16, 2026, 8:40 AM ET / 12:40 UTC. Summary PR surface: Source +14, Tests +14. Total +28 across 2 files. Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Review metrics: none identified. Merge readiness This is a ClawSweeper/Codex infrastructure failure, not a PR readiness or patch-quality verdict. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against aebf0bbd2da7. Evidence reviewedPR surface: Source +14, Tests +14. Total +28 across 2 files. View PR surface stats
What I checked:
Likely related people:
How this review workflow works
|
|
Closing this patch because it regresses the normal in-flight model-switch path.
The linked issue remains valid, but the durable fix needs an explicit selected-vs-effective model contract between Gateway and UI, with pending local selections preserved until confirmation. Focused UI tests passed, and fresh autoreview reproduced this blocker at high confidence. |
Summary
The chat model dropdown could show a cached model selection (e.g. codex/gpt-5.5)
while the active session was actually using the default/fallback model
(e.g. ollama/qwen3.5:9b). This happened because resolveChatModelOverrideValue
always preferred the local chatModelOverrides cache without cross-referencing
the server's session row.
When a user selects a model different from the default, the selection is stored
locally in chatModelOverrides and also sent to the server as a session patch.
But if the session later resets or drifts back to its default model (e.g. after
logout/login, session timeout, or model failover), the local cache retains the
old selection while the server reports the correct runtime model. The dropdown
then displays a misleading model.
Fix: In resolveChatModelOverrideValue(), when a cached override exists but
the server's active session row reports a different runtime model, prefer the
server value. The cached override is still used when the server has no model
data or when both values agree.
Fixes #93346
Linked context
Gateway row projection as two sides of the problem. This PR fixes the UI side
(cache-first picker) — the dropdown now accurately reflects the server-reported
runtime model.
Real behavior proof
Behavior addressed: Chat model dropdown now reflects actual runtime model
when the server session row differs from the locally cached override.
Real setup tested: Unit tests with vitest
Exact steps or command run after fix:
pnpm test -- --run ui/src/ui/chat-model-select-state.test.ts
After-fix evidence:
= test/vitest/vitest.ui.config.ts (1 test file)
= chat-model-select-state (10 tests)
Test Files 1 passed (1)
Tests 10 passed (10)
Start at 20:05:52
Duration 2.93s
New test case (prefers server session row over stale cached override):
Existing behavior preserved (normalizes cached bare overrides):
Observed result after the fix: All 10 tests pass, including 1 new test
covering the drift scenario. The fix is a pure state-selector change — no
component or server-side modifications needed.
What was not tested: E2E tests with live Gateway were not run. The fix is
a pure selector function change verified through unit tests.
Tests and validation
Risk checklist
Did user-visible behavior change? (Yes)
the server's runtime model instead of the stale cached selection.
Did config, environment, or migration behavior change? (No)
Did security, auth, secrets, network, or tool execution behavior change? (No)
What is the highest-risk area?
a slightly stale server response. The server value is authoritative once the
patch is confirmed.
How is that risk mitigated?
After the server confirms a patch, both values agree and the cache wins
normally. The divergence only occurs when the session genuinely drifted.
Current review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
conflates selected and runtime model identity into a single model/modelProvider
field. A follow-up could expose both fields separately for full transparency,
but this change already makes the dropdown accurate.
Which bot or reviewer comments were addressed?
this PR directly addresses that by cross-referencing the server row.
The Gateway row projection issue (selectedModel vs resolvedModel both
mapped to row.model) is noted but not addressed here.