The best way to control Claude Code, Codex and more from any computer or phone
fix(web): don't send completion notifications for snoozed threads (#27458)
Co-authored-by: maximkes <22573701+maximkes@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
maximkes committed
Nov 14, 2026 at 18:01 UTC
4954322f02f7b569bd0369caa4e1552393635a1c
6 files changed
+132
-6
apps/server/src/orchestration-v2/ProjectionStore.ts
+6
@@ -1081,6 +1081,9 @@ export type AgentAwarenessThread = ProjectThreadAwarenessV2Input["thread"] &
1081
| "creationSource"
1082
| "latestRunCompletedAt"
1083
| "archivedAt"
1084
+ | "snoozedUntil"
1085
+ | "snoozedAt"
1086
+ | "pendingGuestMessageCount"
1087
| "activeRunId"
1088
| "latestRunId"
1089
| "hasActionableProposedPlan"
@@ -8685,6 +8688,9 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
8688
projectId: state.thread.projectId,
8689
creationSource: state.thread.creationSource,
8690
archivedAt: state.thread.archivedAt,
8691
+ snoozedUntil: state.thread.snoozedUntil ?? null,
8692
+ snoozedAt: state.thread.snoozedAt ?? null,
8693
+ pendingGuestMessageCount: pendingGuestMessageCount(state.thread.guestShare),
8694
activeRunId: state.activeRunId,
8695
latestRunId: state.latestRunId,
8696
hasActionableProposedPlan: state.hasActionableProposedPlan,
apps/server/src/relay/AgentAwarenessRelay.test.ts
+31
@@ -753,6 +753,37 @@ describe("AgentAwarenessRelay", () => {
753
}),
754
);
755
756
+ it.effect(
757
+ "clears a completion that landed while snoozed, even when processed after the wake",
758
+ () =>
759
+ Effect.gen(function* () {
760
+ yield* TestClock.setTime(DateTime.toEpochMillis(DateTime.makeUnsafe(NOW)));
761
+ const { relay, currentShell, publications } = yield* makeTestRelay();
762
+ const snooze = {
763
+ snoozedAt: DateTime.makeUnsafe(NOW),
764
+ snoozedUntil: DateTime.makeUnsafe("2026-09-04T13:00:00.000Z"),
765
+ };
766
+ yield* Ref.set(currentShell, shell(snooze));
767
+ yield* relay.publishThread(THREAD_ID);
768
+ yield* TestClock.adjust("2 hours");
769
+ yield* Ref.set(
770
+ currentShell,
771
+ shell({
772
+ ...snooze,
773
+ status: "completed",
774
+ latestRunCompletedAt: DateTime.makeUnsafe("2026-09-04T12:30:00.000Z"),
775
+ }),
776
+ );
777
+ yield* relay.publishThread(THREAD_ID);
778
+ yield* TestClock.adjust("5 seconds");
779
+ yield* relay.drain;
780
+ assert.deepEqual(
781
+ publications.map((publication) => publication.state?.phase ?? null),
782
+ ["running", null],
783
+ );
784
+ }),
785
+ );
786
+
787
it.effect("still publishes a completion when the thread settles during the hold", () =>
788
Effect.gen(function* () {
789
const { relay, currentShell, publications } = yield* makeTestRelay();
apps/server/src/relay/AgentAwarenessRelay.ts
+17
-1
@@ -51,6 +51,7 @@ import {
51
import { EnvironmentSigningKey } from "../cloud/environmentKeys.ts";
52
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
53
import * as ThreadManagement from "../orchestration-v2/ThreadManagementService.ts";
54
+import { isSnoozed } from "../orchestration-v2/ThreadSettlementService.ts";
55
import * as ProjectService from "../project/ProjectService.ts";
56
import { forkParked } from "../serverActivation.ts";
57
@@ -360,12 +361,27 @@ function resolveAgentAwarenessRelayPublishSnapshot(input: {
361
state?.phase !== projectThreadAwarenessV2(awarenessInput)?.phase;
362
return {
363
projectId: input.thread.value.projectId,
363
- state: sanitizeRelayAgentActivityState(state),
364
+ state: snoozedCompletion(input.thread.value, state)
365
+ ? null
366
+ : sanitizeRelayAgentActivityState(state),
367
subagentWait: childDrivesWait ? input.pendingSubagentRequest : null,
368
reason: "snapshot",
369
};
370
}
371
372
+// Checked at completion time, so a completion processed after the wake stays silent too.
373
+function snoozedCompletion(
374
+ thread: AgentAwarenessThread,
375
+ state: { readonly phase: string } | null,
376
+): boolean {
377
+ if (state?.phase !== "completed" || thread.latestRunCompletedAt == null) return false;
378
+ const completedAt = DateTime.toEpochMillis(thread.latestRunCompletedAt);
379
+ if (thread.snoozedAt != null && completedAt < DateTime.toEpochMillis(thread.snoozedAt)) {
380
+ return false;
381
+ }
382
+ return isSnoozed(thread, completedAt);
383
+}
384
+
385
function terminalWorkSinceStart(thread: AgentAwarenessThread, startedAt: number): boolean {
386
return (
387
thread.latestRunCompletedAt != null &&
apps/web/src/components/ThreadNotificationCoordinator.logic.test.ts
+50
-1
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vite-plus/test";
2
3
import {
4
createThreadNotificationGate,
5
+ isSnoozedForNotification,
6
RELEASED_COMPLETION_GRACE_MS,
7
type ThreadNotificationObservation,
8
} from "./ThreadNotificationCoordinator.logic";
@@ -25,7 +26,8 @@ const woke = (at: number): ThreadNotificationObservation => ({
26
...completed(at),
27
backgroundWake: true,
28
});
28
-const visible = { archived: false, quiet: false };
29
+const visible = { archived: false, quiet: false, snoozed: false };
30
+const snoozed = { ...visible, snoozed: true };
31
32
function fakeTimers(): Disposable {
33
vi.useFakeTimers();
@@ -44,6 +46,16 @@ function harness() {
46
}
47
48
describe("createThreadNotificationGate", () => {
49
+ it("skips a completion seen while snoozed, but still notifies attention", () => {
50
+ const { notify, observe } = harness();
51
+ observe(working);
52
+ observe(completed(1), snoozed);
53
+ observe({ ...completed(1) });
54
+ expect(notify).not.toHaveBeenCalled();
55
+ observe({ ...working, attention: "run-2:approval" }, snoozed);
56
+ expect(notify.mock.calls).toEqual([["thread", "input"]]);
57
+ });
58
+
59
it("notifies a completion immediately and only once", () => {
60
const { notify, observe } = harness();
61
observe(working);
@@ -180,6 +192,16 @@ describe("createThreadNotificationGate", () => {
192
expect(notify).toHaveBeenCalledTimes(1);
193
});
194
195
+ it("drops a pending wake completion when the thread is snoozed", () => {
196
+ using _timers = fakeTimers();
197
+ const { notify, observe } = harness();
198
+ observe(waking);
199
+ observe(woke(1));
200
+ observe({ ...woke(1) }, snoozed);
201
+ vi.advanceTimersByTime(RELEASED_COMPLETION_GRACE_MS);
202
+ expect(notify).not.toHaveBeenCalled();
203
+ });
204
+
205
it("drops a pending wake completion when the thread is removed or the gate is cleared", () => {
206
using _timers = fakeTimers();
207
for (const reset of [
@@ -195,3 +217,30 @@ describe("createThreadNotificationGate", () => {
217
}
218
});
219
});
220
+
221
+describe("isSnoozedForNotification", () => {
222
+ const snoozedAt = Date.parse("2026-01-01T11:00:00.000Z");
223
+ const wakeAt = Date.parse("2026-01-01T12:00:00.000Z");
224
+ const thread = {
225
+ snoozedAt: new Date(snoozedAt).toISOString(),
226
+ snoozedUntil: new Date(wakeAt).toISOString(),
227
+ hasPendingApprovals: false,
228
+ hasPendingUserInput: false,
229
+ };
230
+ const later = wakeAt + 60_000;
231
+
232
+ it.each([
233
+ ["during the snooze, processed after the wake", thread, wakeAt - 1, later, true],
234
+ ["before the snooze, processed after the wake", thread, snoozedAt - 1, later, false],
235
+ ["after the wake", thread, wakeAt + 1, later, false],
236
+ [
237
+ "after an early wake for attention",
238
+ { ...thread, hasPendingApprovals: true },
239
+ wakeAt - 1,
240
+ wakeAt - 1,
241
+ false,
242
+ ],
243
+ ])("a completion %s is suppressed: %s", (_name, shell, completedAt, now, expected) => {
244
+ expect(isSnoozedForNotification(shell, completedAt, now)).toBe(expected);
245
+ });
246
+});
apps/web/src/components/ThreadNotificationCoordinator.logic.ts
+25
-4
@@ -1,3 +1,8 @@
1
+import {
2
+ effectiveSnoozed,
3
+ type ThreadSnoozeShell,
4
+} from "@t3tools/client-runtime/state/thread-settled";
5
+
6
export type ThreadNotificationKind = "input" | "completion";
7
8
export interface ThreadNotificationObservation {
@@ -16,6 +21,21 @@ export interface ThreadNotificationObservation {
21
/** Matches the push relay's completion confirmation: a final wake can start right after a progress wake. */
22
export const RELEASED_COMPLETION_GRACE_MS = 5_000;
23
24
+/**
25
+ * Whether completion notifications are suppressed by snooze. A completion that landed
26
+ * during the snooze stays suppressed even when its update is processed after the wake.
27
+ */
28
+export function isSnoozedForNotification(
29
+ thread: ThreadSnoozeShell,
30
+ completedAt: number | null,
31
+ now: number,
32
+): boolean {
33
+ if (effectiveSnoozed(thread, { now: new Date(now).toISOString() })) return true;
34
+ if (completedAt === null) return false;
35
+ if (thread.snoozedAt != null && completedAt < Date.parse(thread.snoozedAt)) return false;
36
+ return effectiveSnoozed(thread, { now: new Date(completedAt).toISOString() });
37
+}
38
+
39
export function createThreadNotificationGate<Key>(
40
notify: (key: Key, kind: ThreadNotificationKind) => void,
41
) {
@@ -64,17 +84,18 @@ export function createThreadNotificationGate<Key>(
84
key: Key,
85
prior: ThreadNotificationObservation | undefined,
86
next: ThreadNotificationObservation,
67
- options: { readonly archived: boolean; readonly quiet: boolean },
87
+ options: { readonly archived: boolean; readonly quiet: boolean; readonly snoozed: boolean },
88
): void {
89
// The grace survives updates that keep the wake's completion; anything else cancels it.
90
const pending = releases.get(key);
71
- if (pending?.at === next.completedAt && !options.archived && !options.quiet) {
91
+ const silenced = options.archived || options.quiet || options.snoozed;
92
+ if (pending?.at === next.completedAt && !silenced) {
93
if (pending.timer === undefined) release(key, pending.at);
94
return;
95
}
96
cancel(key);
76
- // The first sighting, archived threads, and stopped or silent runs never notify completion.
77
- if (!prior || options.archived || options.quiet) skip(key, next.completedAt);
97
+ // The first sighting, archived or snoozed threads, and stopped or silent runs never notify completion.
98
+ if (!prior || silenced) skip(key, next.completedAt);
99
const fresh = attend(key, prior, next);
100
if (!prior || options.archived) return;
101
if (fresh) {
apps/web/src/components/ThreadNotificationCoordinator.tsx
+3
@@ -35,6 +35,7 @@ import { resolveBackgroundThreadRequest } from "./backgroundThreadAnnouncement";
35
import { resolveSidebarThreadStatus, type SidebarThreadStatus } from "./Sidebar.logic";
36
import {
37
createThreadNotificationGate,
38
+ isSnoozedForNotification,
39
type ThreadNotificationKind,
40
type ThreadNotificationObservation,
41
} from "./ThreadNotificationCoordinator.logic";
@@ -300,10 +301,12 @@ export function startThreadNotifications(
301
entry.reconnecting = false;
302
entry.previous = next;
303
entry.gate.retain(new Set(next.keys()));
304
+ const now = Date.now();
305
for (const [prior, state] of changed) {
306
entry.gate.observe(state.thread.id, prior, state, {
307
archived: state.thread.archivedAt !== null,
308
quiet: state.raw.latestRunStopRequested === true,
309
+ snoozed: isSnoozedForNotification(state.thread, state.completedAt, now),
310
});
311
}
312
};