Repository navigation
add enable/disable ai features actions - #308988
Conversation
Sandeep Somavarapu (sandy081)
commented
Apr 10, 2026
- add enable/disable ai features actions
- disable ai features when extension is disabled at workspace level
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Benjamin Pasero (@bpasero)Matched files:
TylerLeonhardtMatched files:
Johannes Rieken (@jrieken)Matched files:
Ladislau Szomoru (@lszomoru)Matched files:
|
There was a problem hiding this comment.
Pull request overview
This PR adds workspace-level “AI disabled” state to Chat entitlement context and wires it through various UI entry points, and introduces new extension actions intended to enable/disable AI features (especially for the default chat extension).
Changes:
- Add a new context key/state (
chatSetupDisabledInWorkspace) to represent Chat being disabled at workspace scope. - Gate Chat- and agent-related UI contributions (Getting Started, SCM suggestions, MCP views/commands, inline chat, help actions, etc.) on the new workspace-disabled state.
- Add new Extensions UI actions to enable/disable AI features globally and per-workspace, and adjust migration behavior when the built-in chat extension is disabled.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts | Migration logic relating chat extension disablement to chat.disableAIFeatures. |
| src/vs/workbench/services/chat/common/chatEntitlementService.ts | Introduces disabledInWorkspace sentiment/context key and propagates it via ChatEntitlementContext. |
| src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.ts | Hides Copilot “getting started” entry points when disabled in workspace. |
| src/vs/workbench/contrib/scm/browser/scmInput.ts | Disables SCM Chat setup suggestion when disabled in workspace. |
| src/vs/workbench/contrib/scm/browser/scm.contribution.ts | Disables SCM merge-conflict Chat affordances when disabled in workspace. |
| src/vs/workbench/contrib/mcp/browser/mcpServersView.ts | Hides MCP views when Chat is disabled in workspace. |
| src/vs/workbench/contrib/mcp/browser/mcpCommands.ts | Adds workspace-disabled gating to MCP command preconditions/menus. |
| src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts | Gates inline-chat action on workspace-disabled state. |
| src/vs/workbench/contrib/extensions/browser/extensionsActions.ts | Adds “Enable/Disable AI Features” actions and customizes chat extension enablement actions. |
| src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts | Gates “Open Agents Application” action when disabled in workspace. |
| src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.ts | Avoids registering chat/AI providers and actions when disabled in workspace; sets disabledInWorkspace from extension enablement state. |
| src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.ts | Updates Chat view visibility conditions to respect workspace-disabled state. |
| src/vs/workbench/contrib/chat/browser/agentPluginsView.ts | Gates agent plugin browsing commands/menus when disabled in workspace. |
| src/vs/workbench/contrib/chat/browser/actions/createPluginAction.ts | Gates plugin creation action when disabled in workspace. |
| src/vs/workbench/contrib/chat/browser/actions/chatPluginActions.ts | Gates plugin marketplace actions when disabled in workspace. |
| src/vs/workbench/contrib/chat/browser/actions/chatActions.ts | Gates chat-opening and editor context submenu when disabled in workspace. |
| src/vs/workbench/contrib/authentication/browser/actions/manageTrustedMcpServersForAccountAction.ts | Gates MCP-trust management action when disabled in workspace. |
| src/vs/workbench/browser/parts/editor/editorGroupWatermark.ts | Hides “Open Chat” watermark entry when disabled in workspace. |
| src/vs/workbench/browser/actions/helpActions.ts | Hides “Ask Victor Salazar (@VScode)” when disabled in workspace. |
Copilot's findings
Comments suppressed due to low confidence (2)
src/vs/workbench/services/chat/common/chatEntitlementService.ts:528
disabledInWorkspaceis now part ofsentiment, butonDidChangeSentimentis still only wired to the previous set of context keys. As a result, toggling the workspace-disabled state can leavesentimentObs/UI consumers stale. IncludeChatEntitlementContextKeys.Setup.disabledInWorkspace.keyin theaffectsSome(...)set used to raiseonDidChangeSentiment.
get sentiment(): IChatSentiment {
return {
completed: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.completed.key) === true,
installed: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.installed.key) === true,
hidden: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.hidden.key) === true,
disabledInWorkspace: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.disabledInWorkspace.key) === true,
disabled: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.disabled.key) === true,
untrusted: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.untrusted.key) === true,
later: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.later.key) === true,
registered: this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.Setup.registered.key) === true
src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts:156
- The migration sets
chat.disableAIFeatures=truewhen the builtin chat extension is disabled globally, but it does not re-enable the extension. Combined with the new Extensions UI behavior that hides regular enable/disable actions for the chat extension, this risks leaving users with a globally-disabled chat extension and no obvious way to re-enable it. Consider also enabling the chat extension here (so the setting becomes the source of truth), or ensure the UI still exposes an enable-extension action for this scenario.
const context = (chatEntitlementService as ChatEntitlementService).context;
if (context) {
if (context.value.state.completed) {
// User has used chat features before
if (this._isDisabledGlobally({ id: this._chatExtensionId })) {
// User had specifically disabled the chat extension to disable AI features
if (this.configurationService.getValue('chat.disableAIFeatures') !== true) {
// Honor that choice by disabling AI features
this.logService.debug('Disabling AI features because builtin chat extension is disabled');
this.configurationService.updateValue('chat.disableAIFeatures', true)
.catch(err => this.logService.error('Failed to update chat.disableAIFeatures setting during builtin chat extension enablement migration', err));
}
- Files reviewed: 19/19 changed files
- Comments generated: 3
| class EnableAIFeaturesGloballyAction extends ExtensionAction { | ||
|
|
||
| static readonly ID = 'extensions.enableAIGlobally'; | ||
| static readonly LABEL = localize('enableAIGloballyAction', "Enable AI Features"); | ||
|
|
||
| constructor( | ||
| @IProductService private readonly productService: IProductService, | ||
| @IConfigurationService private readonly configurationService: IConfigurationService, | ||
| ) { | ||
| super(EnableAIFeaturesGloballyAction.ID, EnableAIFeaturesGloballyAction.LABEL, ExtensionAction.LABEL_ACTION_CLASS); | ||
| this.tooltip = localize('enableAIGloballyActionToolTip', "Enable AI features"); | ||
| this.update(); | ||
| } | ||
|
|
||
| update(): void { | ||
| this.enabled = false; | ||
| if (this.extension && ExtensionIdentifier.equals(this.extension.identifier.id, this.productService.defaultChatAgent?.chatExtensionId)) { | ||
| this.enabled = this.configurationService.getValue<boolean>(CHAT_AI_DISABLED_SETTING) === true | ||
| && this.extension.enablementState !== EnablementState.DisabledWorkspace; | ||
| } | ||
| } | ||
|
|
||
| override async run(): Promise<void> { | ||
| await this.configurationService.updateValue(CHAT_AI_DISABLED_SETTING, false); | ||
| } | ||
| } | ||
|
|
||
| class EnableAIFeaturesInWorkspaceAction extends ExtensionAction { | ||
|
|
||
| static readonly ID = 'extensions.enableAIInWorkspace'; | ||
| static readonly LABEL = localize('enableAIInWorkspaceAction', "Enable AI Features (Workspace)"); | ||
|
|
||
| constructor( | ||
| @IProductService private readonly productService: IProductService, | ||
| @IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService, | ||
| ) { | ||
| super(EnableAIFeaturesInWorkspaceAction.ID, EnableAIFeaturesInWorkspaceAction.LABEL, ExtensionAction.LABEL_ACTION_CLASS); | ||
| this.tooltip = localize('enableAIInWorkspaceActionToolTip', "Enable AI features in this workspace"); | ||
| this.update(); | ||
| } | ||
|
|
||
| update(): void { | ||
| this.enabled = false; | ||
| if (this.extension && this.extension.local && ExtensionIdentifier.equals(this.extension.identifier.id, this.productService.defaultChatAgent?.chatExtensionId)) { | ||
| this.enabled = this.extension.enablementState === EnablementState.DisabledWorkspace; | ||
| } | ||
| } | ||
|
|
||
| override async run(): Promise<void> { | ||
| if (!this.extension) { | ||
| return; | ||
| } | ||
| return this.extensionsWorkbenchService.setEnablement(this.extension, EnablementState.EnabledWorkspace); | ||
| } | ||
| } | ||
|
|
||
| class DisableAIFeaturesGloballyAction extends ExtensionAction { | ||
|
|
||
| static readonly ID = 'extensions.disableAIGlobally'; | ||
| static readonly LABEL = localize('disableAIGloballyAction', "Disable AI Features"); | ||
|
|
||
| constructor( | ||
| @IProductService private readonly productService: IProductService, | ||
| @IConfigurationService private readonly configurationService: IConfigurationService, | ||
| ) { | ||
| super(DisableAIFeaturesGloballyAction.ID, DisableAIFeaturesGloballyAction.LABEL, ExtensionAction.LABEL_ACTION_CLASS); | ||
| this.tooltip = localize('disableAIGloballyActionToolTip', "Disable AI features"); | ||
| this.update(); | ||
| } | ||
|
|
||
| update(): void { | ||
| this.enabled = false; | ||
| if (this.extension && ExtensionIdentifier.equals(this.extension.identifier.id, this.productService.defaultChatAgent?.chatExtensionId)) { | ||
| this.enabled = this.extension.state === ExtensionState.Installed | ||
| && this.configurationService.getValue<boolean>(CHAT_AI_DISABLED_SETTING) !== true | ||
| && this.extension.enablementState !== EnablementState.DisabledWorkspace; | ||
| } | ||
| } | ||
|
|
||
| override async run(): Promise<void> { | ||
| await this.configurationService.updateValue(CHAT_AI_DISABLED_SETTING, true); | ||
| } | ||
| } |
There was a problem hiding this comment.
EnableAIFeaturesGloballyAction / DisableAIFeaturesGloballyAction derive their enabled/hidden state from chat.disableAIFeatures but never listen for configuration changes. If the setting is changed via Settings UI or by another action, these actions can remain stale until some unrelated refresh. Register a configurationService.onDidChangeConfiguration listener (filtering on chat.disableAIFeatures) to call update().
There was a problem hiding this comment.
Sandeep Somavarapu (@sandy081) did you see this?