@@ -7876,6 +7876,8 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
78767876 "independent-patches" ,
78777877 "expired-snooze" ,
78787878 "wake" ,
7879+ "wake-then-resume" ,
7880+ "pin-then-resume" ,
78797881 "stop" ,
78807882 "stop-before-arm" ,
78817883 "stop-before-arm-mismatched-recovery" ,
@@ -8025,8 +8027,10 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
80258027 assert . isNull ( current . thread . snoozedUntil ) ;
80268028 return ;
80278029 }
8028- const snooze = scenario === "wake" || scenario === "cancel-resume-keep-snooze" ;
8029- const autoResume = scenario !== "wake" ;
8030+ const wakesBeforeResume = scenario === "wake-then-resume" || scenario === "pin-then-resume" ;
8031+ const snooze =
8032+ scenario === "wake" || scenario === "cancel-resume-keep-snooze" || wakesBeforeResume ;
8033+ const autoResume = scenario !== "wake" && ! wakesBeforeResume ;
80308034 const arm = limitRecoveryCommand ( shell , autoResume , DateTime . toEpochMillis ( now ) , snooze ) ;
80318035 assert ( arm ?. type === "thread.metadata.update" && arm . limitRecovery != null ) ;
80328036 const automaticArm = {
@@ -8199,6 +8203,33 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
81998203 } ) ;
82008204 assert . isNull ( ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . snoozedUntil ) ;
82018205 }
8206+ if ( wakesBeforeResume ) {
8207+ yield * orchestrator . dispatch (
8208+ scenario === "pin-then-resume"
8209+ ? {
8210+ type : "thread.pin" ,
8211+ commandId : CommandId . make ( `recovery:pin:${ scenario } ` ) ,
8212+ threadId,
8213+ }
8214+ : {
8215+ type : "thread.unsnooze" ,
8216+ commandId : CommandId . make ( `recovery:sidebar-wake:${ scenario } ` ) ,
8217+ threadId,
8218+ reason : "user" ,
8219+ } ,
8220+ ) ;
8221+ assert . isNull ( ( yield * orchestrator . getThreadProjection ( threadId ) ) . thread . snoozedUntil ) ;
8222+ // "Resume at reset" omits snooze, so it inherits the stored flag.
8223+ yield * orchestrator . dispatch ( {
8224+ type : "thread.metadata.update" ,
8225+ commandId : CommandId . make ( `recovery:resume-after-wake:${ scenario } ` ) ,
8226+ threadId,
8227+ limitRecovery : { runId : run . id , resetAt, autoResume : true } ,
8228+ } ) ;
8229+ const current = yield * orchestrator . getThreadProjection ( threadId ) ;
8230+ assert . isTrue ( current . thread . limitRecovery ! . autoResume ) ;
8231+ assert . isNull ( current . thread . snoozedUntil ) ;
8232+ }
82028233 assert . isNull ( limitRecoveryCommand ( armedShell , true , DateTime . toEpochMillis ( now ) ) ) ;
82038234 yield * orchestrator . dispatch ( {
82048235 type : "message.dispatch" ,
0 commit comments