Skip to content

Prefer Copilot harness once for editor sessions#326178

Merged
TylerLeonhardt merged 3 commits into
mainfrom
tyleonha/prefer-copilot-harness
Jul 16, 2026
Merged

Prefer Copilot harness once for editor sessions#326178
TylerLeonhardt merged 3 commits into
mainfrom
tyleonha/prefer-copilot-harness

Conversation

@TylerLeonhardt

@TylerLeonhardt TylerLeonhardt commented Jul 16, 2026

Copy link
Copy Markdown
Member

What

Base PR of a stacked pair. Adds the chat.editor.preferCopilotHarness setting (replacing the chat.editor.defaultProvider enum).

When enabled, an existing local editor chat session is swapped to the Agent Host Copilot CLI exactly once, guarded by a persisted marker (CHAT_PREFERRED_COPILOT_HARNESS_STORAGE_KEY).

The one-time swap only fires when the agent host is enabled — we don't try to swap to a Copilot harness that isn't available. The setting has no other effect: it does not change the computed default provider or editor session-type visibility, so leaving it off (the default) preserves today's behavior. Fresh users are unaffected by this PR.

Scope

  • chat.editor.preferCopilotHarness setting.
  • One-time Local -> Copilot swap in resolveDefaultNewChatSessionType, gated on the marker and agentHostEnabled.
  • Thread agentHostEnabled (from IAgentHostEnablementService) into the swap path (clearChatSessionPreservingType and its callers).
  • Unit tests in constants.test.ts (including the agent-host gate and the once-only marker).

Stacked follow-up

The stacked PR (#326086) builds on this to make Agent Host Copilot the default for both editor and panel chat whenever the agent host is enabled (i.e. for first-time users), while preferCopilotHarness stays scoped to this one-time migration.

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

Introduces opt-in preference and one-time migration toward Agent Host Copilot for editor chat sessions.

Changes:

  • Replaces the provider enum with chat.editor.preferCopilotHarness.
  • Adds persisted one-time migration state and provider resolution.
  • Updates session creation, restoration, picker behavior, and tests.
Show a summary per file
File Description
constants.test.ts Tests provider preference and migration behavior.
constants.ts Implements default-provider and migration resolution.
chatSessionTypePreference.ts Persists the migration marker.
chatViewPane.ts Applies preference during panel restoration.
sessionTargetPickerActionItem.ts Reacts to the new setting.
chatActions.ts Uses migration-aware resolution for new sessions.
agentHostEnablementService.ts Registers the boolean setting.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 5
  • Review effort level: Medium

Comment thread src/vs/workbench/contrib/chat/browser/actions/chatActions.ts Outdated
Comment thread src/vs/workbench/contrib/chat/common/constants.ts Outdated
Comment thread src/vs/workbench/contrib/chat/browser/widgetHosts/viewPane/chatViewPane.ts Outdated
Comment thread src/vs/workbench/contrib/chat/common/constants.ts Outdated
roblourens
roblourens previously approved these changes Jul 16, 2026
Add the `chat.editor.preferCopilotHarness` setting (replacing the
`chat.editor.defaultProvider` enum). When enabled, an existing local editor
chat session is swapped to the Agent Host Copilot CLI exactly once, guarded by
a persisted marker (CHAT_PREFERRED_COPILOT_HARNESS_STORAGE_KEY).

The one-time swap only fires when the agent host is enabled, since the Copilot
harness is otherwise unavailable. The setting has no other effect: it does not
change the computed default provider or editor session-type visibility for
fresh users, so leaving it off (the default) preserves today's behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The comment referenced the `chat.editor.preferCopilotHarness` setting selecting
a provider, but that setting no longer drives the computed default. Describe the
actual behavior: acquire the computed default when it is non-local, else fall
back to a local session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TylerLeonhardt
TylerLeonhardt marked this pull request as draft July 16, 2026 17:58
`resolveDefaultNewChatSessionType` set the migration marker as a side effect of
merely computing the type, so callers that discarded the result (notably the
editor New Chat path, which called `widget.clear()`) consumed the one-time swap
without ever applying it. The editor then stayed on Local, and the marker
blocked any future swap.

Make `resolveDefaultNewChatSessionType` pure: it returns
`{ sessionType, isPreferCopilotHarnessSwap }` and no longer writes the marker.
Callers persist the marker only when they actually apply the swap:

- The sidebar path in `clearChatSessionPreservingType` marks after loading the
  swapped session.
- `clearChatEditor` now resolves the swap for a local editor session, opens a
  Copilot editor, and marks it there instead of recomputing a swap-unaware
  default via `getDefaultNewChatSessionResource`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TylerLeonhardt
TylerLeonhardt marked this pull request as ready for review July 16, 2026 18:43
@TylerLeonhardt
TylerLeonhardt enabled auto-merge (squash) July 16, 2026 18:43
@TylerLeonhardt
TylerLeonhardt merged commit 44908a4 into main Jul 16, 2026
29 checks passed
@TylerLeonhardt
TylerLeonhardt deleted the tyleonha/prefer-copilot-harness branch July 16, 2026 20:04
@vs-code-engineering vs-code-engineering Bot added this to the 1.130.0 milestone Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants