@devries-cameron20 / t3code Mirror · read-only / commits / 264969317c
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 17:00 UTC

fix(client): a thread opened before its shell loads still counts as opened (#25133)

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

Julius Marminge committed Oct 25, 2026 at 16:24 UTC 264969317c48e5cffcdcbf1e60d46bf84cf7af56
2 files changed +12 -8
packages/client-runtime/src/state/threadVisits.test.ts
+7 -2
@@ -130,13 +130,18 @@ it("drops a pending visit when the thread is no longer viewed", () => {
130 expect(t.visits).toHaveLength(1);
131 });
132
133 -it("records the open while the thread is shown before its shell arrives", () => {
133 +it("sends the open with the first visit when the shell arrives after the thread is shown", () => {
134 using t = setup("thread-shell-missing", null);
135 t.mount();
136 expect(claimThreadOpen(environmentId, t.ref.threadId, Date.UTC(2026, 0, 1))).toBe(false);
137 + expect(t.visits).toEqual([]);
138
139 t.update({ updatedAt: at(10), lastVisitedAt: at(0), latestRun: null });
139 - expect(t.visits).toEqual([{ threadId: t.ref.threadId, visitedAt: at(10) }]);
140 + expect(t.visits).toEqual([{ threadId: t.ref.threadId, visitedAt: at(10), opened: true }]);
141 +
142 + t.update({ updatedAt: at(10), lastVisitedAt: at(10) });
143 + vi.advanceTimersByTime(VISIT_DISPATCH_THROTTLE_MS);
144 + expect(t.visits).toHaveLength(1);
145 });
146
147 it("advances the watermark to a wake without waiting for the throttle", () => {
packages/client-runtime/src/state/threadVisits.ts
+5 -6
@@ -56,7 +56,7 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
56 return Atom.make((get) => {
57 const registry = get.registry;
58 // Showing the thread is the open, whether or not its shell has arrived;
59 - // the shell only decides whether the server hears about it now.
59 + // the shell only decides when the server hears about it.
60 // Recorded even when the server cannot take opens, so recents follow
61 // it. A palette pick already sent the open with its query.
62 let openPending = claimThreadOpen(ref.environmentId, ref.threadId, Date.now());
@@ -94,10 +94,6 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
94
95 const onShell = (shell: VisitedShell | null) => {
96 clearTimer();
97 - // Only a shell present when the thread is shown carries the open; one
98 - // that arrives later is an ordinary visit.
99 - const opened = openPending;
100 - openPending = false;
97 if (shell === null) return;
98
99 const shellUpdatedAtMs = Date.parse(shell.updatedAt);
@@ -110,7 +106,10 @@ export function createThreadVisitTracker(options: ThreadVisitTrackerOptions) {
106 options.markLocalVisit?.(ref, visitedAt);
107 return;
108 }
113 - if (opened) {
109 + // The open rides on the first visit the server hears, however late
110 + // the shell arrives, so it still counts toward search ranking.
111 + if (openPending) {
112 + openPending = false;
113 dispatch(shell, visitedAt, true);
114 return;
115 }