Skip to content

Commit ef41842

Browse files
authored
Merge pull request microsoft#261233 from microsoft/copilot/fix-261223-2
Fix background terminals not showing auto-approve indicator
2 parents 271305b + e6d752c commit ef41842

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,14 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
450450
} else if (outputAndIdle) {
451451
resultText += `\n\ The command is still running, with output:\n${outputAndIdle.output}`;
452452
}
453+
454+
let toolResultMessage: string | undefined;
455+
if (toolSpecificData.autoApproveInfo) {
456+
toolResultMessage = toolSpecificData.autoApproveInfo.value;
457+
}
458+
453459
return {
460+
toolResultMessage: toolResultMessage ? new MarkdownString(toolResultMessage) : undefined,
454461
content: [{
455462
kind: 'text',
456463
value: resultText,

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ suite('RunInTerminalTool', () => {
197197
assertAutoApproved(result);
198198
});
199199

200+
test('should include auto-approve info for background commands', async () => {
201+
setAutoApprove({
202+
npm: true
203+
});
204+
205+
const result = await executeToolTest({
206+
command: 'npm run watch',
207+
explanation: 'Start watching for file changes',
208+
isBackground: true
209+
});
210+
assertAutoApproved(result);
211+
212+
// Verify that auto-approve information is included
213+
ok(result?.toolSpecificData, 'Expected toolSpecificData to be defined');
214+
const terminalData = result!.toolSpecificData as any;
215+
ok(terminalData.autoApproveInfo, 'Expected autoApproveInfo to be defined for auto-approved background command');
216+
ok(terminalData.autoApproveInfo.value, 'Expected autoApproveInfo to have a value');
217+
ok(terminalData.autoApproveInfo.value.includes('npm'), 'Expected autoApproveInfo to mention the approved rule');
218+
});
219+
200220
test('should handle regex patterns in allow list', async () => {
201221
setAutoApprove({
202222
'/^git (status|log)/': true

0 commit comments

Comments
 (0)