Repository navigation
chat: remember focused agent session's model as last-used - #323393
Merged
Don Jayamanne (DonJayamanne) merged 5 commits intoJun 29, 2026
Merged
Don Jayamanne (DonJayamanne) merged 5 commits into
Don Jayamanne (DonJayamanne) merged 5 commits into
Conversation
New chat editors for agent-host session types (e.g. Copilot Agent Host) defaulted to "Auto" even when open editors used a non-Auto model. The per-agent last-used key was only written on explicit picks, so restored sessions that kept their model (the _syncFromModel `keep` path) never recorded it; a fresh editor then read the stale "auto" value. Record the focused session's resolved model into the same per-session-type key on focus, so new editors restore it. Guarded to skip local sessions, types without their own model pool, and unresolved/transient models during async load. Adds shouldRecordSessionTypeDefaultModel + unit tests. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes model picker defaults for agent-host chat editors by ensuring the focused session’s resolved model is persisted as the last-used model for that session type, even when the model was restored implicitly (the “keep” path) rather than explicitly picked by the user.
Changes:
- Add
shouldRecordSessionTypeDefaultModeldecision helper to gate when a focused session should update the per-session-type last-used model. - Record the focused widget’s current resolved model as the session-type default during the existing “record last used session type” focus chokepoint.
- Add focused unit coverage for the new decision helper with multiple guard/skip cases.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/widget/input/chatModelSelectionLogic.test.ts | Adds unit tests for the new “should record default model” decision helper. |
| src/vs/workbench/contrib/chat/browser/widget/input/chatModelSelectionLogic.ts | Introduces shouldRecordSessionTypeDefaultModel helper to ensure safe persistence conditions. |
| src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts | Adds recordCurrentModelAsSessionTypeDefault() to persist the focused session’s resolved model for its session type. |
| src/vs/workbench/contrib/chat/browser/widget/chatWidgetService.ts | Hooks model-recording into the existing last-focused session type tracking. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Don Jayamanne (DonJayamanne)
marked this pull request as ready for review
June 29, 2026 05:14
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Don Jayamanne (DonJayamanne)
enabled auto-merge (squash)
June 29, 2026 05:14
Justin Chen (justschen)
approved these changes
Jun 29, 2026
Giuseppe Cianci (Giuspepe)
approved these changes
Jun 29, 2026
Don Jayamanne (DonJayamanne)
merged commit Jun 29, 2026
81d97ff
into
microsoft:main
29 checks passed
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.
Problem
New chat editors for agent-host session types (e.g. Copilot Agent Host) default the model picker to Auto even when every open editor of that type is on a non-Auto model (e.g. Opus 4.8).
Follow-up to the #322792 fix. The per-agent last-used key
chat.currentLanguageModel.<location>.<sessionType>is only written bysetCurrentLanguageModel, i.e. on explicit user picks. Sessions restored to a model that already matches their saved state take the_syncFromModelkeep path and never call it — so the visible Opus editors never record Opus. The key keeps the last explicit value (auto), and a fresh editor with no session state reads that and shows Auto.Fix
Record the focused session's resolved model as the last-used model for its type, at the same focus chokepoint that already records the last-used agent (
ChatWidgetService.recordLastUsedSessionType). Storage-key knowledge stays insideChatInputPartviarecordCurrentModelAsSessionTypeDefault().Guarded to only write when:
autoduring async load),Tests
shouldRecordSessionTypeDefaultModelpure function + 6 unit cases (record vs. local / no-pool / unresolved / not-in-pool / no-type).typecheck-clientandeslintclean.Notes
[ModelPickerDbg]logging from the prior research is left as-is.Fixes #322792