Skip to content

[codex] fix: Support iframe preview annotations#3160

Open
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:fix/preview-iframe-annotation-picker
Open

[codex] fix: Support iframe preview annotations#3160
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:fix/preview-iframe-annotation-picker

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keeps the preview annotation picker running only in the top document, but adds a transparent capture surface so iframe areas still deliver picker pointer input.
  • Adds same-origin/srcdoc iframe-aware hit testing and viewport-rect translation for hover outlines, selected outlines, marquee selection, erasing, screenshot crop rects, and capture payloads.
  • Leaves cross-origin iframes conservative: inaccessible frames are treated as the iframe element/region surface instead of claiming inner DOM access.
  • No tests were added; this stays scoped to the preload implementation.

Root cause

The picker listened for pointer events and used document.elementsFromPoint only 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 typecheck
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run --filter @t3tools/desktop test
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck
  • Manual Xvfb/Electron smoke fixture covering top-document selection, top-document drawing, iframe-area drawing, and srcdoc iframe button selection.

vp check reports the repository's existing unrelated warnings and no errors.

Closes #3141

Note

Fix preview annotation tool to support element picking and selection inside iframes

  • Adds cross-frame picking via pickFromDocument, which walks elementsFromPoint recursively into same-origin iframes, translating coordinates to top-level viewport space.
  • Introduces getDocumentViewportOffset and getElementViewportRect to produce viewport-aligned rects for elements nested inside frames, used throughout selection, hover, marquee, and submit flows.
  • Replaces window-level pointer listeners with a dedicated transparent captureSurface overlay that owns pointer capture, preventing event leakage to the page.
  • Adds onPointerCancel handling and explicit pointer capture release to avoid stuck interaction states.
  • Risk: cross-origin iframes are silently skipped; same-origin frame traversal adds DOM walking overhead proportional to frame nesting depth.

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 elementsFromPoint into 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 captureSurface with explicit pointer capture, pointercancel cleanup, and safer DOM checks (hasInlineStyle, per-document getComputedStyle) 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.

Co-authored-by: Codex <codex@openai.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 919b6f83-7e58-42ad-bf6b-1aef3e96a44d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jun 19, 2026
@StiensWout StiensWout marked this pull request as ready for review June 19, 2026 09:56
@macroscopeapp

macroscopeapp Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: preview annotation element picker does not work inside iframes

1 participant