@@ -33,13 +33,18 @@ describe("fx permission prompts", () => {
3333} ) ;
3434
3535describe ( "fx cancellation failures" , ( ) => {
36+ const diff = { type : "diff" , path : "notes.txt" , oldText : "old" , newText : "new" } ;
37+ const terminal = { type : "terminal" , terminalId : "fx-terminal" } ;
38+
3639 it . each ( [
3740 { content : [ "Cancelled" ] , cancelled : true } ,
3841 { content : [ "Cancelled." ] , cancelled : true } ,
3942 { content : [ '{"error":{"details":{"error":"Cancelled"}}}' ] , cancelled : true } ,
4043 { content : [ '{"error":{"details":{"error":"Permission denied"}}}' ] , cancelled : false } ,
4144 { content : [ "Command failed" ] , cancelled : false } ,
4245 { content : [ "" ] , cancelled : false } ,
46+ { content : [ "Cancelled" ] , followingItems : [ diff ] , cancelled : true } ,
47+ { content : [ "Cancelled" ] , precedingItems : [ diff ] , cancelled : false } ,
4348 {
4449 content : [ '{"error":{"details":{"error":"Permission denied"}}}' , "Cancelled" ] ,
4550 cancelled : false ,
@@ -52,14 +57,23 @@ describe("fx cancellation failures", () => {
5257 content : [ "Cancelled" , '{"error":{"details":{"error":"Permission denied"}}}' ] ,
5358 cancelled : true ,
5459 } ,
55- ] ) ( "recognizes $content as cancellation: $cancelled" , ( { content, cancelled } ) => {
56- assert . equal (
57- fxToolCallWasCancelled ( {
58- update : { content : content . map ( ( text ) => ( { content : { text } } ) ) } ,
59- } ) ,
60- cancelled ,
61- ) ;
62- } ) ;
60+ ] ) (
61+ "recognizes $content as cancellation: $cancelled" ,
62+ ( { content, cancelled, precedingItems = [ ] , followingItems = [ ] } ) => {
63+ assert . equal (
64+ fxToolCallWasCancelled ( {
65+ update : {
66+ content : [
67+ ...precedingItems ,
68+ ...content . map ( ( text ) => ( { content : { text } } ) ) ,
69+ ...followingItems ,
70+ ] ,
71+ } ,
72+ } ) ,
73+ cancelled ,
74+ ) ;
75+ } ,
76+ ) ;
6377
6478 it . each ( [
6579 {
@@ -80,6 +94,34 @@ describe("fx cancellation failures", () => {
8094 followingContent : [ "Cancelled" ] ,
8195 cancelled : false ,
8296 } ,
97+ {
98+ exit_code : null ,
99+ signal : null ,
100+ timed_out : false ,
101+ termination_indeterminate : true ,
102+ content : '{"error":{"message":"Permission denied","details":{"error":"Permission denied"}}}' ,
103+ followingItems : [ terminal ] ,
104+ cancelled : false ,
105+ } ,
106+ {
107+ exit_code : null ,
108+ signal : null ,
109+ timed_out : false ,
110+ termination_indeterminate : true ,
111+ content : '{"error":{"type":"tool_execution_failed","message":"clipped",' ,
112+ followingItems : [ diff ] ,
113+ cancelled : false ,
114+ } ,
115+ {
116+ exit_code : null ,
117+ signal : null ,
118+ timed_out : false ,
119+ termination_indeterminate : true ,
120+ content : "Still processing" ,
121+ followingContent : [ '{"error":{"message":"Permission denied"}}' ] ,
122+ followingItems : [ diff ] ,
123+ cancelled : false ,
124+ } ,
83125 {
84126 exit_code : 1 ,
85127 signal : null ,
@@ -98,12 +140,15 @@ describe("fx cancellation failures", () => {
98140 } ,
99141 ] ) (
100142 "recognizes a command result with exit $exit_code, timeout $timed_out" ,
101- ( { cancelled, content, followingContent = [ ] , ...commandResult } ) => {
143+ ( { cancelled, content, followingContent = [ ] , followingItems = [ ] , ...commandResult } ) => {
102144 assert . equal (
103145 fxToolCallWasCancelled ( {
104146 update : {
105147 command_result : commandResult ,
106- content : [ content , ...followingContent ] . map ( ( text ) => ( { content : { text } } ) ) ,
148+ content : [
149+ ...[ content , ...followingContent ] . map ( ( text ) => ( { content : { text } } ) ) ,
150+ ...followingItems ,
151+ ] ,
107152 } ,
108153 } ) ,
109154 cancelled ,
0 commit comments