Skip to content

fix(browser): keep the annotation composer off the element it annotates - #26596

Merged
brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:keep-composer-off-selected-element
Oct 8, 2026
Merged

brennanb2025 merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:keep-composer-off-selected-element

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

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. getBrowserOverlayAnchor only ever measured the gap below the target. When that came up short it named top without checking that above had room either. Radix's popper runs shift({ 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, shift and flip have 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:

  • The old height constant said the card was 330px when it rendered at 276, so the "no room below" branch fired ~54px earlier than it needed to.
  • The card lost its truncated selector line (unreadable at popover width, now a tooltip) and the redundant "Intent" label above a toggle that already says Change / Question. 276px → 237px, which is part of why it now fits beside a target. This is also the "feels crowded" half of the issue.

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:

  • Anchor to the full target rect instead of a point. In the degenerate case it reaches 0% overlap by putting 227px of a 237px card outside the pane. The textarea and the Add button end up off-screen.
  • Turn off collision handling in the fallback. Same outcome, 228px outside the pane.

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

image

Testing

Measured against the real PendingBrowserAnnotationCard rendered in a browser, not a mockup:

scenario (1000×620 pane) before after
small element, room below below, 0% covered below, 0% covered
small element near pane bottom above, 0% covered above, 0% covered
tall element, no vertical room bottom, 91.8% covered right, 0% covered
small element, 1000×460 pane bottom, 31.3% covered right, 0% covered
element fills the pane 18.4% covered 15.8% covered

A sweep of ~1500 pane/target combinations through the real @floating-ui/dom with 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 — BrowserOverlayAnchor is renderer-local. Tested on macOS.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No security, SSH/remote, mobile, backwards-compatibility or performance surface: this is renderer-local geometry plus markup inside one popover. The orphaned Intent catalog key is removed from all six locales so it does not ship in the boot bundle.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test pass locally on a fresh rebase onto origin/main; pnpm build left to CI

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.
@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 8, 2026 15:11
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 779ee554-404e-4fed-9a31-4b1e0ff9a777
📥 Commits

Reviewing files that changed from the base of the PR and between 907cb6e and bda19ca.

📒 Files selected for processing (9)
  • src/renderer/src/components/browser-pane/annotate/pending-browser-annotation-card.tsx
  • src/renderer/src/components/browser-pane/describe-page/browser-annotation-geometry.test.ts
  • src/renderer/src/components/browser-pane/describe-page/browser-annotation-geometry.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
💤 Files with no reviewable changes (6)
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/i18n/locales/ko.json

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

Walkthrough

The 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 bda19

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping the browser annotation composer away from the annotated element.
Description check ✅ Passed The description is complete and relevant. It covers the user impact, implementation, rationale, alternatives, linked issue, visual proof, testing, scope considerations, and checklist. It also records …
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit 23fd5e6 into stablyai:main Oct 8, 2026
43 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Web annotation composer obscures selected elements

2 participants