chat: restore last-used agent and model for new chat editors#323011
Merged
Conversation
- New chat editors always opened with the Local agent and the Auto model, even right after the user had been working with an agent host (e.g. Copilot Agent Host). The last-used agent/model was never consulted, so users had to re-pick the agent, model, and model configuration for every new editor, and it reset in every new workspace. - Persists the last-used non-local chat agent (session type) at profile scope and prefers it when resolving the session type for a new chat editor, so the editor reopens with the agent the user last worked with across windows and workspaces. An explicit chat.editor.defaultProvider still wins. - Restores that agent's last-used model and its configuration (e.g. context size, thinking effort) for the fresh editor session, mirroring the existing reopened-session restore. Fixes #322792 (Commit message generated by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the “New Chat Editor” experience by persisting and restoring the last-used non-local chat agent (session type) and its model/configuration, so new editors don’t always start with Local + Auto when the user has been working with an agent host. It does so by recording the last-focused agent-backed session type into profile storage, preferring it when creating a new editor session (unless chat.editor.defaultProvider is explicitly set), and seeding the model/config for fresh sessions of that agent.
Changes:
- Persist the last-used non-local editor chat session type (agent) at profile scope and prefer it for new chat editors when no explicit default provider is configured.
- Update new chat editor creation paths (editor input + actions) to use the new “prefer last-used agent” resolver.
- Restore the remembered agent’s last-used model/configuration for fresh sessions and add unit tests for the new session-type resolution logic.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/constants.ts | Adds storage key + new resolver functions to prefer last-used agent for new editor sessions (and corresponding resource creation). |
| src/vs/workbench/contrib/chat/test/common/constants.test.ts | Adds unit coverage for getNewChatEditorSessionType last-used-agent precedence behavior. |
| src/vs/workbench/contrib/chat/browser/widgetHosts/editor/chatEditorInput.ts | Uses profile-stored last-used session type when creating an untitled/new chat editor session. |
| src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts | Seeds fresh sessions with the remembered model/config for session types that have their own model pool. |
| src/vs/workbench/contrib/chat/browser/widget/chatWidgetService.ts | Records last-focused non-local session type (excluding Quick Chat) into profile storage. |
| src/vs/workbench/contrib/chat/browser/actions/chatActions.ts | Updates “New Chat Editor” session URI creation to prefer last-used agent via the new resolver. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 6
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dmitrivMS
approved these changes
Jun 25, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
chat.editor.defaultProviderstill wins.Fixes #322792
(Commit message generated by Copilot)