Skip to content

Prompt restart for chat.agentHost.enabled setting#311531

Merged
roblourens merged 2 commits intomainfrom
roblou/agents/agent-host-instant-spawn
Apr 21, 2026
Merged

Prompt restart for chat.agentHost.enabled setting#311531
roblourens merged 2 commits intomainfrom
roblou/agents/agent-host-instant-spawn

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented Apr 20, 2026

Add chat.agentHost.enabled to the SettingsChangeRelauncher settings list so that toggling the setting prompts the user with the standard "A setting has changed that requires a restart" dialog.

Previously the agent host wouldn't start until the next app launch after enabling the setting. This surfaces the restart prompt immediately so the user knows to restart.

(Written by Copilot)

Previously, toggling chat.agentHost.enabled at runtime required an app
restart before the local agent host process actually spawned and the
chat/sessions integrations registered. The setting was checked exactly
once at construction time in four places, all of which early-returned if
disabled.

Each site now also registers a one-shot onDidChangeConfiguration listener
 true flip triggers setup without a restart:

- src/vs/code/electron-main/app.ts: wraps the
  ElectronAgentHostStarter + AgentHostProcessManager construction.
- src/vs/platform/agentHost/electron-browser/agentHostService.ts:
  AgentHostServiceClient calls _connect() on flip.
- src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/
  agentHostChatContribution.ts: extracted constructor body into _enable().
- src/vs/sessions/contrib/agentHost/browser/localAgentHost.contribution.ts:
  same one-shot pattern.

Disable still requires a restart (no teardown of the singleton renderer
service or utility process).

Adds 5 unit tests in agentHostChatContribution.test.ts covering the
gating behavior and the one-shot semantics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 23:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 makes chat.agentHost.enabled take effect immediately at runtime (specifically on a false → true flip), so the local agent host process and related chat/sessions integrations can be enabled without requiring an application restart.

Changes:

  • Adds one-shot onDidChangeConfiguration listeners in the main process, renderer agent host service, and both chat/sessions contributions to perform deferred initialization on false → true.
  • Refactors the two workbench contributions to move their gated setup into a dedicated _enable() method.
  • Adds unit tests to verify initial gating behavior and one-shot enable semantics.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Adds unit tests validating dynamic enable gating and one-shot behavior.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts Enables late initialization via a one-shot config-change listener and _enable() extraction.
src/vs/sessions/contrib/agentHost/browser/localAgentHost.contribution.ts Mirrors the one-shot runtime enable pattern for Sessions app provider registration.
src/vs/platform/agentHost/electron-browser/agentHostService.ts Defers _connect() until the setting flips on, using a one-shot listener.
src/vs/code/electron-main/app.ts Defers spawning the agent host utility process until the setting flips on, using a one-shot listener.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 641cbea2 Current: dd00976b

Changed (1)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after

Replace the previous approach (one-shot config listeners in 4 files) with a
single entry in SettingsChangeRelauncher.SETTINGS. Toggling the setting now
shows the standard 'restart required' dialog, which is simpler and avoids
races between renderer and main process setup.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens marked this pull request as ready for review April 21, 2026 01:45
@roblourens roblourens enabled auto-merge (squash) April 21, 2026 01:45
@roblourens roblourens changed the title Spawn agent host immediately when chat.agentHost.enabled flips on Prompt restart for chat.agentHost.enabled setting Apr 21, 2026
@roblourens roblourens merged commit b2d3ae7 into main Apr 21, 2026
40 of 41 checks passed
@roblourens roblourens deleted the roblou/agents/agent-host-instant-spawn branch April 21, 2026 02:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 21, 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