Skip to content

Commit d68ab95

Browse files
saphidclaude
andcommitted
fix(client): an older shell row no longer lowers the handled visit watermark
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 14c1156 commit d68ab95

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ it("keeps a mark-unread on a read thread reopened within the open dedupe window"
122122
t.update({ lastVisitedAt: at(8) });
123123
vi.advanceTimersByTime(VISIT_DISPATCH_THROTTLE_MS);
124124
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([]);
125131
});
126132

127133
it("keeps mark unread sticky after an expired wake is retired", () => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
116116
const lastVisitedAtMs = shell.lastVisitedAt ? Date.parse(shell.lastVisitedAt) : NaN;
117117
if (!Number.isNaN(lastVisitedAtMs) && lastVisitedAtMs >= updatedAtMs) {
118118
// Already seen, so a later mark-unread stays sticky even when no open was sent.
119-
lastDispatchedUpdatedAt = visitedAt;
119+
if (lastDispatchedUpdatedAt === null || Date.parse(lastDispatchedUpdatedAt) < updatedAtMs)
120+
lastDispatchedUpdatedAt = visitedAt;
120121
return;
121122
}
122123
if (lastDispatchedUpdatedAt !== null && Date.parse(lastDispatchedUpdatedAt) >= updatedAtMs)

0 commit comments

Comments
 (0)