Repository navigation
Fix account policy enforcement in the Agents window - #336968
Merged
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation consistently enforces policy state and includes focused regression coverage for startup races, UI visibility, and direct commands.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes account-policy enforcement across the Agents window and related launch surfaces.
Changes:
- Corrects configuration and policy initialization ordering.
- Reactively hides Agents banners when agent mode is unavailable.
- Blocks direct Agents window launch commands and adds regression coverage.
| File | Description |
|---|---|
src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts |
Makes the Welcome banner policy-aware. |
src/vs/workbench/contrib/welcomeAgentSessions/browser/agentSessionsWelcome.ts |
Makes the sessions invitation policy-aware. |
src/vs/workbench/contrib/chat/test/electron-browser/agentSessionsActions.test.ts |
Tests launch-command enforcement. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentSessionsBanner.test.ts |
Tests reactive banner visibility. |
src/vs/workbench/contrib/chat/electron-browser/agentSessions/agentSessionsActions.ts |
Rejects launches when agent mode is disabled. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsBanner.ts |
Reactively applies entitlement and configuration visibility. |
src/vs/sessions/services/configuration/test/browser/configurationService.test.ts |
Covers policy initialization and update races. |
src/vs/sessions/services/configuration/browser/configurationService.ts |
Initializes defaults first and preserves current policy state. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <[email protected]>
Ross Wollman (rwoll)
marked this pull request as ready for review
September 21, 2026 05:03
Ross Wollman (rwoll)
enabled auto-merge
September 21, 2026 05:03
Co-authored-by: Copilot App <[email protected]>
Contributor
Giuseppe Cianci (Giuspepe)
approved these changes
Sep 21, 2026
This was referenced Sep 21, 2026
| const result = startAccountPolicyInitialization(policyData); | ||
| await result.initialization; | ||
| return result; | ||
| } |
| await result.initialization; | ||
| return result; | ||
| } | ||
|
|
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { $, addDisposableListener } from '../../../../../base/browser/dom.js'; | ||
| import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js'; |
There was a problem hiding this comment.
Suggested change
| import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js'; | |
| import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Initialize configuration defaults before registering policies so the Agents window applies account restrictions correctly, and preserve policy updates received while configuration files load. Hide the Welcome invitation and reject direct launch commands when Agent mode is disabled.
Before the change, the "Try out the new Agents Window" showed up on the Editor Welcome even though Agents were disabled by token policy:

Now, the "Try…" no longer shows and even if the user circumvents it (e.g. using
code --agents …to launch the Agents Window directly), policy is properly applied so it shows the disabled state:Repro
scripts/mock-policy-server, mock/copilot_internal/v2/tokenwith{"token":"agent_mode=0;editor_preview_features=0;mcp=0"}and route that endpoint through the proxy. Leave other endpoints on passthrough.chat.agent.enabledoverride and run Developer: Sync Account Policy.Before: the invitation remains and opens an unblocked Agents window, although both windows receive
chat_agent_enabled: false.After: the invitation is hidden, and an Agents window opened directly with
--agentsshows Agents Disabled. Verified with mocked account policy; successful model execution was not tested with the synthetic token.Validation
Client build and lint pass; 191 focused tests pass, including startup policy changes and existing draft handoff coverage.
Fixes https://github.com/microsoft/vscode-internalbacklog/issues/9102.