Respect chat.tools.terminal.autoApprove for agent host#322774
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds agent-host plumbing to forward and enforce VS Code terminal auto-approve rules (chat.tools.terminal.autoApprove) for shell permission decisions, including support for null, boolean, and { approve, matchCommandLine } rule entries, across both local and remote agent-host clients.
Changes:
- Introduces a new agent-host root config key for forwarded terminal auto-approve rules and implements normalization (including “ignore default rules” behavior).
- Updates shell command auto-approval to consume forwarded rules (with bundled defaults as a compatibility fallback when rules aren’t forwarded).
- Adds/extends tests for rule normalization, remote forwarding behavior, and permission decision outcomes.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/common/agentHostSchema.ts | Adds root-config key + normalization helpers for forwarding effective terminal auto-approve rules. |
| src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts | Forwards terminal auto-approve rules on connect and on relevant configuration changes (remote client). |
| src/vs/platform/agentHost/electron-browser/localAgentHostService.ts | Forwards terminal auto-approve rules on connect and on relevant configuration changes (local client). |
| src/vs/platform/agentHost/node/sessionPermissions.ts | Uses forwarded terminal auto-approve rules during shell permission auto-approval (still gated by enablement setting). |
| src/vs/platform/agentHost/node/commandAutoApprover.ts | Extends rule compilation/matching to support { approve, matchCommandLine } and forwarded rule sets. |
| src/vs/platform/agentHost/test/common/agentHostSchema.test.ts | Adds coverage for terminal auto-approve rule normalization and default-ignoring behavior. |
| src/vs/platform/agentHost/test/electron-browser/remoteAgentHostProtocolClient.test.ts | Adds coverage for forwarding terminal auto-approve rules on connect and when settings change. |
| src/vs/platform/agentHost/test/node/sessionPermissions.test.ts | Adds coverage ensuring forwarded allow/deny rules affect shell permission outcomes as expected. |
| src/vs/platform/agentHost/test/node/commandAutoApprover.test.ts | Adds coverage for forwarded rules including null entries and matchCommandLine behavior. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 1
9e6adc0 to
59d368f
Compare
Contributor
|
Base:
|
alexdima
approved these changes
Jun 25, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves: #322112
Coming from: #322633
Follow-up in future: #322791
chat.tools.terminal.autoApprove.chat.tools.terminal.autoApproveorchat.tools.terminal.ignoreDefaultAutoApproveRuleschanges.null, boolean rules, and{ approve, matchCommandLine }object rules in Agent Host shell approval.chat.tools.terminal.enableAutoApprove=falseas the top-level gate for rule-based shell approval./cc @justschen
Inspirations from:
TerminalChatAgentToolsSettingId.chat.tools.terminal.autoApprovevalue shape, includingnullandmatchCommandLine, comes from the setting schema interminalChatAgentToolsConfiguration.ts.CommandLineAutoApprover.updateConfiguration.chat.tools.terminal.ignoreDefaultAutoApproveRulescomes from_mapAutoApproveConfigToRules.