Skip to content

Commit e01944b

Browse files
committed
Add reasons to Terminal log
1 parent 0e210df commit e01944b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,33 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
172172
const inlineSubCommands = subCommands.map(e => Array.from(extractInlineSubCommands(e, shell, os))).flat();
173173
const allSubCommands = [...subCommands, ...inlineSubCommands];
174174
const subCommandResults = allSubCommands.map(e => this._commandLineAutoApprover.isCommandAutoApproved(e, shell, os));
175+
const autoApproveReasons: string[] = [...subCommandResults.map(e => e.reason)];
176+
175177
if (subCommandResults.every(e => e.isAutoApproved)) {
178+
this._logService.info('autoApprove: All sub-commands auto-approved');
176179
confirmationMessages = undefined;
177180
} else {
181+
this._logService.info('autoApprove: All sub-commands NOT auto-approved');
178182
const commandLineResults = this._commandLineAutoApprover.isCommandLineAutoApproved(args.command);
183+
autoApproveReasons.push(commandLineResults.reason);
179184
if (commandLineResults.isAutoApproved) {
185+
this._logService.info('autoApprove: Command line auto-approved');
180186
confirmationMessages = undefined;
181187
} else {
182-
// TODO: Surface reason in UI
188+
this._logService.info('autoApprove: Command line NOT auto-approved');
183189
confirmationMessages = {
184190
title: args.isBackground
185191
? localize('runInTerminal.background', "Run command in background terminal")
186192
: localize('runInTerminal.foreground', "Run command in terminal"),
187-
message: new MarkdownString(
188-
args.explanation
189-
),
193+
message: new MarkdownString(args.explanation),
190194
};
191195
}
192196
}
197+
198+
// TODO: Surface reason on tool part https://github.com/microsoft/vscode/pull/256793
199+
for (const reason of autoApproveReasons) {
200+
this._logService.info(`- ${reason}`);
201+
}
193202
}
194203

195204
const instance = context.chatSessionId ? this._sessionTerminalAssociations.get(context.chatSessionId)?.instance : undefined;

src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const terminalChatAgentToolsConfiguration: IStringDictionary<IConfigurati
3535
localize('autoApprove.description.intro', "A list of commands or regular expressions that control whether the run in terminal tool commands require explicit approval. These will be matched against the start of a command. A regular expression can be provided by wrapping the string in {0} characters followed by optional flags such as {1} for case-insensitivity.", '`/`', '`i`'),
3636
localize('autoApprove.description.values', "Set to {0} to automatically approve commands, {1} to always require explicit approval or {2} to unset the value.", '`true`', '`false`', '`null`'),
3737
localize('autoApprove.description.subCommands', "Note that these commands and regular expressions are evaluated for every _sub-command_ within the full _command line_, so {0} for example will need both {1} and {2} to match a {3} entry and must not match a {4} entry in order to auto approve. Inline commands are also detected so {5} will need both {5} and {6} to pass.", '`foo && bar`', '`foo`', '`bar`', '`true`', '`false`', '`echo $(rm file)`', '`rm file`'),
38-
localize('autoApprove.description.commandLine', "An object can be used to match against the full command line instead of matching sub-commands and inline commands, for example {0}. This will be checked _after_ sub-commands are checked, so denied sub-commands will take precedence.", '`{ approve: false, matchCommandLine: true }`'),
38+
localize('autoApprove.description.commandLine', "An object can be used to match against the full command line instead of matching sub-commands and inline commands, for example {0}. This will be checked _after_ sub-commands are checked, taking precedence over even denied sub-commands.", '`{ approve: false, matchCommandLine: true }`'),
3939
[
4040
localize('autoApprove.description.examples.title', 'Examples:'),
4141
`|${localize('autoApprove.description.examples.value', "Value")}|${localize('autoApprove.description.examples.description', "Description")}|`,

0 commit comments

Comments
 (0)