Repository navigation
fix(browser): keep the annotation composer off the element it annotates - #26596
Conversation
Placement only measured the gap below the target, so a tall target or a short pane sent the card to a side with no room and Radix slid it back over the selection.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (9)
💤 Files with no reviewable changes (6)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe browser annotation overlay now chooses among bottom, top, right, and left placement based on available space. The pending card uses the selected side and updates its target summary and intent controls. Geometry tests cover five placement cases. Locale entries for the standalone intent label are removed or revised. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The change moves the annotation composer so it no longer covers the selected element, and trims its height. No merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ELI5
When you comment on something in Orca's browser, the comment box used to open right on top of the thing you picked, so you could not see what you were writing about. Now it steps aside.
What Changed
Before: pick an element to annotate and, for a tall target (a table cell, a card, a quoted block) or in a browser pane under roughly 640px tall, the composer opened over the selection and hid it. Measured on the real component: a 300×300 block in a 1000×620 pane was 92% covered.
After: the composer takes a side with room for it. Same case, 0% covered — the card moves to the right of the block and the selection stays visible.
Mechanism.
getBrowserOverlayAnchoronly ever measured the gap below the target. When that came up short it namedtopwithout checking that above had room either. Radix's popper runsshift({ mainAxis: true, crossAxis: false })with no limiter, so a card too tall for the side it was given gets slid back inside the pane — onto the anchor. We were handing Radix an impossible instruction, and it resolved it the only way it can.Placement now measures all four gaps and takes one that actually fits the card, preferring below → above → right → left. When the named side fits,
shiftandfliphave nothing to correct and never fire, so the card cannot be moved onto the target. The guarantee is that we stop creating the collision, not that we handle it better.Two supporting changes:
Why
The honest fix is at the layer that owns the decision. Patching around Radix — re-nudging the card after it lands, or stacking guards — leaves the same wrong promise in place.
Two alternatives were implemented and measured, and both are worse:
Both avoid the target by leaving the viewport, so the fallback deliberately keeps Radix's collision handling: when a pane genuinely cannot host the card beside the target, covering part of a selection that cannot be cleared beats an unreachable composer. That trade-off is written into the code comment.
Linked Issue
Fixes #26475
Visual Proof
Testing
Measured against the real
PendingBrowserAnnotationCardrendered in a browser, not a mockup:A sweep of ~1500 pane/target combinations through the real
@floating-ui/domwith Radix's exact middleware config: 448 avoidable overlaps before, 0 after. "Avoidable" means a placement existed that would not have covered the element. The rest are panes with no band large enough for the card on any side; those overlap under the old code too, and no worse now.To reproduce by hand: open a page with a table or card layout in the browser pane, press ⌘⇧C (macOS) or Alt+Shift+N, and pick a tall element. Whether it reproduces depends on where the element sits in the pane when you click, not on which element you pick.
Renderer-only geometry, no platform branches, no execution-host involvement, nothing persisted or sent over the wire —
BrowserOverlayAnchoris renderer-local. Tested on macOS.Five cases added for the placement decision in
browser-annotation-geometry.test.ts. Final on-screen card bounds are not asserted there — that suite runs in node with no layout engine, which is why the bounds above were measured in a browser instead.AI Disclosure
Review
Agent skill upstream boundary
Notes
No security, SSH/remote, mobile, backwards-compatibility or performance surface: this is renderer-local geometry plus markup inside one popover. The orphaned
Intentcatalog key is removed from all six locales so it does not ship in the boot bundle.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm testpass locally on a fresh rebase ontoorigin/main;pnpm buildleft to CI