The best way to control Claude Code, Codex and more from any computer or phone
fix(server): re-snoozing a woken thread to the same wake time hides it again (#14887)
Jonas B. committed
Oct 18, 2026 at 15:08 UTC
699c1c5d4ce7ea21511f17dce0a201957e92fb8d
4 files changed
+36
-15
apps/server/src/orchestration-v2/Orchestrator.ts
+5
-7
@@ -2878,17 +2878,15 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
2878
};
2879
}
2880
case "thread.snooze": {
2881
- const sameWakeTime =
2882
- thread.snoozedUntil != null &&
2883
- snoozedUntil !== null &&
2884
- DateTime.toEpochMillis(thread.snoozedUntil) === DateTime.toEpochMillis(snoozedUntil);
2885
- const existingSnoozedAt = sameWakeTime ? (thread.snoozedAt ?? null) : null;
2881
+ // Always restamp, even for the same wake time: a re-snooze after a
2882
+ // failure or completion woke the thread means "I saw it, not now".
2883
+ // Retries are deduplicated by commandId before reaching here.
2884
return {
2885
...thread,
2886
snoozedUntil,
2887
limitRecovery: thread.limitRecovery ? { ...thread.limitRecovery, snooze: false } : null,
2890
- snoozedAt: existingSnoozedAt ?? now,
2891
- updatedAt: existingSnoozedAt === null ? now : thread.updatedAt,
2888
+ snoozedAt: now,
2889
+ updatedAt: now,
2890
};
2891
}
2892
case "thread.unsnooze": {
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+8
-3
@@ -5191,9 +5191,11 @@ it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
5191
5192
const firstProjection = yield* orchestrator.getThreadProjection(threadId);
5193
const firstSnoozedAt = firstProjection.thread.snoozedAt;
5194
- const firstUpdatedAt = firstProjection.thread.updatedAt;
5194
assert.isNotNull(firstSnoozedAt);
5195
5196
+ // Repeating a calendar preset sends the same wake time. It must still
5197
+ // restamp snoozedAt, or a failure that woke the thread keeps it awake.
5198
+ yield* TestClock.adjust("1 second");
5199
yield* orchestrator.dispatch({
5200
type: "thread.snooze",
5201
commandId: CommandId.make("runtime-layer-snoozed-thread-snooze-again"),
@@ -5205,8 +5207,11 @@ it.layer(layerSharedApplicationDataPlaneTest)("snooze projection", (it) => {
5207
const thread = shell.threads.find((candidate) => candidate.id === threadId);
5208
assert.isDefined(thread);
5209
assert.equal(DateTime.formatIso(thread.snoozedUntil!), snoozedUntil);
5208
- assert.deepEqual(thread.snoozedAt, firstSnoozedAt);
5209
- assert.deepEqual(thread.updatedAt, firstUpdatedAt);
5210
+ assert.equal(
5211
+ DateTime.toEpochMillis(thread.snoozedAt!),
5212
+ DateTime.toEpochMillis(firstSnoozedAt!) + 1_000,
5213
+ );
5214
+ assert.deepEqual(thread.updatedAt, thread.snoozedAt);
5215
5216
yield* orchestrator.dispatch({
5217
type: "thread.unsnooze",
packages/client-runtime/src/state/threadCommands.test.ts
+22
@@ -182,6 +182,28 @@ describe("remote thread lifecycle commands", () => {
182
}),
183
);
184
185
+ it.effect("restamps snoozedAt when re-snoozing to the same wake time", () =>
186
+ Effect.gen(function* () {
187
+ const h = yield* makeHarness();
188
+ const earlierSnoozedAt = DateTime.makeUnsafe("2000-01-01T00:00:00.000Z");
189
+ h.registry.set(h.snapshotAtom(ENVIRONMENT_ID), {
190
+ ...SNAPSHOT,
191
+ threads: [{ ...SNAPSHOT.threads[0]!, snoozedUntil: FUTURE, snoozedAt: earlierSnoozedAt }],
192
+ });
193
+ const result = h.commands.snooze.run(h.registry, {
194
+ environmentId: ENVIRONMENT_ID,
195
+ input: { threadId: THREAD_ID, snoozedUntil: DateTime.formatIso(FUTURE) },
196
+ });
197
+ const snoozedAt = h.registry.get(h.visibleAtom)?.threads[0]?.snoozedAt;
198
+ expect(DateTime.toEpochMillis(snoozedAt!)).toBeGreaterThan(
199
+ DateTime.toEpochMillis(earlierSnoozedAt),
200
+ );
201
+ const request = yield* Queue.take(h.requests);
202
+ yield* Deferred.succeed(request.reply, { sequence: 2 });
203
+ expect((yield* Effect.promise(() => result))._tag).toBe("Success");
204
+ }),
205
+ );
206
+
207
it.effect("keeps the preview after acknowledgement until the matching shell update arrives", () =>
208
Effect.gen(function* () {
209
const h = yield* makeHarness();
packages/client-runtime/src/state/threadCommands.ts
+1
-5
@@ -443,11 +443,7 @@ export function createThreadEnvironmentAtoms<R, E>(
443
...thread,
444
pendingRuntimeRequest: null,
445
snoozedUntil: DateTime.makeUnsafe(input.snoozedUntil),
446
- snoozedAt:
447
- thread.snoozedUntil != null &&
448
- DateTime.formatIso(thread.snoozedUntil) === input.snoozedUntil
449
- ? (thread.snoozedAt ?? now)
450
- : now,
446
+ snoozedAt: now,
447
},
448
),
449
unsnooze: optimistic.wrap(commands.unsnooze, (thread) => ({