GeezerVison is showing github.com — fix(client-runtime): do not count a background thread mount as an open by saphid · Pull Request #44689 · pingdotgg/t3code
Conversation
Problem
Mounting a thread in a background or unfocused window (viewingAtom = false) immediately calls claimThreadOpen, which adds the thread to local search recents and consumes its 10-minute server open dedupe claim. If that view unmounts before receiving focus, a subsequent visible mount within 10 minutes also fails to send { opened: true } to the server.
Deterministic repro on origin/main (a91808a108efa4ff121d29c80ddab72c4699d980):
In packages/client-runtime/src/state/threadVisits.test.ts, mount createThreadVisitTracker with viewingAtom = Atom.make(false), a fresh thread ID, and lastVisitedAt === updatedAt, read threadSearchSubject(shell, null).opens, unmount, then mount a visible tracker (viewingAtom = Atom.make(true)) for the same thread ID.
- Observed on
origin/main: opens changes from null to { score: 1, picks: [], openedAt: <mount time> } during the hidden mount, and the subsequent visible mount sends [] (no { opened: true } visit).
- Expected: The hidden mount leaves
opens as null and does not consume the dedupe claim; the first visible mount updates opens and sends one { threadId, visitedAt, opened: true } visit.
Change
Defer claimThreadOpen in packages/client-runtime/src/state/threadVisits.ts until onShell observes viewingAtom as truthy (or when no viewingAtom is provided), claiming once on the first visible observation before requiring a loaded shell so existing visible-before-shell behavior is preserved.
Surface check: createThreadVisitTracker is shared by Web/Desktop (apps/web/src/components/chat/ThreadVisitWatermark.tsx, which passes documentViewedAtom) and Mobile (apps/mobile/src/features/threads/ThreadDetailScreen.tsx, which omits viewingAtom and keeps immediate open-on-mount behavior). No contract, server, or i18n changes are needed.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
- Base failure (
a91808a108efa4ff121d29c80ddab72c4699d980): vp test run packages/client-runtime/src/state/threadVisits.test.ts -t "does not record a background mount" failed with AssertionError: expected { score: 1, picks: [], openedAt: 1767225600000 } to be null.
- Head passes (2/2 consecutive runs):
vp test run packages/client-runtime/src/state/threadVisits.test.ts passed 18/18 tests on both consecutive runs.
- Changed-files gate:
vp run check:changed exited 0 (format, lint, knip 1/2 & 2/2, typecheck across 7 packages, and affected tests all green).
- Before/after transcript: https://gist.github.com/saphid/58765e73488c9dd7ef40be4d38731c98
- Not shown: End-to-end Electron/browser focus transitions and Mobile runtime (verified at the shared
createThreadVisitTracker unit layer; ThreadVisitWatermark already wires documentViewedAtom directly into viewingAtom).
Authored by Gemini 4 Neon (Antigravity); reviewed by Gemini 4 Neon (Antigravity).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 28, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Important
Review skipped
Review was skipped as selected files did not have any reviewable changes.
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between eac7ad0 and 1f90c41.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review.
Walkthrough
-
The thread visit tracker now claims an open on its first viewing observation. If the shell is unavailable, the claim remains pending until the shell arrives, when the tracker dispatches the visit with opened: true. Tests cover hidden mounts and visibility changes.
Changes: Thread Visit Visibility
| Layer / File(s) |
Summary |
Visibility-gated open handling packages/client-runtime/src/state/threadVisits.ts, packages/client-runtime/src/state/threadVisits.test.ts |
The tracker claims an open on the first viewing observation, even if the shell is unavailable. It retains the pending claim and dispatches the visit with opened: true when the shell arrives. Tests verify behavior for hidden mounts and visibility changes. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: juliusmarminge
Merge Risk: Minimal · previous review eac7a
-
Background or unfocused thread mounts no longer record a thread as opened or consume the server dedupe claim. Mobile behavior is unchanged. No merge-blocking risk was identified in the changed code. The author reports that end-to-end focus transitions were not tested.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the fix and its scope: a background thread mount no longer counts as an open in client-runtime. The raw summary confirms the tracker now defers claiming a thread open until the thread … |
| Description check |
 |
The description follows the template's sections: Problem, Change, Scope, and Verification. It gives a deterministic repro, names the changed behavior, and links a before/after transcript. It states th… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the fix and its scope: a background thread mount no longer counts as an open in client-runtime. The raw summary confirms the tracker now defers claiming a thread open until the thread is first observed as viewed. The title is specific, follows conventional commit form, and matches the changeset.
Full details: Description check
-
Explanation
The description follows the template's sections: Problem, Change, Scope, and Verification. It gives a deterministic repro, names the changed behavior, and links a before/after transcript. It states the Scope rationale for omitting an issue. Verification lists a base failure, passing head runs, and a changed-files gate. It also states what was not checked: end-to-end Electron/browser focus transitions and the Mobile runtime. The template's agent-attribution line is present. The description does not link the issue or a maintainer request, but it explains why none is needed. The 'Scope' section says the fix is small and obvious but does not cite a CONTRIBUTING.md rule beyond the author's reference. It is mostly complete.
Finishing Touches
-
Generate unit tests (beta)
-
Fix failing CI checks
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 84ae5dc and eac7ad0.
Files selected for processing: 2
-
packages/client-runtime/src/state/threadVisits.test.ts
packages/client-runtime/src/state/threadVisits.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The automated pipeline stopped on this pull request and will not merge it:
the capture was not run as reported, so nothing is shown either way:
Seed Alpha and Beta. Open Alpha and wait for its open frame. Open a second tab in the same window and verify the app reports hidden and unfocused. Invoke the sidebar navigation handler for Beta, wait for its message view, then return to Alpha. Reactivate the app tab, open Beta visibly, then switch Alpha → Beta again within ten minutes. Capture visit-frame counts. In the final comparison, both sides had already sent one Beta open before scripted tab reactivation, so the reported background-only mount was not reliably established.
It stays open for a person to finish or close.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
takeover:blocked
Takeover blocked; reason in the PR body
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|