Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class ChatTerminalToolConfirmationSubPart extends BaseChatToolInvocationS
const cancelKeybinding = keybindingService.lookupKeybinding(CancelChatActionId)?.getLabel();
const cancelTooltip = cancelKeybinding ? `${cancelLabel} (${cancelKeybinding})` : cancelLabel;

const autoApproveEnabled = this.configurationService.getValue(TerminalContribSettingId.EnableAutoApprove) === 'on';
const autoApproveEnabled = this.configurationService.getValue(TerminalContribSettingId.EnableAutoApprove) === true;
const autoApproveWarningAccepted = this.storageService.getBoolean(TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted, StorageScope.APPLICATION, false);
let moreActions: (IChatConfirmationButton<TerminalNewAutoApproveButtonData> | Separator)[] | undefined = undefined;
if (autoApproveEnabled) {
Expand Down
20 changes: 2 additions & 18 deletions src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,24 +652,8 @@ export async function registerTerminalConfiguration(getFontSnippets: () => Promi
// extraction as it doesn't compute runtime values.
[TerminalContribSettingId.EnableAutoApprove]: {
description: localize('autoApproveMode.description', "Controls whether to allow auto approval in the run in terminal tool."),
type: 'string',
enum: [
'off',
'on',
// 'onWithoutDefaultRules',
],
enumDescriptions: [
localize('enableAutoApprove.off', "Terminal auto approval is disabled."),
localize('enableAutoApprove.on', "Terminal auto approval is enabled, with the default rules defined in {0}.", `\`${TerminalContribSettingId.AutoApprove}\``),
// localize('enableAutoApprove.onWithoutDefaultRules', "Terminal auto approval is enabled, without the default rules defined in {0}.", `\`${TerminalContribSettingId.AutoApprove}\``),
],
markdownEnumDescriptions: [
localize('enableAutoApprove.off', "Terminal auto approval is disabled."),
localize('enableAutoApprove.on', "Terminal auto approval is enabled, with the default rules defined in {0}.", `\`#${TerminalContribSettingId.AutoApprove}#\``),
// localize('enableAutoApprove.onWithoutDefaultRules', "Terminal auto approval is enabled, without the default rules defined in {0}.", `\`#${TerminalContribSettingId.AutoApprove}#\``),
],
default: 'on',
// TODO: Move to register call to make tree sitter happy
type: 'boolean',
default: true,
policy: {
name: 'ChatToolsTerminalEnableAutoApprove',
minimumVersion: '1.104',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
// Clear out warning accepted state if the setting is disabled
this._register(Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {
if (!e || e.affectsConfiguration(TerminalChatAgentToolsSettingId.EnableAutoApprove)) {
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) !== 'on') {
if (this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) !== true) {
this._storageService.remove(TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted, StorageScope.APPLICATION);
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
}

// Apply auto approval or force it off depending on enablement/opt-in state
const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === 'on';
const isAutoApproveEnabled = this._configurationService.getValue(TerminalChatAgentToolsSettingId.EnableAutoApprove) === true;
const isAutoApproveWarningAccepted = this._storageService.getBoolean(TerminalToolConfirmationStorageKeys.TerminalAutoApproveWarningAccepted, StorageScope.APPLICATION, false);
const isAutoApproveAllowed = isAutoApproveEnabled && isAutoApproveWarningAccepted;
if (isAutoApproveEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ suite('RunInTerminalTool', () => {

setup(() => {
configurationService = new TestConfigurationService();
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, 'on');
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, true);
terminalServiceDisposeEmitter = new Emitter<ITerminalInstance>();
chatServiceDisposeEmitter = new Emitter<{ sessionId: string; reason: 'cleared' }>();

Expand Down Expand Up @@ -975,7 +975,7 @@ suite('RunInTerminalTool', () => {

suite('auto approve warning acceptance mechanism', () => {
test('should require confirmation for auto-approvable commands when warning not accepted', async () => {
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, 'on');
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, true);
setAutoApprove({
echo: true
});
Expand All @@ -986,7 +986,7 @@ suite('RunInTerminalTool', () => {
});

test('should auto-approve commands when both auto-approve enabled and warning accepted', async () => {
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, 'on');
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, true);
setAutoApprove({
echo: true
});
Expand All @@ -995,7 +995,7 @@ suite('RunInTerminalTool', () => {
});

test('should require confirmation when auto-approve disabled regardless of warning acceptance', async () => {
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, 'off');
setConfig(TerminalChatAgentToolsSettingId.EnableAutoApprove, false);
setAutoApprove({
echo: true
});
Expand Down
Loading