Auto approve immediately if only warning blocked it - #285751
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a feature to auto-approve terminal commands immediately after the user accepts the auto-approve warning, if the command would have been auto-approved based on existing rules. Previously, users had to accept the warning and then still manually confirm or set up rules for the command.
Key Changes:
- Splits auto-approval logic to distinguish between commands that would be auto-approved by rules vs. commands that are actually auto-approved (accounting for warning acceptance state)
- Passes
autoApproveInfoto confirmation widget even when warning hasn't been accepted yet, enabling immediate approval after warning acceptance - Updates confirmation widget to check for
autoApproveInfopresence to determine whether to auto-approve after warning acceptance
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts |
Refactors auto-approval logic to separate "would be auto-approved" from "is auto-approved", and sets autoApproveInfo for commands that would be auto-approved even if warning not yet accepted |
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.ts |
Changes confirmation widget logic to check autoApproveInfo instead of terminalCustomActions to determine whether to auto-approve after warning acceptance |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts |
Adds test case to verify autoApproveInfo is set for commands that would be auto-approved even when warning hasn't been accepted |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.ts:250
- Missing fallback case when neither autoApproveInfo nor terminalCustomActions are present. If both conditions are false, doComplete remains true but toolConfirmKind stays as ToolConfirmKind.Denied (from line 219), causing the command to be denied. The original logic would auto-approve when there were no custom actions. Consider adding an else clause to handle the case where both autoApproveInfo is falsy and terminalCustomActions is falsy, to either set doComplete to false or set toolConfirmKind appropriately.
if (terminalData.autoApproveInfo) {
toolConfirmKind = ToolConfirmKind.UserAction;
}
// If this would not have been auto approved, enable the options and
// do not complete
else if (terminalCustomActions) {
for (const action of terminalCustomActions) {
if (!(action instanceof Separator)) {
action.disabled = false;
}
}
confirmWidget.updateButtons(this._createButtons(terminalCustomActions));
doComplete = false;
}
Ladislau Szomoru (lszomoru)
approved these changes
Jan 3, 2026
| @@ -232,13 +232,13 @@ export class ChatTerminalToolConfirmationSubPart extends BaseChatToolInvocationS | |||
| const optedIn = await this._showAutoApproveWarning(); | |||
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
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.
Fixes #275312