agentHost: move IAgentHostEnablementService to platform layer and make setting private - #325008
Conversation
…e setting private
- Moves IAgentHostEnablementService interface and implementation from
sessions/ to platform/agentHost/common and platform/agentHost/browser
- Merges the two agentHost config contribution files into the service
files, making AgentHostEnabledSettingId an unexported module-private
constant (only the service reads the config value at runtime)
- Removes the isAgentHostEnabled() helper from agentService.ts
- Adds AGENT_HOST_ENABLED_CONTEXT_KEY (RawContextKey) set eagerly by
the service, replacing ad-hoc ContextKeyExpr.equals('config.xxx')
expressions in when clauses
- All consumers (localAgentHostService, editorRemoteAgentHostServiceClient,
workbench contributions, sessions providers) now inject and use
IAgentHostEnablementService instead of reading the config directly
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ion tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks #325001 onto release/1.128. It relocates IAgentHostEnablementService from the sessions layer (vs/sessions/services/agentHost/common) to the platform layer (vs/platform/agentHost/common) so workbench, sessions, and platform consumers can all inject it, and it makes the chat.agentHost.enabled setting ID private — the setting is now read only through the service (fixed at startup), and when-clause consumers switch from the ad-hoc config.chat.agentHost.enabled expression to a proper AGENT_HOST_ENABLED_CONTEXT_KEY. A 1.128-specific compatibility shim re-exports the prompt contribution under its old CLI-settings name.
Changes:
- New platform-layer service (
commoninterface + config/context-key registration,browserimplementation registeredEager, applying the policy upgrade and setting the context key). - Removed
AgentHostEnabledSettingId/isAgentHostEnabledfromagentService.ts; consumers now inject the service or useAGENT_HOST_ENABLED_CONTEXT_KEY; runtime config-change listeners dropped (enablement fixed at startup). - Deleted the old sessions service and
agentHost.config.contribution.ts(common + browser); tests updated to stub the service directly.
Show a summary per file
| File | Description |
|---|---|
platform/agentHost/common/agentHostEnablementService.ts |
New: interface, private setting ID, AGENT_HOST_ENABLED_CONTEXT_KEY, config registration |
platform/agentHost/browser/agentHostEnablementService.ts |
New: impl (Eager), policy upgrade, sets context key |
platform/agentHost/common/agentService.ts |
Removed AgentHostEnabledSettingId, isAgentHostEnabled, unused isWeb import |
platform/agentHost/browser/agentHost.config.contribution.ts |
Deleted (merged into new service) |
platform/agentHost/electron-main/electronAgentHostStarter.ts |
Import points to new service file |
platform/agentHost/electron-browser/localAgentHostService.ts |
Injects service, uses enabled |
workbench/.../editorRemoteAgentHostServiceClient.ts |
Injects service; log text hard-codes setting name |
workbench/.../agentHostChatContribution.ts |
Uses service; keeps configurationService for later use |
workbench/.../agentHostTerminalContribution.ts / agentHostCopilotPromptContribution.ts |
Use service; removed config-change listeners |
workbench/.../agentHostSessionListContribution.ts |
Injects service, uses enabled |
workbench/.../agentHostCopilotCliSettingsContribution.ts |
Now a re-export shim (1.128 compat) |
workbench/.../actions/{profile,debug,exportAgentHostDebugLogs}Action.ts |
Use AGENT_HOST_ENABLED_CONTEXT_KEY |
workbench/.../chat.shared.contribution.ts |
Import new service files; description text updated |
workbench/workbench.desktop.main.ts / workbench.web.main.ts |
Register the platform service |
sessions/sessions.common.main.ts |
Register the platform service |
sessions/services/agentHost/browser/agentHostEnablementService.ts |
Deleted (moved to platform) |
sessions/contrib/.../sessionsViewActions.ts, exportDebugLogsAction.ts, localAgentHost.contribution.ts, providers |
Use context key / new import path / updated descriptions |
*.test.ts (chat, sessions providers) |
Stub IAgentHostEnablementService.enabled directly |
Review details
Comments suppressed due to low confidence (1)
src/vs/platform/agentHost/common/agentHostEnablementService.ts:51
- This
nls.localizecall still passesagentHostEnabledSettingIdas a format argument, but the message no longer contains a{0}placeholder (it was replaced with the hard-coded`#chat.agentHost.enabled#`). The trailing argument is now dead and inconsistent with the two other identical refactors in this PR, which correctly dropped the argument (seechat.shared.contribution.tsforchat.agents.claude.preferAgentHostandlocalAgentHost.contribution.tsforsessions.chat.agentHost.defaultSessionsProvider). Remove the unused argument.
- Files reviewed: 30/30 changed files
- Comments generated: 0
- Review effort level: Medium
…ration in agents window - SessionsDefaultConfiguration now extends the workbench DefaultConfiguration (with caching) instead of the base platform one, so experiment-driven default overrides for settings like chat.agentHost.enabled are persisted to disk and read back immediately on subsequent startups - same as the editor window - Pass IConfigurationCache and IBrowserWorkbenchEnvironmentService through to the ConfigurationService constructor in both desktop and web sessions mains - hasCachedConfigurationDefaultsOverrides() now delegates to defaultConfiguration instead of hardcoding false - reloadConfiguration() now always reloads defaults first via a new reloadDefaultConfiguration() helper; when called with ConfigurationTarget.DEFAULT it returns after that, matching the editor window's behaviour Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cherry-pick of #325001 onto
release/1.128.Summary
Moves
IAgentHostEnablementServicefrom the sessions layer to the platform layer so all consumers can use it. Makes thechat.agentHost.enabledsetting ID private/internal — only the service reads it at runtime.See the main PR (#325001) for full details.
1.128-specific notes
agentHostCopilotCliSettingsContribution.tswas added as a compatibility shim sincerelease/1.128does not yet haveAgentHostRootConfigForwarderorcopilotCliConfigagentHostCopilotPromptContribution.test.ts(1.128 name) updated instead ofagentHostCopilotCliSettingsContribution.test.ts