@@ -800,56 +800,61 @@ describe("AgentAwarenessRelay", () => {
800800 ) ;
801801
802802 it . effect . each ( [
803- { work : "running" , phase : "running" } ,
804- { work : "user input" , phase : "waiting_for_input" } ,
805- { work : "monitor" , phase : "running" } ,
806- ] as const ) ( "keeps settled $work visible until it finishes" , ( { work, phase } ) =>
807- Effect . gen ( function * ( ) {
808- const { relay, currentShell, publications } = yield * makeTestRelay ( ) ;
809- const active = shell ( {
810- status : work === "running" ? "running" : "completed" ,
811- latestRunCompletedAt : DateTime . add ( yield * DateTime . now , { seconds : 1 } ) ,
812- pendingRuntimeRequest :
813- work === "user input"
814- ? {
815- id : RuntimeRequestId . make ( "waiting" ) ,
816- kind : "user_input" ,
817- createdAt : yield * DateTime . now ,
818- }
819- : null ,
820- pendingBackgroundTasks : work === "monitor" ? [ { taskId : "watch" , kind : "monitor" } ] : [ ] ,
821- } ) ;
822- yield * Ref . set ( currentShell , active ) ;
823- yield * relay . publishThread ( THREAD_ID ) ;
824- assert . deepEqual (
825- publications . map ( ( { state } ) => state ?. phase ) ,
826- [ phase ] ,
827- ) ;
803+ { work : "running" , status : "running" , phase : "running" } ,
804+ { work : "user input" , status : "completed" , phase : "waiting_for_input" } ,
805+ { work : "monitor" , status : "completed" , phase : "running" } ,
806+ { work : "monitor" , status : "failed" , phase : "failed" } ,
807+ ] as const ) (
808+ "keeps settled $work visible until it finishes ($status run)" ,
809+ ( { work, status, phase } ) =>
810+ Effect . gen ( function * ( ) {
811+ const { relay, currentShell, publications } = yield * makeTestRelay ( ) ;
812+ const active = shell ( {
813+ status,
814+ latestRunCompletedAt : DateTime . add ( yield * DateTime . now , { seconds : 1 } ) ,
815+ pendingRuntimeRequest :
816+ work === "user input"
817+ ? {
818+ id : RuntimeRequestId . make ( "waiting" ) ,
819+ kind : "user_input" ,
820+ createdAt : yield * DateTime . now ,
821+ }
822+ : null ,
823+ pendingBackgroundTasks : work === "monitor" ? [ { taskId : "watch" , kind : "monitor" } ] : [ ] ,
824+ } ) ;
825+ yield * Ref . set ( currentShell , active ) ;
826+ yield * relay . publishThread ( THREAD_ID ) ;
827+ yield * TestClock . adjust ( "5 seconds" ) ;
828+ yield * relay . drain ;
829+ assert . deepEqual (
830+ publications . map ( ( { state } ) => state ?. phase ) ,
831+ [ phase ] ,
832+ ) ;
828833
829- yield * Ref . set ( currentShell , { ...active , settledOverride : "settled" } ) ;
830- yield * relay . publishThread ( THREAD_ID ) ;
831- yield * TestClock . adjust ( "5 seconds" ) ;
832- yield * relay . drain ;
833- assert . deepEqual (
834- publications . map ( ( { state } ) => state ?. phase ) ,
835- [ phase ] ,
836- ) ;
834+ yield * Ref . set ( currentShell , { ...active , settledOverride : "settled" } ) ;
835+ yield * relay . publishThread ( THREAD_ID ) ;
836+ yield * TestClock . adjust ( "5 seconds" ) ;
837+ yield * relay . drain ;
838+ assert . deepEqual (
839+ publications . map ( ( { state } ) => state ?. phase ) ,
840+ [ phase ] ,
841+ ) ;
837842
838- yield * Ref . set ( currentShell , {
839- ...active ,
840- settledOverride : "settled" ,
841- status : " completed",
842- pendingRuntimeRequest : null ,
843- pendingBackgroundTasks : [ ] ,
844- } ) ;
845- yield * relay . publishThread ( THREAD_ID ) ;
846- yield * TestClock . adjust ( "5 seconds" ) ;
847- yield * relay . drain ;
848- assert . deepEqual (
849- publications . map ( ( { state } ) => state ?. phase ?? null ) ,
850- [ phase , null ] ,
851- ) ;
852- } ) ,
843+ yield * Ref . set ( currentShell , {
844+ ...active ,
845+ settledOverride : "settled" ,
846+ status : status === "running" ? " completed" : status ,
847+ pendingRuntimeRequest : null ,
848+ pendingBackgroundTasks : [ ] ,
849+ } ) ;
850+ yield * relay . publishThread ( THREAD_ID ) ;
851+ yield * TestClock . adjust ( "5 seconds" ) ;
852+ yield * relay . drain ;
853+ assert . deepEqual (
854+ publications . map ( ( { state } ) => state ?. phase ?? null ) ,
855+ [ phase , null ] ,
856+ ) ;
857+ } ) ,
853858 ) ;
854859
855860 it . effect ( "confirms a first completed state and respects disabling during confirmation" , ( ) =>
0 commit comments