Skip to content

Commit 2e12baa

Browse files
saphidclaude
andcommitted
fix(server): waking or pinning a usage-limit-snoozed thread no longer re-snoozes it on Resume at reset
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d01b92c commit 2e12baa

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,6 +3514,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
35143514
snoozedUntil: null,
35153515
snoozedAt: null,
35163516
lastSnoozeWakeAt: alreadyAwake ? thread.lastSnoozeWakeAt : now,
3517+
limitRecovery: thread.limitRecovery ? { ...thread.limitRecovery, snooze: false } : null,
35173518
updatedAt: alreadyAwake ? thread.updatedAt : now,
35183519
};
35193520
}
@@ -3540,6 +3541,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
35403541
snoozedUntil: null,
35413542
snoozedAt: null,
35423543
lastSnoozeWakeAt: thread.snoozedUntil == null ? thread.lastSnoozeWakeAt : now,
3544+
limitRecovery: thread.limitRecovery ? { ...thread.limitRecovery, snooze: false } : null,
35433545
updatedAt: alreadyPinned && !promotes ? thread.updatedAt : now,
35443546
};
35453547
}

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)