@devries-cameron20 / t3code-1 / commits / 480eb8d219
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(client): mark unread sticks on a thread reopened within ten minutes (#29814)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 23:37 UTC 480eb8d219a5103b84c029cd32ee31819e028e2b
2 files changed +25 -1
packages/client-runtime/src/state/threadVisits.test.ts
+19
@@ -111,6 +111,25 @@ it("keeps a mark-unread on the open thread until new activity lands", () => {
111 expect(t.visits.slice(1)).toEqual([{ threadId: t.ref.threadId, visitedAt: at(30) }]);
112 });
113
114 +it("keeps a mark-unread on a read thread reopened within the open dedupe window", () => {
115 + using t = setup("thread-unread-reopened", {
116 + updatedAt: at(10),
117 + lastVisitedAt: at(10),
118 + latestRun: { completedAt: at(9) },
119 + });
120 + claimThreadOpen(environmentId, t.ref.threadId, Date.UTC(2026, 0, 1));
121 + t.mount();
122 + t.update({ lastVisitedAt: at(8) });
123 + vi.advanceTimersByTime(VISIT_DISPATCH_THROTTLE_MS);
124 + expect(t.visits).toEqual([]);
125 +
126 + // An authoritative snapshot can briefly replace the row with an older one.
127 + t.update({ updatedAt: at(5), lastVisitedAt: at(5), latestRun: { completedAt: at(4) } });
128 + t.update({ updatedAt: at(10), lastVisitedAt: at(8), latestRun: { completedAt: at(9) } });
129 + vi.advanceTimersByTime(VISIT_DISPATCH_THROTTLE_MS);
130 + expect(t.visits).toEqual([]);
131 +});
132 +
133 it("keeps mark unread sticky after an expired wake is retired", () => {
134 using t = setup("thread-unread-retired-wake", {
135 updatedAt: at(10),
packages/client-runtime/src/state/threadVisits.ts
+6 -1
@@ -114,7 +114,12 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
114 return;
115 }
116 const lastVisitedAtMs = shell.lastVisitedAt ? Date.parse(shell.lastVisitedAt) : NaN;
117 - if (!Number.isNaN(lastVisitedAtMs) && lastVisitedAtMs >= updatedAtMs) return;
117 + if (!Number.isNaN(lastVisitedAtMs) && lastVisitedAtMs >= updatedAtMs) {
118 + // Already seen, so a later mark-unread stays sticky even when no open was sent.
119 + if (lastDispatchedUpdatedAt === null || Date.parse(lastDispatchedUpdatedAt) < updatedAtMs)
120 + lastDispatchedUpdatedAt = visitedAt;
121 + return;
122 + }
123 if (lastDispatchedUpdatedAt !== null && Date.parse(lastDispatchedUpdatedAt) >= updatedAtMs)
124 return;
125