Skip to content

Add chat.{agents,editor}.claude.preferAgentHost EXP settings#321020

Merged
TylerLeonhardt merged 3 commits into
mainfrom
tyleonha/claude-prefer-agent-host
Jun 11, 2026
Merged

Add chat.{agents,editor}.claude.preferAgentHost EXP settings#321020
TylerLeonhardt merged 3 commits into
mainfrom
tyleonha/claude-prefer-agent-host

Conversation

@TylerLeonhardt

Copy link
Copy Markdown
Member

Summary

Introduces a pair of EXP-backed boolean settings that select between the Copilot extension's Claude implementation (EH) and the agent host's Claude implementation (AH) on a per-surface basis:

  • chat.agents.claude.preferAgentHost — gates the Agents Window
  • chat.editor.claude.preferAgentHost — gates the regular workbench sidebar

Both implementations register normally. Per-window suppression happens declaratively in three places:

  1. Extension chatSessions contribution when clause (extensions/copilot/package.json) — branches on isSessionsWindow to read the surface-appropriate setting.
  2. CopilotChatSessionsProvider (Agents Window-only consumer) — reads chat.agents.claude.preferAgentHost reactively in the existing _claudeEnabled listener.
  3. AgentHostContribution._shouldRegisterAgent() — mirrors the same per-window rule on the AH side; reactive listener flips the bridge live when the relevant setting changes.

Net effect: exactly one Claude implementation per window, live-switchable without a reload.

Why per-window rather than process-level

Earlier iterations forwarded the resolved preference to the agent host process via an env var so the AH would only register Claude when at least one preference was true. That coupled main-process spawn-time logic to UI lifecycle and required a window reload when toggling. The current design keeps the AH surface-agnostic (always register if SDK is reachable) and pushes the "which window sees which implementation" decision to the renderer, which already has the per-window context. The cost is constructing a ClaudeAgent instance in the AH process that may not be bridged anywhere — small, no SDK load.

Relationship to #320896

#320896 adds the same two setting names (plus four more in the family) and gates picker visibility without unregistering. Both providers stay in the registry, hidden only at the dropdown. This PR takes the unregistration path so downstream consumers (command palette, MRU, URI handlers) also see exactly one Claude. The two PRs conflict on the schema declarations; recommend coordinating before merge.

Test plan

  • Compile-client emits cleanly for changed files
  • Existing copilotChatSessionsProvider unit tests pass (with new cases added for preferAgentHost reactivity)
  • Manual launch verification across the matrix:
    • agents=true, editor=false: Agents Window shows AH-Claude only; sidebar shows EH-Claude only
    • agents=false, editor=true: inverse
    • agents=false, editor=false (default): both windows show EH-Claude
    • Live toggle of either setting flips the picker without window reload
  • ChatSessionsService._evaluateAvailability traces confirm per-window shouldBeRegistered matches the matrix

🤖 Generated with Claude Code

Introduces a pair of EXP-backed boolean settings that select between the
Copilot extension's Claude implementation (EH) and the agent host's
Claude implementation (AH) on a per-surface basis:

- chat.agents.claude.preferAgentHost gates the Agents Window
- chat.editor.claude.preferAgentHost gates the regular workbench sidebar

Both implementations register normally. Per-window suppression happens
declaratively in three places:

1. The extension's `chatSessions` contribution `when` clause branches on
   `isSessionsWindow` to read the surface-appropriate setting.
2. `CopilotChatSessionsProvider` (Agents Window-only consumer) reads the
   agents-window setting reactively.
3. `AgentHostContribution._shouldRegisterAgent()` mirrors the same
   per-window rule for the AH side, reactively listening for config flips.

Net effect: exactly one Claude implementation per window, live-switchable
without a reload.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 11, 2026 20:16
The block explained a decision that lives in `AgentHostContribution`, not
here. Removing it brings this file back to its pre-PR state.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

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

Adds two EXP-backed settings to choose (per window surface) whether Claude sessions are fulfilled by the Copilot extension (EH) or by the agent host (AH), aiming to ensure only one Claude provider is registered per window and allowing live switching.

Changes:

  • Introduces chat.agents.claude.preferAgentHost and chat.editor.claude.preferAgentHost settings and wires them into chat configuration.
  • Gates Claude provider registration on both sides: EH via Copilot extension chatSessions contribution when, AH via AgentHostContribution filtering.
  • Updates Agents Window Copilot sessions provider logic + tests to suppress EH-Claude when AH-Claude is preferred.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts Registers the two new EXP-backed settings in chat configuration.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts Filters AH provider registration per window based on the new settings and reacts to config flips.
src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts Suppresses EH-Claude session type when Agents Window prefers AH-Claude; adds reactive updates.
src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts Adds coverage for preferAgentHost gating and reactivity in sessionTypes.
src/vs/platform/agentHost/common/agentService.ts Defines exported setting IDs (agents/editor) and documents intended behavior.
src/vs/platform/agentHost/node/agentHostMain.ts Clarifies that Claude registers when reachable and renderer enforces per-window surfacing.
extensions/copilot/package.json Updates EH Claude chatSessions contribution when clause to be surface-aware via new settings.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 3

Comment thread src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts
Comment thread src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts
…gents

Two stale "Requires a window reload" notes in the setting descriptions
remained from when this was env-var-gated. The implementation is now
reactive in both EH and AH paths, so toggling takes effect live.

Also restrict `_authenticateWithServer` to the allowed agents instead of
all agents in root state — token resolution work for a Claude provider
suppressed in this window was wasted effort.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@TylerLeonhardt TylerLeonhardt marked this pull request as ready for review June 11, 2026 21:36
@TylerLeonhardt TylerLeonhardt enabled auto-merge (squash) June 11, 2026 21:45
@TylerLeonhardt TylerLeonhardt merged commit 826d1e7 into main Jun 11, 2026
25 checks passed
@TylerLeonhardt TylerLeonhardt deleted the tyleonha/claude-prefer-agent-host branch June 11, 2026 21:46
@vs-code-engineering vs-code-engineering Bot added this to the 1.125.0 milestone Jun 11, 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.

3 participants