@@ -308,7 +308,22 @@ describe("CursorAdapterV2", () => {
308308 } ) ,
309309 failure : null ,
310310 } ,
311- ] ) ( "ends the turn with $reason" , ( { updates = [ ] , wait, failure } ) =>
311+ {
312+ reason : "no answer from a resume after the turn ended that made no progress" ,
313+ updates : [ { type : "turn-ended" } ] satisfies ReadonlyArray < InteractionUpdate > ,
314+ wait : Effect . succeed ( {
315+ id : "native-cursor-run" ,
316+ requestId : "native-request" ,
317+ status : "error" as const ,
318+ error : { message : "Agent turn stopped after repeated resume attempts made no progress" } ,
319+ result : "A regenerated closing." ,
320+ model : { id : "claude-fable-5" } ,
321+ durationMs : 1 ,
322+ } ) ,
323+ failure : null ,
324+ answers : [ ] ,
325+ } ,
326+ ] ) ( "ends the turn with $reason" , ( { updates = [ ] , wait, failure, answers } ) =>
312327 Effect . gen ( function * ( ) {
313328 const fileSystem = yield * FileSystem . FileSystem ;
314329 const workspace = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "cursor-v2-failure-" } ) ;
@@ -401,15 +416,23 @@ describe("CursorAdapterV2", () => {
401416 attachments : [ ] ,
402417 } ,
403418 } ) ;
404- const terminal = yield * runtime . events . pipe (
405- Stream . filter ( ( event ) => event . type === "turn.terminal" ) ,
406- Stream . runHead ,
419+ const events = yield * runtime . events . pipe (
420+ Stream . takeUntil ( ( event ) => event . type === "turn.terminal" ) ,
421+ Stream . runCollect ,
407422 ) ;
408- assert . isTrue ( Option . isSome ( terminal ) ) ;
409- if ( Option . isSome ( terminal ) ) {
410- assert . equal ( terminal . value . status , failure === null ? "completed" : "failed" ) ;
411- assert . equal ( terminal . value . failure ?. class , failure ?. class ) ;
412- assert . equal ( terminal . value . failure ?. message , failure ?. message ) ;
423+ const terminal = events . find ( ( event ) => event . type === "turn.terminal" ) ;
424+ assert . equal ( terminal ?. status , failure === null ? "completed" : "failed" ) ;
425+ assert . equal ( terminal ?. failure ?. class , failure ?. class ) ;
426+ assert . equal ( terminal ?. failure ?. message , failure ?. message ) ;
427+ if ( answers !== undefined ) {
428+ assert . deepEqual (
429+ events . flatMap ( ( event ) =>
430+ event . type === "message.updated" && event . message . role === "assistant"
431+ ? [ event . message . text ]
432+ : [ ] ,
433+ ) ,
434+ answers ,
435+ ) ;
413436 }
414437 } ) . pipe (
415438 Effect . scoped ,
0 commit comments