Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): the Cite button comes back once the timeline stops scrolling #15818

MergedMnigos(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/15818/headmerged by juliusmarminge View on GitHub

Fixes #15700.

Scrolling an assistant text selection permanently dismissed Cite. Temporarily hide the toolbar during scrolling, then re-read the selection 150 ms after scrolling settles. Restore it at the current text anchor when selected text is visible. Escape remains dismissed until a new gesture; held selection drags and the terminal’s default context-menu behavior are preserved.

Only the assistant toolbar opts in. Visibility uses the shared intersection of the timeline and each selected text fragment’s clipping ancestors, including horizontal code scrolling and selections across blocks. It runs on selection reads and settled scrolling, using the observer’s existing timer.

Rebuilt from @Mnigos’s #15818, preserving contributor commits and merging main. Replaced ten added test cases with three combined behavioral cases; corrected independent-overlap and common-ancestor-only clipping checks.

Validation: 42 → 35 tests in apps/web/src/lib/selectionActions.test.ts, including all 32 main cases unchanged. All pass. Negative controls fail on missing scroll restoration, horizontal clipping, and disjoint clipping intersections. Targeted lint/format and web typecheck pass. Round one: Sol found no defects; Opus found a non-selectable code-header fragment could falsely restore Cite. Round two found navigation keys could undo Escape before a scroll; reproduced and fixed by separating restoration eligibility from the keyboard-selection latch. Both fixes have unit/live proof. The third full independent review round was clear on both Claude Opus 5.5 and GPT-6 Sol; both independently reran all 35 tests.

Linux browser verification used the same isolated synthetic timeline, 1280×800 viewport, selected text and scroll offsets for pinned main and the rebuilt head. Selection/pointer/key events were scripted; the DOM scrolls were real. Cite hides during scroll, returns at its new position after settling, stays hidden offscreen, and returns when the same selection comes back. Also verified horizontal code clipping and partial visibility, a selection spanning prose and clipped code (including a visible non-selectable header), Escape during a pending restore and later keyboard scrolling, real text reselection re-arming restoration, release after held-drag autoscroll, and the real Cite button inserting the expected quote into the composer. No message was sent.

Before — the selection remains but Cite does not return:

Before: selected assistant text without Cite after scrolling

Before recording

After — Cite returns at the current text position after scrolling settles:

After: Cite restored beside the same selected text

After recording

Limits: physical mouse selection, trackpad momentum, live provider output, Electron native menus, macOS, Windows, Safari/Firefox, iOS, Android, and a second remote client were not run. Terminal compatibility is covered by the existing observer tests and unchanged default opt-in, not a live native-menu check. Collapsed-table-specific disjoint clipping and horizontal-only lane clipping have geometry/source evidence, not a live table fixture. Native mobile has no toolbar change. This takeover does not merge the PR.

Implementation and verification: GPT-6.1 Sol in the Codex harness through T3 Code; tests GPT-6 Astra; independent reviews Claude Opus 5.5 and GPT-6 Sol.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 102c3dd

      Macroscope's review found this PR approvable — This is a contained web bug fix that restores the existing Cite button after scrolling, with nested clipping and dismissal behavior handled in the assistant selection path only. The shared observer remains backward-compatible by default, and the new interaction cases are covered by focused tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: a2a46dd7-cb97-45e7-87cf-17cf7624a456
      📥 Commits

      Reviewing files that changed from the base of the PR and between fe417dff4cdc149d6873bb4fbaaa388731628d0b and 4a78be186a7c73cc52d35dbca6f4cc08f1f889e6.

      📒 Files selected for processing (3)
      • apps/web/src/components/chat/AssistantSelectionToolbar.tsx
      • apps/web/src/lib/selectionActions.test.ts
      • apps/web/src/lib/selectionActions.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

      📝 Walkthrough

      Selection actions now support visibility checks against clipping bounds and optional restoration after scrolling settles. The assistant selection toolbar enables restoration and clears when the selected range is not visible.

      Changes: Selection toolbar behavior

      Layer / File(s)Summary
      Check selection visibility against clipping bounds
      apps/web/src/lib/selectionActions.ts, apps/web/src/components/chat/AssistantSelectionToolbar.tsx, apps/web/src/lib/selectionActions.test.ts
      isSelectionRectVisible requires positive width and overlap with every clipping rectangle. The toolbar clears when the selection is outside the viewport or a clipping ancestor. Tests cover fully clipped, edge-touching, zero-width, and partially clipped selections.
      Restore selection actions after scrolling
      apps/web/src/lib/selectionActions.ts, apps/web/src/components/chat/AssistantSelectionToolbar.tsx, apps/web/src/lib/selectionActions.test.ts
      observeSelectionActions accepts an optional restoreAfterScroll setting. When enabled, it schedules restoration after a 150 ms delay unless actions were dismissed. The toolbar enables this setting. Tests cover restoration, Escape dismissal, and teardown.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 4a78b

      The Cite button now returns after the timeline stops scrolling, and the terminal drawer's behavior is unchanged. No merge-blocking issue was found.

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Linked Issues checkPassedIssue #15700 requires the Cite action to return after scrolling settles when the selected assistant text remains visible, stay hidden when it is out of view, and return when it becomes visible again. …
      Out of Scope Changes checkPassedAll changes support issue #15700. The observer option limits the behavior change to AssistantSelectionToolbar; the visibility helper handles clipped selections exposed by restoration; and the tests …
      Title checkPassedThe title clearly and concisely describes the main fix: restoring the Cite button after timeline scrolling stops.
      Description checkPassedThe description explains the problem, implementation, scope, linked issue, verification results, screenshots, recordings, and untested limitations. It provides sufficient detail for review, although i…
      Full details: Linked Issues check

      Explanation

      Issue #15700 requires the Cite action to return after scrolling settles when the selected assistant text remains visible, stay hidden when it is out of view, and return when it becomes visible again. AssistantSelectionToolbar opts into restoration, and observeSelectionActions re-reads the selection 150 ms after the last scroll with no pointer. The toolbar rechecks the assistant selection and intersects its rectangle with the timeline and overflow-clipping ancestors. Added tests cover settled-scroll restoration, Escape dismissal, teardown, and visibility. The default behavior remains unchanged for other observer users.

      Full details: Out of Scope Changes check

      Explanation

      All changes support issue #15700. The observer option limits the behavior change to AssistantSelectionToolbar; the visibility helper handles clipped selections exposed by restoration; and the tests cover the new behavior. The diff does not change the terminal drawer.

      Full details: Description check

      Explanation

      The description explains the problem, implementation, scope, linked issue, verification results, screenshots, recordings, and untested limitations. It provides sufficient detail for review, although it does not reproduce the template headings exactly and does not state explicit maintainer approval.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one as maintainer for batch settings-theme-02. I will preserve your commits, merge current main, minimize the regression coverage, and verify the Cite selection behavior in an isolated client. I will leave it unmerged.

    7. juliusmarminge merged thiscd8c2c5

    8. juliusmarminge closed this

Sign in to join this conversation.