feat(screenshot): draw TV overlay refs at the page's capture scale

Merged
AL
11d ago
+87-21

Summary

Follow-up to #4635. On Tizen and webOS, screenshot --overlay-refs drew CSS px rects 1:1 on the capture. Tizen boxes came out too small and offset (1280 meta viewport, captured at 1.5×). On webOS (1280×720 app), boxes for nodes past the page edge spilled onto the padding.

 buildSnapshotState
+  captureScale carried beside viewport
 projectRectToScreenshot (overlay)
-  rects 1:1, clamped to the image
+  rects × captureScale, clamped to viewport × captureScale   # same as --crop-on

8 files, no linked issue. Scope expansion: SnapshotState.captureScale (internal). A tree without a scale keeps 1:1 boxes and is not refused.

Validation

Tested 59f385621 on bfb67d5cc; hardware ran on 851a13449, before a refactor-only amend that keeps Fallow complexity under threshold. The local registry mirror lacks packages for this lockfile, so the local runs used the #4635 worktree with this patch applied. CI validates the head.

  • vitest capture-kit, daemon/src/execution, tv-cdp: 2071/2071. Typecheck, oxlint, oxfmt, fr: clean.
  • Mutation: reverting the overlay projection fails both new tests.
  • Hardware, webOS 22 and Tizen 9.0, static fixture. Each overlayRect was compared with the element's frame found from border pixels in a plain screenshot:
    • webOS 1920×1080 app: 400×240 at (200,300) and the edge node at 80×100 match.
    • webOS 1280×720 app: both match, with 0 overlay pixels outside the page. Before the fix: edge box 300×100, 1072 pixels outside.
    • Tizen native: both match. Tizen 1280 meta viewport (visualViewport.scale 1.5): 600×360 at (300,450) and edge 120×150 at (1800,900) match. Before the fix: 400×240 at (200,300) and 300×100 at (1200,600).

Screenshots:

  • webOS 1280×720 app, edge box, before / after:
webos-720-overlay-edge-before webos-720-overlay-edge-after
  • webOS 1280×720 app, full capture with overlay:
webos-720-overlay-full
  • Tizen 1280 meta viewport, before / after:
tizen-1280-overlay-before tizen-1280-overlay-after

Risks: on a scaled Tizen page, JSON center is in screenshot px, not the CSS px that press takes.

Two-way door. Blast radius: TV plugins.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.