fix(web): quote comment box stays in view for long code lines #22126
main fromrefs/pull/22126/head·opened View on GitHubCloses #22109
Problem#
Quoting text that ends inside a code block's horizontal overflow opens the "Add an optional comment…" box off-screen. The box anchors to the last client rect of the quoted range (AssistantCitationChip.tsx, popupAnchor). For a line wider than the pane, that rect is a narrow line-end rect past the window edge. In my run it was 8px wide, and the box landed at x≈3426 in an 800px window.
Change#
AssistantCitationChip.tsx: the comment popup passessticky.ui/popover.tsx:PopoverPopupforwardsstickyto the Base UI Positioner. It didn't forward it before.
Base UI already shifts popups on the cross axis, but its default limitShift limiter keeps the popup attached to its anchor, so the box stays at the off-screen rect. Only sticky drops that limiter (useAnchorPositioning.js:181 in @base-ui/react 1.5.0). A collisionAvoidance shift like ThreadDetailsCard.tsx uses keeps the limiter, so it wouldn't help here. The anchor itself is unchanged, so a quote whose end is visible still opens under its selection.
The sideways shift of the chat column is out of scope for this PR.
Scope and approval#
#22109 is triaged and labeled accepted. The maintainer confirmed the anchoring cause: https://github.com/pingdotgg/t3code/issues/22109#issuecomment-6282940075
#17023 also edits popupAnchor in AssistantCitationChip.tsx. It keeps the same last-rect anchoring and only memoizes the anchor so bridge position updates re-anchor, so it doesn't fix this. Our change sits in the popup props and popover.tsx, away from the lines #17023 rewrites. A trial git merge-tree of its head with this branch merges cleanly.
Verification#
AssistantCitationChip.browser.test.tsx: a new real-Chromium case anchors the popup to a line-end rect past the window edge. It checks that the popup stays within0..window.innerWidth.- Without the fix:
expected 3120.515625 to be less than or equal to 414. - With the fix: all 5 tests in the file pass.
- Without the fix:
- Manual check in an isolated dev instance of this branch, in an 800px-wide window. I quoted the first line of an assistant code block whose lines run past the pane, then measured the popup with
getBoundingClientRect.main: the box is outside the window, at left 3426 and right 3746.document.documentElement.scrollWidthis 3746.

- This PR: same anchor and steps. The box sits inside the window, at left 475 and right 795.
scrollWidthis 800.
- Control, fix build only: a quote whose end is visible still opens directly under the selection.
- Not checked: the desktop app window and the right-panel-open layout.
Claude Sonnet 5.5 (xhigh) via T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
24295c43-6050-4741-8961-f062e94031cf
📥 Commits
-
Reviewing files that changed from the base of the PR and between 69ceea9dc6b4e758e3998bded7cae1535449bbfa and 0f6e822e37ee40a425bd81fe1fa9045737ccedbb.
📒 Files selected for processing: 3
-
apps/web/src/components/chat/AssistantCitationChip.browser.test.tsxapps/web/src/components/chat/AssistantCitationChip.tsxapps/web/src/components/ui/popover.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
The citation comment popup now uses sticky positioning. A browser test checks that it remains within the viewport when the cited text extends beyond the visible width of a code block.
Changes: Citation popup placement
Layer / File(s) Summary Add and verify sticky citation popup placement
apps/web/src/components/ui/popover.tsx,apps/web/src/components/chat/AssistantCitationChip.tsx,apps/web/src/components/chat/AssistantCitationChip.browser.test.tsxPopoverPopupaccepts and forwards the optionalstickyprop. The citation comment popup enables sticky positioning. A browser test checks its bounds for a citation in horizontally overflowing code.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
0f6e8-
No actionable merge-blocking risk remains for this focused positioning change.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main fix: keeping the quote comment box visible for long code lines. It uses an appropriate conventional commit format. Linked Issues check Issue #22109requires the quote comment popup to remain within the window when the cited range ends in horizontally overflowing code, while preserving normal anchoring for visible ends. `AssistantCita…Out of Scope Changes check The changes are limited to the citation comment popup prop, the shared PopoverPopupprop forwarding required by that change, related comments, and a focused browser regression test. Each change dire…Description check The pull request description includes all required sections. It clearly explains the problem, change, scope and approval, focused verification, observed results, screenshots, untested layouts, and the… Full details: Linked Issues check
-
Explanation
Issue
#22109requires the quote comment popup to remain within the window when the cited range ends in horizontally overflowing code, while preserving normal anchoring for visible ends.AssistantCitationChip.tsxpassessticky, andui/popover.tsxforwards it toPopoverPrimitive.Positioner. The added Chromium test verifies an off-screen final range rect and asserts popup bounds withinwindow.innerWidth. The PR also reports a visible-end control check. The reported chat-column sideways shift is explicitly outside this PR's stated scope.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to the citation comment popup prop, the shared
PopoverPopupprop forwarding required by that change, related comments, and a focused browser regression test. Each change directly supports issue#22109. No unrelated product behavior is changed.
Full details: Description check
-
Explanation
The pull request description includes all required sections. It clearly explains the problem, change, scope and approval, focused verification, observed results, screenshots, untested layouts, and the agent attribution. The description also identifies the out-of-scope behavior.
-
✨ Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
0f6e822Macroscope's review found this PR approvable — This is a narrowly scoped web UI bug fix that forwards an optional Base UI positioning prop and enables it only for citation comment popups. Existing popover callers are unchanged, and a browser regression test covers the off-screen long-code-line case.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).