fix(tui): reject stale session model switches - #56083
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a TUI gateway edge case where config.set model changes could incorrectly fall back to the global/default model switch path when the caller provided a stale session_id that no longer maps to a live session. This aligns desktop/TUI model picker behavior with the intended “session-scoped override unless explicitly global” contract.
Changes:
- Reject
config.setrequests forkey=="model"when a non-emptysession_idis provided but not found in_sessions. - Preserve the intentional global model-switch behavior when
session_idis empty/omitted. - Add a regression test ensuring stale session model switch requests do not hit the global model switch path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tui_gateway/server.py | Rejects stale session_id model updates instead of falling back to global model switching. |
| tests/test_tui_gateway_server.py | Adds coverage to prevent missing-session requests from invoking the global model switch path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f4bf168 to
91db1d4
Compare
|
Update: rebased this branch onto current Validation:
Current head: |
|
Thanks for the focused regression fix. Current main still has the reported fallthrough: The PR's early 4001 guard distinguishes those cases while retaining the intentional empty-ID global path, and its added regression covers model plus the other mutating |
91db1d4 to
63f0fdc
Compare
|
Rebased the branch onto the latest main and pushed the updated head 63f0fdc. The patch remains limited to rejecting stale session-scoped config.set model updates while preserving the explicit global path.\n\nValidation on the rebased head:\n- uv run --extra dev pytest tests/test_tui_gateway_server.py -k config_set -q - 34 passed, 290 deselected\n- |
Summary
config.setupdates when a non-emptysession_idno longer maps to a live gateway sessionFixes #56058
Tests
uv run --extra dev pytest tests/test_tui_gateway_server.py -k config_set -qnpm --workspace apps/desktop run test:ui -- src/app/session/hooks/use-model-controls.test.tsxuv run --extra dev ruff check tui_gateway/server.py tests/test_tui_gateway_server.pygit diff --check origin/main...HEAD