Skip to content

Commit f2fdc5a

Browse files
only21milclaude
andcommitted
fix(web): changes made while disconnected still notify after reconnect
The coordinator cleared its notification baseline whenever the shell left the live state, so a thread that finished or asked for input during a dropped connection looked new after resync and never notified. Keep the last live baseline instead; alerts raised before the drop still do not repeat. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d53873b commit f2fdc5a

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

‎apps/web/src/components/ThreadNotificationCoordinator.badge.browser.test.tsx‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,26 @@ it.each(["hasPendingApprovals", "hasPendingUserInput"] as const)(
215215
expect(notification.close).toHaveBeenCalled();
216216
},
217217
);
218+
219+
it("notifies for changes made while the environment was disconnected, once", async () => {
220+
await using app = setup();
221+
const asking = { id: "asking", hasPendingApprovals: true };
222+
state.shells.set("one", shell({ id: "working" }, { id: "asking" }));
223+
await app.render();
224+
state.shells.set("one", shell({ id: "working" }, asking));
225+
await app.render();
226+
state.shells.set("one", { ...shell({ id: "working" }, asking), status: "cached" });
227+
await app.render();
228+
const completed = {
229+
id: "working",
230+
latestTurn: { turnId: "turn", state: "completed", completedAt: "2026-09-13T07:05:00.000Z" },
231+
};
232+
state.shells.set("one", { ...shell(completed, asking), status: "synchronizing" });
233+
await app.render();
234+
state.shells.set("one", shell(completed, asking));
235+
await app.render();
236+
expect(TestNotification.sent.map(({ title }) => title)).toEqual([
237+
"Approval needed",
238+
"Thread completed",
239+
]);
240+
});

‎apps/web/src/components/ThreadNotificationCoordinator.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ function EnvironmentNotifications({
121121
const previous = useRef(new Map<ThreadId, NotificationState>());
122122

123123
useEffect(() => {
124-
if (threads === null) {
125-
previous.current.clear();
126-
return;
127-
}
124+
// Keep the last live baseline through a disconnect, so what changed meanwhile still
125+
// notifies once the shell is live again, while alerts already raised stay quiet.
126+
if (threads === null) return;
128127
const next = new Map<ThreadId, NotificationState>();
129128
const subagentRequests = pendingSubagentRequestsByThread(threads);
130129
for (const rawThread of threads) {

0 commit comments

Comments
 (0)