#19087: fix(sessions): sync display fields on model switch
gateway
size: M
Cluster:
Session Management Enhancements
## Summary
Fixes #18603
`applyModelOverrideToSessionEntry()` updated `providerOverride`/`modelOverride` but left the display fields (`model`/`modelProvider`) stale. Every UI surface — session list, CLI status, TUI — reads the display fields, so a switched model appeared unchanged until the next message was actually sent.
- On model switch: write display fields alongside override fields
- On revert-to-default: clear display fields so consumers fall back to configured defaults
- Added `model-overrides.test.ts` (12 tests) covering set, clear, idempotency, stale display sync, auth profile handling, and timestamp behavior
- Extended `sessions-patch.test.ts` with display field assertions and two new test cases
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed model switch display bug where UI surfaces showed stale model info. The function `applyModelOverrideToSessionEntry()` now syncs display fields (`model`/`modelProvider`) alongside override fields (`modelOverride`/`providerOverride`), ensuring session lists, CLI status, and TUI reflect changes immediately.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- Clean bug fix with comprehensive test coverage (12 new unit tests in model-overrides.test.ts plus 2 integration tests in sessions-patch.test.ts). The fix is straightforward: syncing display fields alongside override fields. All edge cases are tested including idempotency, stale display sync, clearing on default, and the exact regression scenario from issue #18603. No breaking changes or risky refactoring.
- No files require special attention
<sub>Last reviewed commit: 653c915</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#6750: fix(tui): show session model overrides in status bar
by ewijaya · 2026-02-02
82.8%
#21847: fix(session): /new and /reset no longer carry over model overrides
by hydro13 · 2026-02-20
82.1%
#21849: fix(session): clear model/provider overrides on /new and /reset
by widingmarcus-cyber · 2026-02-20
81.3%
#21932: fix(tui): eliminate stale model indicator lag in TUI
by graysurf · 2026-02-20
80.7%
#17414: fix(sessions): refresh contextTokens when model override changes
by michaelbship · 2026-02-15
80.4%
#21876: fix(session): clear model override on /new and /reset
by sauerdaniel · 2026-02-20
78.9%
#21731: Fix: clear stale session runtime model on /new, /reset, and session...
by AIflow-Labs · 2026-02-20
78.5%
#16478: fix(gateway): fall back to lookupContextTokens on model switch
by colddonkey · 2026-02-14
78.4%
#17011: fix(/new /reset): clear model override for reset turn
by Limitless2023 · 2026-02-15
78.4%
#20185: fix(model): recognize default/reset/clear keywords to clear session...
by yxshee · 2026-02-18
78.2%