@@ -377,6 +377,73 @@ suite('RunInTerminalTool', () => {
377
377
strictEqual ( customActions [ 2 ] . data . type , 'configure' ) ;
378
378
} ) ;
379
379
380
+ test ( 'should not show approved commands in custom actions dropdown' , async ( ) => {
381
+ setAutoApprove ( {
382
+ head : true // head is approved by default in real scenario
383
+ } ) ;
384
+
385
+ const result = await executeToolTest ( {
386
+ command : 'foo | head -20' ,
387
+ explanation : 'Run foo command and show first 20 lines'
388
+ } ) ;
389
+
390
+ assertConfirmationRequired ( result , 'Run command in terminal' ) ;
391
+ ok ( result ! . confirmationMessages ! . terminalCustomActions , 'Expected custom actions to be defined' ) ;
392
+
393
+ const customActions = result ! . confirmationMessages ! . terminalCustomActions ! ;
394
+ strictEqual ( customActions . length , 3 , 'Expected 3 custom actions' ) ;
395
+
396
+ strictEqual ( customActions [ 0 ] . label , 'Always Allow Command: foo' , 'Should only show \'foo\' since \'head\' is auto-approved' ) ;
397
+ strictEqual ( customActions [ 0 ] . data . type , 'newRule' ) ;
398
+
399
+ strictEqual ( customActions [ 1 ] . label , 'Always Allow Full Command Line: foo | head -20' ) ;
400
+ strictEqual ( customActions [ 1 ] . data . type , 'newRule' ) ;
401
+
402
+ strictEqual ( customActions [ 2 ] . label , 'Configure Auto Approve...' ) ;
403
+ strictEqual ( customActions [ 2 ] . data . type , 'configure' ) ;
404
+ } ) ;
405
+
406
+ test ( 'should not show any command-specific actions when all sub-commands are approved' , async ( ) => {
407
+ setAutoApprove ( {
408
+ foo : true ,
409
+ head : true
410
+ } ) ;
411
+
412
+ const result = await executeToolTest ( {
413
+ command : 'foo | head -20' ,
414
+ explanation : 'Run foo command and show first 20 lines'
415
+ } ) ;
416
+
417
+ assertAutoApproved ( result ) ;
418
+ } ) ;
419
+
420
+ test ( 'should handle mixed approved and unapproved commands correctly' , async ( ) => {
421
+ setAutoApprove ( {
422
+ head : true ,
423
+ tail : true
424
+ } ) ;
425
+
426
+ const result = await executeToolTest ( {
427
+ command : 'foo | head -20 && bar | tail -10' ,
428
+ explanation : 'Run multiple piped commands'
429
+ } ) ;
430
+
431
+ assertConfirmationRequired ( result , 'Run command in terminal' ) ;
432
+ ok ( result ! . confirmationMessages ! . terminalCustomActions , 'Expected custom actions to be defined' ) ;
433
+
434
+ const customActions = result ! . confirmationMessages ! . terminalCustomActions ! ;
435
+ strictEqual ( customActions . length , 3 , 'Expected 3 custom actions' ) ;
436
+
437
+ strictEqual ( customActions [ 0 ] . label , 'Always Allow Commands: foo, bar' , 'Should only show \'foo, bar\' since \'head\' and \'tail\' are auto-approved' ) ;
438
+ strictEqual ( customActions [ 0 ] . data . type , 'newRule' ) ;
439
+
440
+ strictEqual ( customActions [ 1 ] . label , 'Always Allow Full Command Line: foo | head -20 &&& bar | tail -10' ) ;
441
+ strictEqual ( customActions [ 1 ] . data . type , 'newRule' ) ;
442
+
443
+ strictEqual ( customActions [ 2 ] . label , 'Configure Auto Approve...' ) ;
444
+ strictEqual ( customActions [ 2 ] . data . type , 'configure' ) ;
445
+ } ) ;
446
+
380
447
} ) ;
381
448
382
449
suite ( 'command re-writing' , ( ) => {
0 commit comments