Skip to content

fix(browser): annotation card and outline follow the picked element - #27875

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/browser-annotation-live-rect
Oct 12, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/browser-annotation-live-rect

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​821 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​808
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​396 $\color{#cf222e}{\Huge{\mathbf{−}}}$​137 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​259

ELI5

Review status at 7e1151dd: code fixes and CI checks pass; final rendered qualification remains open. The review validation below records the hidden-frame discrepancy and unverified flows.

In the browser pane you can pick an element on a web page and write a note about it. A note card opens beside the element and a white outline marks it. Until now Orca measured the element only once, at the click. If you then scrolled, resized or zoomed, the white outline stayed where the element used to be, and the card stayed anchored to that old spot too. Now both keep following the element.

What Changed

What you saw before (still true on main after #26596):

  • Scroll the page, or a scrollable box inside the page, while the card is open: the white outline stays where the element was on screen and points at empty space.
  • Resize the window or the browser pane (for example open a sidebar), or zoom the page with Cmd/Ctrl +: the card stays anchored to where the element used to be (it was only pushed back inside the pane), and the outline stays put.
  • Cause: the page script stops tracking the element at the click (freezeHighlight()), and the app placed the card from the click-time position minus the window's scroll. Scrolling inside a box doesn't change the window's scroll, and resize/zoom/layout changes were never seen.

What you see now: the outline and the card move together with the element on page scroll, scrolling inside a box, window/pane resize, page zoom and size changes of the element itself.

How:

  1. Outline. After the click, the page script keeps re-measuring the selected element on scroll (listening in the capture phase, so scrolling inside any box counts), on resize, and on size changes of the element (a ResizeObserver), batched to one update per animation frame, and redraws the outline from that.
  2. Card. The card needs the same live position, but the app window can't measure an element inside the web page. The existing viewport bridge (the small script Orca already runs in the page to report scrolling) now also measures the selected element and reports its live box. It finds the element through a marker attribute the page script puts on the selection when you click and removes when the selection ends. The app uses that live box instead of "click-time position minus scroll", converted from page pixels to pane pixels by the ratio of the pane's width to the page's own width, so page zoom is handled too. Before the first report arrives the card uses the click-time position, as before.
  3. Which side the card opens on now uses the card's measured height; the old fixed estimate (240px) is only used for the very first frame, before the card has rendered.

Why

This is the common pattern for an element picker: whatever can see the element re-measures it live (scroll in the capture phase, resize, size changes) and both the outline and the card follow that one measurement; the card's side is chosen from its real size, with an assumed size only before the first measurement.

Choices and alternatives:

  • Marker attribute as the link between the page script and the bridge. The bridge runs in an isolated script context so the page can't read the per-tab token that authenticates its messages, and an isolated context can't see the page script's objects; both share the page's DOM, so an attribute on the selected element is the simplest link. Sending the position from the page script itself would have exposed that token to the page. A page could move the attribute to another element, but it controls its own layout anyway, so the worst case is the card pointing where the page wants, as it already could.
  • Measured height, not width. The card's width is fixed by its CSS (22rem) and is squeezed by the side it sits on; feeding that squeezed width back into the side choice would let a slowly shrinking pane squeeze the card further and further. The height is what varies (language, font), so that is what is measured.
  • Kept Radix Popover instead of switching to floating-ui directly (the way contextual tours position with flip({fallbackPlacements})). That would mean re-implementing the popover's focus handling, Escape and outside-click dismissal for this one card. Passing the measured height into the existing side choice is a few lines and reuses everything.

Differences from the common pattern:

  • The card is drawn by the app over the page (not inside the page), so the live position has to travel from the page to the app through the bridge, one message per animation frame while a note is open. Intended: that is how Orca's card already works; drawing it inside the page would be a rewrite.
  • Saved-note badges still use their click-time position. Temporary: out of scope here; they would need the element found again from its saved description.

Out of scope:

  • Iframes: picking something inside an iframe still selects the whole iframe. Selection of an element inside the frame is outside this PR.
  • Page zoom different from the app zoom: the card position is now converted with the measured page-to-pane ratio, which is the conversion the earlier mismatch was missing. I have not re-run the exact earlier mismatch case, so treat this as likely fixed but not verified.

Remote/SSH: nothing here crosses the SSH boundary. The browser pane is a local webview in the local app; the page script, the bridge and the card all run on the local machine.

Follow-up to #26596.

Visual Proof

Hidden test apps on macOS, same static test pages in both builds. Top row = before (main 9a64866), bottom row = after (this branch). Each row is consecutive frames left to right. The blue box is the picked element; the white outline and the note card should stay on it.

Page scroll (frames: picked, then the page scrolled 100 / 200 / 300px). Before: the card already followed window scroll, but the outline stays behind (100 → 300px off). After: the outline stays on the element.

f1-page-scroll-before-after.png

Scrolling a box inside the page (box scrolled 60 / 120 / 180px). Before: the outline and the card both stay where the element was (the card ends up 191px away). After: both stay on it, card 11px below.

f1-inner-scroll-before-after.png

Pane resize (right sidebar opened, then both sidebars, then both closed; the element is sized in % of the page, so it reflows). Before: the outline keeps the old size and position (up to 220px off) and the card drifts up to 315px off the element's center. After: both follow the reflowed element.

f2-pane-resize-before-after.png

Page zoom (Cmd + twice while the card is open, 100% → 110% → 120%). Before: the outline keeps its unzoomed size and the card ends up on top of the enlarged element. After: the outline matches it and the card stays 11px below it.

f2-page-zoom-before-after.png

Measured in every frame (card and element in the app's pixels, element mapped from the page with the page's zoom): after the fix the card's gap to the element stays 11px and the outline's offset from the element is 0 in every frame of the first three cases. In the zoom case the outline box could not be read numerically (two tabs had the same page open), so that one is judged from the images. Before the fix the gaps and offsets grow as listed above.

Final head (7e1151d): painted pixels checked in every frame

Re-run on a fresh hidden test app built from the final head. Each frame was captured twice, once as shown and once with the card hidden. The white outline was then measured from the screen pixels and compared with the element's live position. The card's painted edges came from the difference between the two captures. In every frame of every case below, and in the four cases above (page scroll, box scroll, pane resize, page zoom), the painted outline is within 1px of the element on each side and the card sits 11px from it (10.8–11.2px). The painted card matches the card the app laid out to the pixel. The frames are cropped around the element; each strip runs left to right.

Border and padding growth (picked, then the page's own script grows the element's border 2 → 10px, then its padding 10 → 18px). The outline grows with the element and the card moves down to stay 11px below it.

final-c3-border-padding.png

HTML preview (a second Orca connected to the first, so the .html file opens in the HTML preview beside its source, the same way a remote workspace's file does; picked, box scrolled 60 / 120px, then the page scrolled 80px). Same behaviour as a normal browser tab. A local .html file opens as a normal browser tab, which the cases above cover.

final-c4-paired-html-preview.png

Add (note typed, Add pressed, then the page scrolled 100px). The note is saved (one saved note with the typed text), the card closes, no errors are logged, and the saved note's badge stays on the element as the page scrolls.

final-c5-add.png

Page that already uses the selection marker attribute (the orange box comes first in the page and already carries the attribute; the clicked element carries its own value; picked, then the page scrolled 150 / 300px). The card follows the clicked element and never jumps to the orange box. After Cancel both elements have their original attribute values back.

final-c6-decoy.png

Testing

  • New src/main/browser/grab-guest-overlay-follow.test.ts: runs the real page script in a test DOM, clicks an element, then scrolls a box inside the page, resizes the window and changes the element's size, and checks the outline is redrawn at the new position each time; also checks the marker attribute is set on click and removed on teardown.

  • New src/shared/browser-annotation-viewport-live-target.test.ts: runs the real bridge script and checks it reports the marked element's live box after an inner-box scroll, a resize and a size change, and reports no box once the marker is gone.

  • browser-annotation-geometry.test.ts: the live box replaces the click-time one (inner-box scroll, pane reflow), page-zoom conversion, and the measured card height changing the chosen side.

  • Each of the 9 behaviour tests above fails with the fix reverted (checked by reverting the overlay listeners, the bridge's target report, and the geometry's use of the live box/scale/height).

  • Typecheck (web + node), check:code-quality:changed and check:react-doctor:changed pass locally.

  • I manually tested these changes locally (hidden test apps, macOS; see Visual Proof)

  • Automated tests added/updated

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

Security: the bridge's token stays in its isolated context; the only new page-visible thing is the marker attribute on the selected element while a note is open. Cross-platform: no platform-specific code. Performance: while a note card is open, one getBoundingClientRect and one message per animation frame during scroll/resize, as the bridge already did for scroll.

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, and pnpm build pass (or CI will cover; local preferred)

Review validation

The review fixed marker collisions, live coordinate handling in HTML previews, and border/padding-only size notifications. Selected elements now use ResizeObserver with box: 'border-box'; browser pages and previews share the protected report handler.

The final hidden run at 5118ec23 measured card movement after outer-box growth and scrolling, but its captured frames differ from measured card placement. Painted outline/card attachment, the HTML-preview flow and Add action remain unqualified. Final head 7e1151dd adds only the exact upstream CI line-limit repair, with annotation files unchanged. The earlier author captures above are retained; the following frames document the unresolved final-run evidence discrepancy.

Border growth, hidden CDP frame:

Hidden frame after border growth; measured card position differs from captured placement

Page scroll, hidden CDP frame:

Hidden frame after page scroll; painted attachment remains unqualified

The grab overlay keeps re-measuring the picked element after the click
(scroll in any box, resize, element size changes), and the isolated
viewport bridge reports that live box so the pending card follows it,
including page zoom. The card's side pick uses its measured height.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The grab overlay now marks the selected element and updates its outline as the element moves or resizes. The viewport bridge reports the selected element’s live rectangle and viewport width. The renderer validates matching viewport messages, updates viewport state, and uses live geometry and measured card height to place pending annotation cards. The synchronous-spawn baseline and its ratchet script also changed. The refusal resumability mapping now resides in a shared module.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 7e115

The maintenance workflow can corrupt a missing baseline; fix this small issue before or shortly after merging.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 27 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 is concise and clearly describes the main change: keeping the annotation card and outline aligned with the selected browser element.
Description check Passed The description is detailed and mostly complete. It explains the user impact, implementation, rationale, scope, visual proof, testing, compatibility considerations, and checklist status. The linked-is…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d8b93b9-c81c-423c-8e0c-f457e03cbb9a
📥 Commits

Reviewing files that changed from the base of the PR and between 7cb30b7 and 96141ae.

📒 Files selected for processing (12)
  • src/main/browser/grab-guest-overlay-follow.test.ts
  • src/main/browser/grab-guest-overlay-script.ts
  • src/main/browser/grab-guest-script.test.ts
  • src/renderer/src/components/browser-pane/annotate/browser-guest-annotate-overlays.tsx
  • src/renderer/src/components/browser-pane/annotate/pending-browser-annotation-card.tsx
  • src/renderer/src/components/browser-pane/annotate/use-browser-page-grab-annotations.ts
  • 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/components/browser-pane/host-guest/browser-page-webview-navigation-handlers.ts
  • src/shared/browser-annotation-viewport-bridge.ts
  • src/shared/browser-annotation-viewport-live-target.test.ts
  • src/shared/browser-annotation-viewport-report.ts

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

Comment on lines +125 to +143
const trackTarget = (state) => {
const current = state.target;
const next = !emitViewportMessages
? null
: current && current.isConnected && current.hasAttribute(selectedAttribute)
? current
: document.querySelector('[' + selectedAttribute + ']');
if (next !== current) {
state.target = next;
if (state.targetObserver) {
state.targetObserver.disconnect();
if (next) {
state.targetObserver.observe(next);
state.targetObserver.observe(document.documentElement);
}
}
}
return next;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '95,170p' src/shared/browser-annotation-viewport-bridge.ts
sed -n '245,290p' src/shared/browser-annotation-viewport-bridge.ts
sed -n '1,130p' src/renderer/src/components/browser-pane/annotate/guest-annotation-viewport-bridge.ts
sed -n '145,185p' src/renderer/src/components/browser-pane/annotate/use-browser-page-grab-annotations.ts

Repository: stablyai/orca

Length of output: 7088


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- bridge declarations and lifecycle ---'
rg -n -F --glob 'src/shared/browser-annotation-viewport-bridge.ts' -e 'const updateMarkers' -e 'const cleanup' -e 'const positionMarkers' -e 'export function' -e 'requestUpdate' -e 'setAnnotationViewportBridge' src/shared/browser-annotation-viewport-bridge.ts
sed -n '1,115p' src/shared/browser-annotation-viewport-bridge.ts
sed -n '115,285p' src/shared/browser-annotation-viewport-bridge.ts
printf '%s\n' '--- renderer hook and callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'syncGuestAnnotationViewportBridge' -e 'setBrowserOverlayViewport' -e 'pendingAnnotationPayload' -e 'BROWSER_GRAB_SELECTED_ATTRIBUTE' src/renderer/src src/shared
sed -n '1,240p' src/renderer/src/components/browser-pane/annotate/use-browser-page-grab-annotations.ts
sed -n '1,180p' src/renderer/src/components/browser-pane/annotate/guest-annotation-viewport-bridge.ts

Repository: stablyai/orca

Length of output: 36349


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- selected marker lifecycle ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'data-orca-grab-selected' -e 'BROWSER_GRAB_SELECTED_ATTRIBUTE' -e 'selectedAttribute' src
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'setAnnotationViewportBridge({' -e 'syncGuestAnnotationViewportBridge({' src/renderer/src/components/browser-pane
sed -n '1,260p' src/renderer/src/components/browser-pane/annotate/browser-guest-annotate-overlays.tsx
printf '%s\n' '--- webview lifecycle bridge synchronization ---'
sed -n '180,245p' src/renderer/src/components/browser-pane/host-guest/use-browser-page-webview-lifecycle.ts
sed -n '1,125p' src/renderer/src/components/browser-pane/annotate/guest-annotation-viewport-bridge.test.ts
printf '%s\n' '--- grab overlay implementation candidates ---'
rg --files src | rg 'grab.*overlay|overlay.*grab|guest.*grab'

Repository: stablyai/orca

Length of output: 19064


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- grab overlay complete lifecycle ---'
sed -n '1,190p' src/main/browser/grab-guest-overlay-script.ts
printf '%s\n' '--- bridge IPC binding and execution ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'setAnnotationViewportBridge' -e 'buildBrowserAnnotationViewportBridgeScript' src/main src/renderer src/shared
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'browserPageId' -e 'annotation viewport bridge' src/main/browser | head -80
printf '%s\n' '--- live target test scenarios ---'
sed -n '1,210p' src/shared/browser-annotation-viewport-live-target.test.ts
printf '%s\n' '--- grab follow tests ---'
sed -n '1,180p' src/main/browser/grab-guest-overlay-follow.test.ts

Repository: stablyai/orca

Length of output: 34833


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- grab controller and manager ordering ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'freezeHighlight' -e 'cleanup()' -e 'GRAB_GUEST_OVERLAY_SCRIPT' -e 'buildGuestOverlayScript' -e 'stopTrackingSelection' -e 'grabGuest' src/main src/renderer
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'awaitClick' -e 'finalize' -e 'rearm' -e 'toggle' src/main/browser src/renderer/src/components/browser-pane/annotate | head -160
printf '%s\n' '--- viewport bridge execution ---'
sed -n '1,165p' src/main/browser/browser-manager-viewport.ts
sed -n '80,150p' src/main/ipc/browser-guest-view-ipc.ts
printf '%s\n' '--- grab script entrypoint ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'grab-guest-overlay-script' -e 'grab-guest-script' src/main src/renderer

Repository: stablyai/orca

Length of output: 41605


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- report consumer ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'applyBrowserAnnotationViewportReport' -e 'parseBrowserAnnotationViewportReport' -e 'BROWSER_ANNOTATION_VIEWPORT_MESSAGE_PREFIX' src/renderer/src src/main
sed -n '150,220p' src/main/browser/browser-manager-grab-selection-scripts.ts 2>/dev/null || true
sed -n '1,150p' src/main/browser/grab-guest-selection-scripts.ts
printf '%s\n' '--- selection controller ordering ---'
sed -n '45,155p' src/main/browser/browser-grab-session-controller.ts
sed -n '1,145p' src/main/browser/browser-manager-grab.ts
printf '%s\n' '--- bridge sync effect ---'
sed -n '195,235p' src/renderer/src/components/browser-pane/host-guest/use-browser-page-webview-lifecycle.ts

Repository: stablyai/orca

Length of output: 18568


🏁 Script executed:

set -o pipefail
sed -n '175,210p' src/renderer/src/components/browser-pane/describe-page/browser-annotation-geometry.ts
sed -n '180,210p' src/renderer/src/components/browser-pane/host-guest/browser-page-webview-navigation-handlers.ts
sed -n '285,325p' src/renderer/src/components/browser-pane/host-guest/use-browser-page-webview-lifecycle.ts
sed -n '1,80p' src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-viewport-tracking.ts

Repository: stablyai/orca

Length of output: 4591


🏁 Script executed:

rg -n -F --glob '*.ts' --glob '*.tsx' -e 'annotationViewportBridgeTokenRef' -e 'annotationViewportBridgeToken' -e 'createAnnotationViewportBridge' src/renderer/src/components/browser-pane

Repository: stablyai/orca

Length of output: 2467


Invalidate viewport reports when a new grab starts.

A report from the previous selection can be emitted before its marker is removed and delivered after the renderer clears browserOverlayViewport.target. The current per-webview token remains valid, so the handler applies the old report.target before the newly scheduled report arrives. Rotate the existing bridge token on each pending-payload transition before syncing the bridge. This rejects delayed reports from the previous selection.

Suggested fix
   const annotationViewportBridgeTokenRef = useRef<string>(undefined!)
   annotationViewportBridgeTokenRef.current ??= createBrowserUuid().replaceAll('-', '')
+  const previousPendingAnnotationPayloadRef = useRef(pendingAnnotationPayload)
+  useLayoutEffect(() => {
+    if (previousPendingAnnotationPayloadRef.current === pendingAnnotationPayload) {
+      return
+    }
+    previousPendingAnnotationPayloadRef.current = pendingAnnotationPayload
+    annotationViewportBridgeTokenRef.current = createBrowserUuid().replaceAll('-', '')
+  }, [pendingAnnotationPayload])

brennanb2025 and others added 4 commits October 12, 2026 12:37
…ary (#28054)

#27756's script imported baseline helpers from check-focus-read-ratchet.mjs
after #27788 had moved them into ratchet-baseline.mjs, so it crashed on start
and failed every PR that merges main. Use the library's helpers, and record the
two daemon-process launches from #27769 that the broken check never saw.

Co-authored-by: Orca Worker <orca-worker@localhost>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3383483-15f0-4b87-aec8-6deca7db45df
📥 Commits

Reviewing files that changed from the base of the PR and between 96141ae and 4842af4.

📒 Files selected for processing (20)
  • config/main-sync-spawn-baseline.txt
  • config/scripts/check-main-sync-spawn-ratchet.mjs
  • src/main/browser/grab-guest-overlay-follow.test.ts
  • src/main/browser/grab-guest-overlay-script.ts
  • src/main/browser/grab-guest-script.test.ts
  • src/main/browser/grab-guest-selection-scripts.ts
  • src/main/ipc/browser-annotation-viewport-ipc.test.ts
  • src/main/ipc/browser-guest-view-ipc.ts
  • src/renderer/src/components/browser-pane/annotate/browser-annotation-viewport-message.ts
  • src/renderer/src/components/browser-pane/annotate/guest-annotation-viewport-bridge.test.ts
  • src/renderer/src/components/browser-pane/annotate/guest-annotation-viewport-bridge.ts
  • src/renderer/src/components/browser-pane/host-guest/browser-page-annotation-document.test.ts
  • src/renderer/src/components/browser-pane/host-guest/browser-page-webview-navigation-handlers.ts
  • src/renderer/src/components/browser-pane/workspace-doc/HtmlDocPreview.tsx
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-webview-attach.test.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-webview-attach.ts
  • src/renderer/src/components/browser-pane/workspace-doc/use-doc-preview-guest-tools.test.ts
  • src/renderer/src/components/browser-pane/workspace-doc/use-doc-preview-guest-tools.ts
  • src/shared/browser-annotation-viewport-bridge.ts
  • src/shared/browser-annotation-viewport-live-target.test.ts

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

Comment on lines +128 to +149
freezeHighlight: function(selectionId) {
host.removeEventListener('mousemove', onPointerMove);
host.style.pointerEvents = 'none';
host.style.cursor = 'default';
// Why: the outline must follow the element after the click — page and inner-box
// scroll (capture), resize/zoom and the element's own size changes.
selectedEl = currentEl;
if (!selectedEl) return;
// Why: the isolated-world viewport bridge finds the selection by this marker; it
// cannot see this world's objects, and the page must not see the bridge's token.
previousSelectedValue = selectedEl.getAttribute(selectedAttribute);
selectedValue = selectionId;
selectedEl.setAttribute(selectedAttribute, selectionId);
highlightBox.style.transition = 'none';
window.addEventListener('scroll', scheduleFrozenHighlight, true);
window.addEventListener('resize', scheduleFrozenHighlight, true);
if (typeof ResizeObserver === 'function') {
frozenResizeObserver = new ResizeObserver(scheduleFrozenHighlight);
frozenResizeObserver.observe(selectedEl);
// A scrollbar appearing narrows the page without a window resize.
frozenResizeObserver.observe(document.documentElement);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'freezeHighlight|stopTrackingSelection|awaitClick|__orcaGrab|cleanup' src/main/browser/grab-guest-overlay-script.ts src/main/browser/grab-guest-selection-scripts.ts src/main/browser/browser-grab-session-controller.ts src/main/browser/browser-manager-grab.ts
sed -n '70,175p' src/main/browser/grab-guest-overlay-script.ts
sed -n '1,120p' src/main/browser/grab-guest-selection-scripts.ts

Repository: stablyai/orca

Length of output: 11149


Clear the previous selection before a new freeze.

AWAIT_CLICK_SCRIPT calls freezeHighlight once for either the click or context-menu path, so a single selection does not repeat the call. However, the session controller can preserve the overlay after a selected or context-selected result, and a later awaitClick can run against the same __orcaGrab before cleanup. A second freeze then overwrites the previous selection state without disconnecting the earlier ResizeObserver or restoring the earlier marker.

Call stopTrackingSelection() before assigning the new selection.

Suggested fix
--- "a/src/main/browser/grab-guest-overlay-script.ts"
+++ "b/src/main/browser/grab-guest-overlay-script.ts"
@@ -125,8 +125,9 @@
     // the renderer shows the copy menu. Disabling pointer-events on the host
     // lets the cursor return to normal and prevents the crosshair from showing
     // over the dropdown menu's area in the webview.
     freezeHighlight: function(selectionId) {
+      stopTrackingSelection();
       host.removeEventListener('mousemove', onPointerMove);
       host.style.pointerEvents = 'none';
       host.style.cursor = 'default';
       // Why: the outline must follow the element after the click — page and inner-box
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
freezeHighlight: function(selectionId) {
host.removeEventListener('mousemove', onPointerMove);
host.style.pointerEvents = 'none';
host.style.cursor = 'default';
// Why: the outline must follow the element after the click — page and inner-box
// scroll (capture), resize/zoom and the element's own size changes.
selectedEl = currentEl;
if (!selectedEl) return;
// Why: the isolated-world viewport bridge finds the selection by this marker; it
// cannot see this world's objects, and the page must not see the bridge's token.
previousSelectedValue = selectedEl.getAttribute(selectedAttribute);
selectedValue = selectionId;
selectedEl.setAttribute(selectedAttribute, selectionId);
highlightBox.style.transition = 'none';
window.addEventListener('scroll', scheduleFrozenHighlight, true);
window.addEventListener('resize', scheduleFrozenHighlight, true);
if (typeof ResizeObserver === 'function') {
frozenResizeObserver = new ResizeObserver(scheduleFrozenHighlight);
frozenResizeObserver.observe(selectedEl);
// A scrollbar appearing narrows the page without a window resize.
frozenResizeObserver.observe(document.documentElement);
}
freezeHighlight: function(selectionId) {
stopTrackingSelection();
host.removeEventListener('mousemove', onPointerMove);
host.style.pointerEvents = 'none';
host.style.cursor = 'default';
// Why: the outline must follow the element after the click — page and inner-box
// scroll (capture), resize/zoom and the element's own size changes.
selectedEl = currentEl;
if (!selectedEl) return;
// Why: the isolated-world viewport bridge finds the selection by this marker; it
// cannot see this world's objects, and the page must not see the bridge's token.
previousSelectedValue = selectedEl.getAttribute(selectedAttribute);
selectedValue = selectionId;
selectedEl.setAttribute(selectedAttribute, selectionId);
highlightBox.style.transition = 'none';
window.addEventListener('scroll', scheduleFrozenHighlight, true);
window.addEventListener('resize', scheduleFrozenHighlight, true);
if (typeof ResizeObserver === 'function') {
frozenResizeObserver = new ResizeObserver(scheduleFrozenHighlight);
frozenResizeObserver.observe(selectedEl);
// A scrollbar appearing narrows the page without a window resize.
frozenResizeObserver.observe(document.documentElement);
}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/main/browser/grab-guest-overlay-script.ts (1)

128-129: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Stop the previous selection tracking before a new freeze.

The freezeHighlight function overwrites selectedEl, selectedValue, and frozenResizeObserver without releasing the earlier state. If the overlay is reused and freezeHighlight runs again, the earlier ResizeObserver stays connected. The earlier element keeps its marker attribute. Call stopTrackingSelection() at the start of the function. This is the same concern as the earlier review comment.

Proposed fix
     freezeHighlight: function(selectionId) {
+      stopTrackingSelection();
       host.removeEventListener('mousemove', onPointerMove);

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c15b635-a5b3-4dbd-8c2e-dbf8b3f0c28c
📥 Commits

Reviewing files that changed from the base of the PR and between 4842af4 and 5118ec2.

📒 Files selected for processing (5)
  • src/main/browser/grab-guest-overlay-follow.test.ts
  • src/main/browser/grab-guest-overlay-script.ts
  • src/main/browser/grab-guest-script.test.ts
  • src/shared/browser-annotation-viewport-bridge.ts
  • src/shared/browser-annotation-viewport-live-target.test.ts

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

…#28085)

#27946 and #26684 together put agent-session-failure-words.ts at 304 lines,
over max-lines, which fails lint and the pre-commit hook on every merge of
main. The refusal-code table is standalone with one reader, so it moves out.

Co-authored-by: Orca Worker <orca-worker@localhost>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Reject a missing baseline before pruning. · ratchet-baseline.mjs:162-172

config/scripts/ratchet-baseline.mjs:162-172
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Reject a missing baseline before pruning.

pruneCountBaseline treats a missing file as empty and writes a header-only baseline. The reachable --prune workflow calls prune() and then main(), so a missing baseline can be created and the subsequent count check can fail when current counts are nonzero. This violates the contract that pruning requires an existing baseline and that initialization uses --init.

Suggested fix
-  const text = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : ''
+  const text = fs.readFileSync(file, 'utf8')

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e5af2b9c-a372-44d4-9f29-0185e12d9126
📥 Commits

Reviewing files that changed from the base of the PR and between 5118ec2 and 7e1151d.

📒 Files selected for processing (2)
  • src/shared/agent-session-failure-words.ts
  • src/shared/agent-session-start-refusal-resumable.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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The white selection outline and pending note card could stay at old positions after scrolling, pane resize, zoom, or changes to the selected element’s size. The change retains the selected element, remeasures it on those events, and places the existing card from its current rectangle and measured height.

Four review rounds fixed three gaps: page-owned markers could attach the card to the wrong element; HTML previews did not handle live coordinate reports; and the observers watched content size while missing border/padding growth. Selection now uses its capture identity, browser pages and previews share the protected coordinate-report handler, and selected elements are observed with box: 'border-box'.

Regressions were demonstrated failing before the fixes. The geometry head passed 172 targeted tests and both Node/renderer TypeScript checks; a fresh reviewer passed 54 tests and found no additional high- or medium-priority issue. The exact upstream CI dependency repair passed 123 relevant tests. Final head 7e1151dd5e4391d8755fe199a73f19d12f6880b6 is CI-green: 15 successful checks, 17 skipped, zero pending or failed.

Rendered QA remains unqualified. At 5118ec23, real selection and live measurements tracked border/padding growth, scrolling, pane reflow, zoom and content size; Escape cleared the card. The hidden CDP screenshots differ from those measured card positions, so painted attachment still needs confirmation. White-outline measurements, local HTML-preview flow, text/Add and native focus were unverified; preview/Add were not attempted. The run stopped safely with unchanged real config hashes. Final head 7e1151dd changes only the upstream CI dependency after that geometry head, leaving annotation files identical.

Pure transform-only movement remains deferred. Preview drafts surviving navigation predate this PR; iframe picking and saved-note re-identification are outside scope. The named readiness-checklist skill was unavailable, so the accepted general final risk audit ran instead. The existing event-driven positioning mechanism remains in place.

@brennanb2025
brennanb2025 merged commit 1104402 into main Oct 12, 2026
32 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/browser-annotation-live-rect branch October 12, 2026 23:23
OrcaWin added a commit that referenced this pull request Oct 12, 2026
…#28110)

HtmlDocPreview.tsx reached 403 lines on main (#27608 + #27875), over the
400-line limit for .tsx, so lint and the pre-commit hook fail on any
branch that merges main. The focus handoff effect moves unchanged into
use-doc-preview-guest-focus.ts.

Co-authored-by: Orca Worker <orca-worker@localhost>
brennanb2025 pushed a commit that referenced this pull request Oct 15, 2026
…#28110)

HtmlDocPreview.tsx reached 403 lines on main (#27608 + #27875), over the
400-line limit for .tsx, so lint and the pre-commit hook fail on any
branch that merges main. The focus handoff effect moves unchanged into
use-doc-preview-guest-focus.ts.

Co-authored-by: Orca Worker <orca-worker@localhost>
(cherry picked from commit 5e83ca0)
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.

2 participants