Skip to content

Commit 087a87f

Browse files
authored
terminal: use display command in approval actions (#308916)
terminal: use display command in approval actions (#308895) Use the display form of the command when computing terminal approval actions so wrapped unsandboxed commands do not leak into confirmation labels. Also update the runInTerminalTool regression test to assert the display command label.
1 parent 23f8300 commit 087a87f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
725725
// Determine auto approval, this happens even when auto approve is off to that reasoning
726726
// can be reviewed in the terminal channel. It also allows gauging the effective set of
727727
// commands that would be auto approved if it were enabled.
728-
const commandLine = rewrittenCommand ?? args.command;
728+
const commandLine = forDisplayCommand ?? rewrittenCommand ?? args.command;
729729

730730
const isEligibleForAutoApproval = () => isToolEligibleForTerminalAutoApproval(TOOL_REFERENCE_NAME, this._configurationService, LEGACY_TOOL_REFERENCE_FULL_NAMES);
731731
const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;

src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ suite('RunInTerminalTool', () => {
698698
ok(actions, 'Expected custom actions to be defined');
699699
strictEqual(actions.length, 11);
700700
ok(!isSeparator(actions[0]));
701-
strictEqual(actions[0].label, 'Allow `unsandboxed:echo …` in this Session');
701+
strictEqual(actions[0].label, 'Allow `echo …` in this Session');
702702
ok(!isSeparator(actions[4]));
703703
strictEqual(actions[4].label, 'Allow Exact Command Line in this Session');
704704
ok(!isSeparator(actions[10]));

0 commit comments

Comments
 (0)