@@ -643,7 +643,7 @@ it.effect("closes a secret request card's form when its run is recovered", () =>
643643 } ) . pipe ( Effect . provide ( layer ) ) ;
644644} ) ;
645645
646- it . effect ( "holds accepted queued work without cancelling its execution state after restart", ( ) => {
646+ it . effect . each ( [ " queued" , "preparing" ] as const ) ( "recovers $0 work after restart", ( status ) => {
647647 const threadId = ThreadId . make ( "thread_queued_restart" ) ;
648648 const runId = RunId . make ( "run_queued_restart" ) ;
649649 const attemptId = RunAttemptId . make ( "attempt_queued_restart" ) ;
@@ -659,9 +659,18 @@ it.effect("holds accepted queued work without cancelling its execution state aft
659659 runs : [
660660 {
661661 id : runId ,
662- status : "queued" ,
662+ status,
663663 queuePosition : 1 ,
664664 providerInstanceId : ProviderInstanceId . make ( "codex" ) ,
665+ ...( status === "preparing"
666+ ? {
667+ workspacePreparation : {
668+ type : "worktree" ,
669+ baseRef : "parent-local-commit" ,
670+ startFromOrigin : false ,
671+ } ,
672+ }
673+ : { } ) ,
665674 } ,
666675 ] ,
667676 attempts : [
@@ -711,18 +720,33 @@ it.effect("holds accepted queued work without cancelling its execution state aft
711720 return Effect . gen ( function * ( ) {
712721 const summary =
713722 yield * ( yield * ProviderRuntimeRecovery . ProviderRuntimeRecoveryService ) . reconcile ( "startup" ) ;
714- assert . equal ( summary . terminalizedRuns , 0 ) ;
723+ assert . equal ( summary . terminalizedRuns , status === "preparing" ? 1 : 0 ) ;
715724 const command = committedInput ;
716725 assert . isNotNull ( command ) ;
717726 if ( command === null ) return ;
718727 const runEvent = command . events . find ( ( event ) => event . type === "run.updated" ) ;
719728 const attemptEvent = command . events . find ( ( event ) => event . type === "run-attempt.updated" ) ;
720729 const nodeEvent = command . events . find ( ( event ) => event . type === "node.updated" ) ;
721- assert . equal ( runEvent ?. type === "run.updated" ? runEvent . payload . status : null , "queued" ) ;
722- assert . equal ( runEvent ?. type === "run.updated" ? runEvent . payload . queuePosition : null , 1 ) ;
723- assert . equal ( runEvent ?. type === "run.updated" ? runEvent . payload . queueHeld : false , true ) ;
724- assert . isUndefined ( attemptEvent ) ;
725- assert . isUndefined ( nodeEvent ) ;
730+ assert . equal (
731+ runEvent ?. type === "run.updated" ? runEvent . payload . status : null ,
732+ status === "preparing" ? "cancelled" : "queued" ,
733+ ) ;
734+ assert . isEmpty ( command . effects ) ;
735+ if ( status === "preparing" ) {
736+ assert . equal (
737+ attemptEvent ?. type === "run-attempt.updated" ? attemptEvent . payload . status : null ,
738+ "cancelled" ,
739+ ) ;
740+ assert . equal (
741+ nodeEvent ?. type === "node.updated" ? nodeEvent . payload . status : null ,
742+ "cancelled" ,
743+ ) ;
744+ } else {
745+ assert . equal ( runEvent ?. type === "run.updated" ? runEvent . payload . queuePosition : null , 1 ) ;
746+ assert . equal ( runEvent ?. type === "run.updated" ? runEvent . payload . queueHeld : false , true ) ;
747+ assert . isUndefined ( attemptEvent ) ;
748+ assert . isUndefined ( nodeEvent ) ;
749+ }
726750 } ) . pipe ( Effect . provide ( layer ) ) ;
727751} ) ;
728752
0 commit comments