@@ -810,6 +810,41 @@ const taskResult = (laptopEnv: Effect.Success<ReturnType<typeof makeLaptop>>, ta
810810 ) ,
811811 ) ;
812812
813+ it . effect ( "returns the recorded task when an accepted launch loses its response" , ( ) =>
814+ Effect . scoped (
815+ Effect . gen ( function * ( ) {
816+ const thread = yield * makeBoxThread ;
817+ const b = yield * serveBox ( thread ) ;
818+ const offers = yield * SubscriptionRef . make <
819+ ReadonlyArray < ProviderContinuationRequests . ProviderContinuationRequest >
820+ > ( [ ] ) ;
821+ const database = yield * SqlitePersistence . layerMemory . pipe ( Layer . build ) ;
822+ const a = yield * makeLaptop ( database , offers ) ;
823+ yield * linkTo ( a . links , b , "full-access" ) ;
824+ yield * seedParent ( a ) ;
825+ yield * Ref . set (
826+ thread . afterLaunch ,
827+ Ref . set ( thread . afterLaunch , Effect . void ) . pipe (
828+ Effect . andThen ( Effect . die ( "The accepted launch response was lost." ) ) ,
829+ ) ,
830+ ) ;
831+ const delegated = yield * delegateToBox ( a ) ;
832+ expect ( delegated . taskId ) . toBeDefined ( ) ;
833+ const recorded = yield * a . orchestrator . getThreadProjection ( parentThreadId ) ;
834+ expect ( recorded . subagents ) . toHaveLength ( 1 ) ;
835+ expect ( recorded . subagents [ 0 ] ?. id ) . toBe ( delegated . taskId ) ;
836+ yield * Ref . set ( thread . reply , "Recovered the accepted child." ) ;
837+ yield * Ref . set ( thread . status , "completed" ) ;
838+ yield * Deferred . succeed ( thread . finished , undefined ) ;
839+ expect ( yield * taskResult ( a , delegated . taskId ) ) . toMatchObject ( {
840+ status : "completed" ,
841+ result : "Recovered the accepted child." ,
842+ } ) ;
843+ expect ( new Set ( yield * Ref . get ( thread . launchIds ) ) . size ) . toBe ( 1 ) ;
844+ } ) ,
845+ ) . pipe ( Effect . provide ( NodeHttpServer . layerTest ) ) ,
846+ ) ;
847+
813848it . effect ( "a task delegated to the box wakes the laptop's parent when it ends there" , ( ) =>
814849 Effect . scoped (
815850 Effect . gen ( function * ( ) {
0 commit comments