[codex] fix: Support iframe preview annotations#3160
Conversation
Co-authored-by: Codex <codex@openai.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Needs human review This PR adds new iframe element picking capability to the annotation system, introducing recursive document traversal, coordinate offset handling, and a new pointer capture mechanism. Despite being labeled as a 'fix', it introduces significant new user-facing behavior that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
Summary
Root cause
The picker listened for pointer events and used
document.elementsFromPointonly in the top document. Pointer events over iframe content were delivered to the frame instead, so the top picker never saw the interaction and could not show the selection editor for elements inside same-origin/srcdoc iframes.Impact
Preview annotations can now select elements inside accessible same-origin/srcdoc iframes while preserving a single top-frame toolbar/editor and the existing preview webview security preferences. Drawing and region workflows still operate from the top overlay, including over iframe areas.
Videos
issue-3141-before.mp4
issue-3141-after.mp4
Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp run --filter @t3tools/desktop typecheckPATH="$HOME/.vite-plus/bin:$PATH" vp run --filter @t3tools/desktop testPATH="$HOME/.vite-plus/bin:$PATH" vp checkPATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckvp checkreports the repository's existing unrelated warnings and no errors.Closes #3141
Note
Fix preview annotation tool to support element picking and selection inside iframes
pickFromDocument, which walkselementsFromPointrecursively into same-origin iframes, translating coordinates to top-level viewport space.getDocumentViewportOffsetandgetElementViewportRectto produce viewport-aligned rects for elements nested inside frames, used throughout selection, hover, marquee, and submit flows.captureSurfaceoverlay that owns pointer capture, preventing event leakage to the page.onPointerCancelhandling and explicit pointer capture release to avoid stuck interaction states.Macroscope summarized 079eca4.
Note
Medium Risk
Large preload-only change to pointer routing and cross-document geometry; incorrect offsets or frame traversal could misalign screenshots/selections, though cross-origin access remains guarded.
Overview
Enables element picking and marquee selection inside same-origin/srcdoc iframes while keeping the annotation UI in the top document.
Hit testing now recursively walks
elementsFromPointinto accessible child frame documents, maps nested DOM rects into top-level viewport coordinates (getDocumentViewportOffset/getElementViewportRect), and uses those rects for hover/selection outlines, erase hit tests, bounds union, and capture payloads. Cross-origin frames stay opaque—the picker falls back to the iframe element when the inner document is inaccessible.Pointer handling moves from window capture listeners to a full-screen transparent
captureSurfacewith explicit pointer capture,pointercancelcleanup, and safer DOM checks (hasInlineStyle, per-documentgetComputedStyle) so iframe targets still receive consistent picker input without leaking events to the page.Reviewed by Cursor Bugbot for commit 079eca4. Bugbot is set up for automated code reviews on this repo. Configure here.