@@ -252,6 +252,10 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
252252 "execute_command" ,
253253 expect . stringContaining ( "CWD_OBJECT_MISUSE" ) ,
254254 )
255+ // User must see the error in the UI (design principle: both must happen).
256+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
257+ expect ( errorSayCalls . length ) . toBe ( 1 )
258+ expect ( errorSayCalls [ 0 ] [ 1 ] ) . toContain ( "CWD_OBJECT_MISUSE" )
255259 } )
256260
257261 it ( "blocks tool_use with NESTED_PARAM_OVERFLOW and pushes guided tool_result" , async ( ) => {
@@ -286,6 +290,10 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
286290 "read_file" ,
287291 expect . stringContaining ( "NESTED_PARAM_OVERFLOW" ) ,
288292 )
293+ // User must see the error in the UI (design principle: both must happen).
294+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
295+ expect ( errorSayCalls . length ) . toBe ( 1 )
296+ expect ( errorSayCalls [ 0 ] [ 1 ] ) . toContain ( "NESTED_PARAM_OVERFLOW" )
289297 } )
290298
291299 it ( "escalates to STRUCTURAL_MISUSE_REPEAT on second identical misuse" , async ( ) => {
@@ -402,6 +410,9 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
402410 expect . stringContaining ( "missing nativeArgs" ) ,
403411 )
404412 expect ( mockTask . didAlreadyUseTool ) . toBe ( false )
413+ // User must see the error in the UI (design principle: both must happen).
414+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
415+ expect ( errorSayCalls . length ) . toBe ( 1 )
405416 } )
406417 } )
407418
@@ -500,6 +511,7 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
500511 id : toolCallId ,
501512 name : "read_file" ,
502513 params : { path : "x.txt" } ,
514+ nativeArgs : { path : "x.txt" } ,
503515 partial : false ,
504516 } ,
505517 ]
@@ -513,6 +525,10 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
513525 expect ( toolResult . is_error ) . toBe ( true )
514526 expect ( mockTask . consecutiveMistakeCount ) . toBe ( 1 )
515527 expect ( mockTask . didAlreadyUseTool ) . toBe ( false )
528+ // User must see the error in the UI (design principle: both must happen).
529+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
530+ expect ( errorSayCalls . length ) . toBe ( 1 )
531+ expect ( errorSayCalls [ 0 ] [ 1 ] ) . toContain ( "not allowed in" )
516532 } )
517533
518534 it ( "classifies 'Unknown tool' as unknownTool and pushes tool_result" , async ( ) => {
@@ -528,6 +544,7 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
528544 id : toolCallId ,
529545 name : "fake_tool_xyz" ,
530546 params : { } ,
547+ nativeArgs : { } ,
531548 partial : false ,
532549 } ,
533550 ]
@@ -540,6 +557,10 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
540557 expect ( toolResult ) . toBeDefined ( )
541558 expect ( toolResult . is_error ) . toBe ( true )
542559 expect ( mockTask . consecutiveMistakeCount ) . toBe ( 1 )
560+ // User must see the error in the UI (design principle: both must happen).
561+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
562+ expect ( errorSayCalls . length ) . toBe ( 1 )
563+ expect ( errorSayCalls [ 0 ] [ 1 ] ) . toContain ( "Unknown tool" )
543564 } )
544565
545566 it ( "classifies 'File restriction' as fileRestriction and pushes tool_result" , async ( ) => {
@@ -555,6 +576,7 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
555576 id : toolCallId ,
556577 name : "write_to_file" ,
557578 params : { path : ".git/config" , content : "bad" } ,
579+ nativeArgs : { path : ".git/config" , content : "bad" } ,
558580 partial : false ,
559581 } ,
560582 ]
@@ -566,6 +588,10 @@ describe("presentAssistantMessage - Error Interception Integration", () => {
566588 )
567589 expect ( toolResult ) . toBeDefined ( )
568590 expect ( toolResult . is_error ) . toBe ( true )
591+ // User must see the error in the UI (design principle: both must happen).
592+ const errorSayCalls = mockTask . say . mock . calls . filter ( ( c : any [ ] ) => c [ 0 ] === "error" )
593+ expect ( errorSayCalls . length ) . toBe ( 1 )
594+ expect ( errorSayCalls [ 0 ] [ 1 ] ) . toContain ( "File restriction" )
569595 } )
570596 } )
571597
0 commit comments