Repository navigation
feat(chat): enhance model selection logic and session handling - #324843
Merged
Merged
Conversation
- Implemented functions to manage model selection persistence and validation during session switches: - `shouldDropAgnosticDraftModel`: Determines if a draft model should be dropped based on session type compatibility. - `shouldPersistModelSelection`: Checks if a model selection should be persisted based on user actions and session state. - `shouldSuppressModelPersistenceOnSessionSwitch`: Suppresses model persistence during session switches for empty own-pool sessions. - `shouldRestorePerTypeModelOnSessionSwitch`: Restores the persisted model for fresh untitled own-pool sessions. - `shouldWaitForSessionModel`: Decides whether to wait for a session's remembered model to load before applying a default. - Enhanced `ChatService` to backfill missing picker selections from previously saved states during session restoration, ensuring user selections are honored. - Added comprehensive tests for new logic and regression scenarios to prevent model selection issues during session transitions.
Don Jayamanne (DonJayamanne)
force-pushed
the
don/wide-road-runner-refactor
branch
from
July 7, 2026 23:00
10359a3 to
5473206
Compare
Don Jayamanne (DonJayamanne)
changed the base branch from
don/wide-roadrunner
to
main
July 7, 2026 23:01
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a set of related model-selection bugs in agent-host chat sessions where switching to (or restoring) a session would revert the picker to the pool default (e.g. Auto/Haiku) instead of the remembered per-harness model, and could corrupt the persisted per-session-type storage key. It also fixes a "custom agent picker flips to a stale agent after send" bug in the mode synchronizer. The approach extracts the decision logic into small, unit-tested pure functions in chatModelSelectionLogic.ts, and rewires chatInputPart.ts to suppress storage writes during a session switch while restoring/waiting for the correct model.
Changes:
- Adds pure predicates (
shouldDropAgnosticDraftModel,shouldPersistModelSelection,shouldSuppressModelPersistenceOnSessionSwitch,shouldRestorePerTypeModelOnSessionSwitch,shouldWaitForSessionModel) and threads them throughChatInputPart, replacing the removed_getRememberedSessionTypeModelseeding with a session-switch guard + a cold-restore wait (_waitForSessionModel) and late custom-mode re-apply (_restorePersistedCustomModeIfAvailable). - Refactors the large
onDidChangeViewModelhandler into named helpers (handleViewModelChangeand friends) and addsbackfillRestoredPickerStateinChatServiceto recover dropped picker selections at cold restore. - Restricts
AgentHostModeSynchronizerto only seed the shared per-scheme agent into untitled sessions viaisUntitledChatSession.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/browser/widget/input/chatModelSelectionLogic.ts |
Adds five exported pure decision helpers governing draft-model dropping, persistence suppression, per-type restore, and cold-restore waiting. |
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts |
Wires session-switch decisions, adds authoritative-wait guarding of persistence, _waitForSessionModel, _restorePersistedCustomModeIfAvailable, and extracts the view-model-change handler into helpers. |
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts |
Adds backfillRestoredPickerState to recover model/mode from saved state during remote session restore. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostModeSynchronizer.ts |
Guards the shared per-scheme agent seed to untitled sessions only. |
src/vs/workbench/contrib/chat/test/browser/widget/input/chatModelSelectionLogic.test.ts |
Adds predicate tests and a storage-write "ledger" simulation of the session-switch sequence, including a negative control. |
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts |
Adds tests for backfillRestoredPickerState. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostModeSynchronizer.test.ts |
Adds untitled/established coverage for the new seed guard. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Medium
Don Jayamanne (DonJayamanne)
marked this pull request as ready for review
July 7, 2026 23:49
Don Jayamanne (DonJayamanne)
enabled auto-merge (squash)
July 7, 2026 23:49
Megan Rogge (meganrogge)
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented functions to manage model selection persistence and validation during session switches:
shouldDropAgnosticDraftModel: Determines if a draft model should be dropped based on session type compatibility.shouldPersistModelSelection: Checks if a model selection should be persisted based on user actions and session state.shouldSuppressModelPersistenceOnSessionSwitch: Suppresses model persistence during session switches for empty own-pool sessions.shouldRestorePerTypeModelOnSessionSwitch: Restores the persisted model for fresh untitled own-pool sessions.shouldWaitForSessionModel: Decides whether to wait for a session's remembered model to load before applying a default.Enhanced
ChatServiceto backfill missing picker selections from previously saved states during session restoration, ensuring user selections are honored.Added comprehensive tests for new logic and regression scenarios to prevent model selection issues during session transitions.
Fixes #322792