Skip to content

Skip chat extension enablement change when locked by environment#315453

Open
dmitrivMS wants to merge 2 commits into
mainfrom
dev/dmitriv/unhandled-enablement-error
Open

Skip chat extension enablement change when locked by environment#315453
dmitrivMS wants to merge 2 commits into
mainfrom
dev/dmitriv/unhandled-enablement-error

Conversation

@dmitrivMS
Copy link
Copy Markdown
Contributor

@dmitrivMS dmitrivMS commented May 9, 2026

Fixes #312381

When chat.disableAIFeatures is true and the GitHub Copilot Chat extension is in a non-changeable enablement state (e.g. DisabledByExtensionKind, DisabledByVirtualWorkspace, DisabledByAllowlist), ChatTeardownContribution.maybeEnableOrDisableExtension calls setEnablement, which throws an unhandled error.

Guard with canChangeEnablement / canChangeWorkspaceEnablement before calling setEnablement. If the enablement is locked by the environment, bail out early.

Repro Steps

  1. Open WSL, start "code-insiders --transient"
  2. Connect to WSL (install extension, wait for it to finish connecting)
  3. Set "chat.disableAIFeatures": true in user settings
  4. Open dev tools -> console
  5. Reload window

Actual
Error in console:
ERR Cannot change enablement of GitHub Copilot Chat extension because of its extension kind: Error: Cannot change enablement of GitHub Copilot Chat extension because of its extension kind
at $tt.throwErrorIfEnablementStateCannotBeChanged (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:19861)
at $tt.throwErrorIfCannotChangeEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:19479)
at $tt.setEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:1827:20777)
at async o9.doSetEnablement (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:3650:55631)
at async Nve.maybeEnableOrDisableExtension (vscode-file://vscode-app/c:/Users/dmitriv/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/3b8129f1d0/resources/app/out/vs/workbench/workbench.desktop.main.js:3304:48432)

Expected
No error.

When chat.disableAIFeatures is true and the chat extension is in a non-changeable enablement state (DisabledByExtensionKind, DisabledByVirtualWorkspace, DisabledByAllowlist, etc.), ChatTeardownContribution.maybeEnableOrDisableExtension calls setEnablement which throws an unhandled error. Guard with canChangeEnablement / canChangeWorkspaceEnablement before calling.

Fixes #312381
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

Reduces high-volume unhandled errors in the chat teardown path by avoiding enablement changes for the GitHub Copilot Chat extension when its enablement is locked by environment/workspace constraints (e.g. disallowed, extension kind, virtual workspace).

Changes:

  • Early-return from maybeEnableOrDisableExtension when the chat extension isn’t locally available.
  • Guard setEnablement with IWorkbenchExtensionEnablementService.canChangeEnablement / canChangeWorkspaceEnablement to avoid throwing for locked enablement states.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/chatSetup/chatSetupContributions.ts Adds enablement-change guardrails before calling setEnablement to prevent unhandled errors/telemetry noise when enablement is not changeable.

Copilot's findings

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

@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 7c143e99 Current: 69d8c234

Changed (24)

agentSessionsViewer/CompletedRead/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Light
Before After
before after
agentSessionsViewer/CompletedUnread/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Light
Before After
before after
agentSessionsViewer/FailedWithDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithDuration/Light
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Light
Before After
before after
agentSessionsViewer/WithDiffChanges/Dark
Before After
before after
agentSessionsViewer/WithDiffChanges/Light
Before After
before after
agentSessionsViewer/WithFileChangesList/Dark
Before After
before after
agentSessionsViewer/WithFileChangesList/Light
Before After
before after
agentSessionsViewer/WithBadge/Dark
Before After
before after
agentSessionsViewer/WithBadge/Light
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Dark
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Light
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Dark
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Light
Before After
before after
agentSessionsViewer/CloudProvider/Dark
Before After
before after
agentSessionsViewer/CloudProvider/Light
Before After
before after
agentSessionsViewer/BackgroundProvider/Dark
Before After
before after
agentSessionsViewer/BackgroundProvider/Light
Before After
before after
agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

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.

[Error] unhandlederror-Cannot change enablement of GitHub Copilot Chat extension because of its extension ki...

2 participants