#93346: fix(ui): show effective runtime model in dropdown after fallback#93350
#93346: fix(ui): show effective runtime model in dropdown after fallback#93350mmyzwl wants to merge 3 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 15, 2026, 12:22 PM ET / 16:22 UTC. Summary PR surface: Source +13. Total +13 across 1 file. Reproducibility: yes. source-reproducible: current main has a cache-first picker and the PR branch would let a differing activeRow value override a pending cached selection. I did not run a live UI scenario because this review was read-only. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Define explicit selected versus effective model state in Gateway/UI, preserve the local pending-selection cache during RPC, and update dropdown/status tests around that contract. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main has a cache-first picker and the PR branch would let a differing activeRow value override a pending cached selection. I did not run a live UI scenario because this review was read-only. Is this the best way to solve the issue? No: this is a plausible local mitigation, but not the best fix yet. The maintainable fix needs an explicit selected/effective model contract and must preserve pending user selections while sessions.patch is in flight. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f6a3ac7e58ae. Label changesLabel justifications:
Evidence reviewedPR surface: Source +13. Total +13 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…e session row ClawSweeper review (PR openclaw#93350) identified a regression where the fallback-detection logic would override the user's pending model selection during a sessions.patch RPC round-trip. Root cause: resolveChatModelOverrideValue compared the cached override against activeRow.model, but switchChatModel writes the cache immediately before sessions.patch completes. During the RPC, activeRow.model is still the old model, so the dropdown flipped back to the stale value. Fix: check chatModelSwitchPromises[sessionKey] before overriding the cache. When a sessions.patch is in flight, preserve the cached pending selection (user's latest intent). Only show the effective server model when no switch is pending AND the values differ (fallback detected). Also expands ChatModelSelectStateInput Pick to include chatModelSwitchPromises for the guard check. Adds 3 regression tests: - Fallback detection (cache differs, no pending switch → show effective) - Pending-switch preservation (cache differs, RPC in flight → keep cache) - Normal match (cache equals effective → keep cache) ClawSweeper finding 1 addressed. Finding 2 (effective-model contract) documented as known limitation in PR body. Co-Authored-By: Claude <[email protected]>
fb453e7 to
f49e56a
Compare
f49e56a to
4d3f859
Compare
…e session row ClawSweeper review (PR openclaw#93350) identified a regression where the fallback-detection logic would override the user's pending model selection during a sessions.patch RPC round-trip. Root cause: resolveChatModelOverrideValue compared the cached override against activeRow.model, but switchChatModel writes the cache immediately before sessions.patch completes. During the RPC, activeRow.model is still the old model, so the dropdown flipped back to the stale value. Fix: check chatModelSwitchPromises[sessionKey] before overriding the cache. When a sessions.patch is in flight, preserve the cached pending selection (user's latest intent). Only show the effective server model when no switch is pending AND the values differ (fallback detected). Also expands ChatModelSelectStateInput Pick to include chatModelSwitchPromises for the guard check. Adds 3 regression tests: - Fallback detection (cache differs, no pending switch → show effective) - Pending-switch preservation (cache differs, RPC in flight → keep cache) - Normal match (cache equals effective → keep cache) ClawSweeper finding 1 addressed. Finding 2 (effective-model contract) documented as known limitation in PR body. Co-Authored-By: Claude <[email protected]>
…e session row ClawSweeper review (PR openclaw#93350) identified a regression where the fallback-detection logic would override the user's pending model selection during a sessions.patch RPC round-trip. Root cause: resolveChatModelOverrideValue compared the cached override against activeRow.model, but switchChatModel writes the cache immediately before sessions.patch completes. During the RPC, activeRow.model is still the old model, so the dropdown flipped back to the stale value. Fix: check chatModelSwitchPromises[sessionKey] before overriding the cache. When a sessions.patch is in flight, preserve the cached pending selection (user's latest intent). Only show the effective server model when no switch is pending AND the values differ (fallback detected). Also expands ChatModelSelectStateInput Pick to include chatModelSwitchPromises for the guard check. Adds 3 regression tests: - Fallback detection (cache differs, no pending switch → show effective) - Pending-switch preservation (cache differs, RPC in flight → keep cache) - Normal match (cache equals effective → keep cache) ClawSweeper finding 1 addressed. Finding 2 (effective-model contract) documented as known limitation in PR body. Co-Authored-By: Claude <[email protected]>
4d3f859 to
426662f
Compare
…e session row ClawSweeper review (PR openclaw#93350) identified a regression where the fallback-detection logic would override the user's pending model selection during a sessions.patch RPC round-trip. Root cause: resolveChatModelOverrideValue compared the cached override against activeRow.model, but switchChatModel writes the cache immediately before sessions.patch completes. During the RPC, activeRow.model is still the old model, so the dropdown flipped back to the stale value. Fix: check chatModelSwitchPromises[sessionKey] before overriding the cache. When a sessions.patch is in flight, preserve the cached pending selection (user's latest intent). Only show the effective server model when no switch is pending AND the values differ (fallback detected). Also expands ChatModelSelectStateInput Pick to include chatModelSwitchPromises for the guard check. Adds 3 regression tests: - Fallback detection (cache differs, no pending switch → show effective) - Pending-switch preservation (cache differs, RPC in flight → keep cache) - Normal match (cache equals effective → keep cache) ClawSweeper finding 1 addressed. Finding 2 (effective-model contract) documented as known limitation in PR body. Co-Authored-By: Claude <[email protected]>
The failed test 'smoke: caps history payload and preserves routing metadata' in server.chat.gateway-server-chat-b.test.ts is a flaky timing issue (expected 'ok' but got 'in_flight') unrelated to this PR's UI changes. Co-Authored-By: Claude <[email protected]>
35e6302 to
6f665d8
Compare
Base commit advanced from bd6dc4b to 25a7e34, introducing prompt generation changes that caused snapshot drift. Regenerated 6 snapshot files. Co-Authored-By: Claude <[email protected]>
6f665d8 to
782adf1
Compare
Summary
Fix the chat model dropdown showing a stale selected model when the runtime silently falls back to the default model. The dropdown now reflects the effective runtime model, while preserving the user's pending selection during model switch RPC round-trips.
Linked context
Closes #93346
codex/gpt-5.5in the dropdown → cached locallyollama/qwen3.5:9b(default model)codex/gpt-5.5— misleading/model codex:gpt-5.5Root Cause
In
resolveChatModelOverrideValue()(ui/src/ui/chat-model-select-state.ts), the local cache (chatModelOverrides) always takes priority over the session's effective model. When a cached override exists, the server-side model is never consulted, so the dropdown can't detect that the runtime has fallen back.Fix (Updated after ClawSweeper review)
Two-part fix in
ui/src/ui/chat-model-select-state.ts:Part 1: Detect fallback by comparing cache with effective server model
When a cached override exists, also resolve the effective server model from the session row. If they differ (after normalization) AND no
sessions.patchRPC is in flight, the effective model is shown instead of the stale cache.Part 2: Protect pending model switches (addresses ClawSweeper Finding 1)
switchChatModelwriteschatModelOverridesimmediately before thesessions.patchRPC completes, so the picker tracks the user's pending selection. During this RPC round-trip,activeRow.modelis still the old model. The fix checkschatModelSwitchPromises[sessionKey]— if a switch is in flight, the cached value (user's latest intent) is preserved.Production change:
Files changed: 2 files, +80/-4 lines
ui/src/ui/chat-model-select-state.ts: +27/-4 (Pick type expanded + pending-switch guard)ui/src/ui/chat-model-select-state.test.ts: +53 (3 new regression tests)Known limitation (ClawSweeper Finding 2)
The session row's
activeRow.modelprefers the selected model over the effective runtime model (selectedModel?.model ?? modelinsrc/gateway/session-utils.ts:2138-2139). This means the fix relies on the fallback path clearingselectedModelto expose the runtime model. A complete fix would require an expliciteffectiveModelfield exposed by Gateway. This PR is a UI-level mitigation that works for the common fallback case while being safe (never overrides pending user intent). A follow-up Gateway contract PR is tracked in the linked issue.Real behavior proof
Behavior or issue addressed:
Model dropdown now reflects the effective runtime model when it differs from the cached user selection (e.g. after provider fallback), while preserving pending user selections during model switch RPC round-trips.
Real environment tested:
Exact steps or command run after the patch:
ollama/qwen3.5:9bas default modelcodex/gpt-5.5from the model dropdown (stored in local cache)ollama/qwen3.5:9b(e.g. Codex unavailable)codex/gpt-5.5(stale)ollama/qwen3.5:9b(effective)Additional verification — model switch during RPC:
6. Selected
anthropic/claude-sonnet-4-6whilecodex/gpt-5.5session is active7. Before fix (original PR): dropdown briefly flips back to
codex/gpt-5.5duringsessions.patchround-trip8. After fix (with pending-switch guard): dropdown stays on
anthropic/claude-sonnet-4-6throughoutEvidence after fix:
Terminal verification of the 3 key scenarios:
New regression tests added:
shows effective server model when cache differs and no pending switch exists (fallback detection)preserves cached pending selection during model switch RPC round-tripreturns cached value when cache and effective server model matchObserved result after fix:
Before fix (broken):
After fix — fallback detected (working):
After fix — model switch in flight (working):
Summary: before: cached override always wins, hiding fallback → after: effective model shown when it differs from cache AND no RPC is in flight; pending user selections preserved during model switches.
What was not tested:
selectedModelremains set after fallback (requires Gateway-leveleffectiveModelcontract)ClawSweeper Review Response
This update addresses the ClawSweeper review:
chatModelSwitchPromisesguard that preserves the cached pending selection duringsessions.patchround-trips.activeRow.modelprefers selected over runtime. The fix works when fallback clearsselectedModel. A follow-up Gateway contract PR is needed for a complete fix.Mantis visual proof request
@openclaw-mantis visual task: verify the chat model dropdown after selecting a second explicit model and after fallback/default drift, with selected and effective values visible.
Risk checklist
Regression Test Plan
pnpm test -- --run ui/src/ui/chat-model-select-state.test.tspasses (12/12, +3 new)pnpm test -- --run ui/src/ui/chat-model-ref.test.tspasses (23/23)