Skip to content

chat: restore last-used agent and model for new chat editors - #323011

Merged
Don Jayamanne (DonJayamanne) merged 7 commits into
mainfrom
DonJayamanne/322792
Jun 25, 2026
Merged

Don Jayamanne (DonJayamanne) merged 7 commits into
mainfrom
DonJayamanne/322792

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor
  • 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)

- 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 <[email protected]>
Copilot AI review requested due to automatic review settings June 25, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@DonJayamanne
Don Jayamanne (DonJayamanne) marked this pull request as ready for review June 25, 2026 21:24
@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit 34a9b07 into main Jun 25, 2026
46 of 47 checks passed
@DonJayamanne
Don Jayamanne (DonJayamanne) deleted the DonJayamanne/322792 branch June 25, 2026 21:38
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 25, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model switches to Auto for AH in every new workspace

3 participants