Skip to content

Commit 14c1156

Browse files
saphidclaude
andcommitted
fix(client): mark unread sticks on a thread reopened within ten minutes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f6503f0 commit 14c1156

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/client-runtime/src/state/threadVisits.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ it("keeps a mark-unread on the open thread until new activity lands", () => {
111111
expect(t.visits.slice(1)).toEqual([{ threadId: t.ref.threadId, visitedAt: at(30) }]);
112112
});
113113

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+
114127
it("keeps mark unread sticky after an expired wake is retired", () => {
115128
using t = setup("thread-unread-retired-wake", {
116129
updatedAt: at(10),

‎packages/client-runtime/src/state/threadVisits.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
114114
return;
115115
}
116116
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+
lastDispatchedUpdatedAt = visitedAt;
120+
return;
121+
}
118122
if (lastDispatchedUpdatedAt !== null && Date.parse(lastDispatchedUpdatedAt) >= updatedAtMs)
119123
return;
120124

0 commit comments

Comments
 (0)