Skip to content

fix(cdp): scale FakeDriver viewport rects to configured target - #125

Merged
aram-devdocs merged 1 commit into
mainfrom
fix/121-fakedriver-viewport
Apr 25, 2026
Merged

fix(cdp): scale FakeDriver viewport rects to configured target#125
aram-devdocs merged 1 commit into
mainfrom
fix/121-fakedriver-viewport

Conversation

@aram-devdocs

Copy link
Copy Markdown
Owner

Summary

  • FakeDriver::snapshot already retargeted viewport/viewport_width/viewport_height per request, but the per-node rect values from PlumbSnapshot::canned() (html and body) stayed at the canned 1280×800. Multi-viewport runs against plumb-fake://hello therefore reported mobile viewports with desktop rects.
  • After this change, any node whose rect equals the canned viewport bounds (0, 0, canned_w, canned_h) is rewritten to the requested target's width/height. Captured before the field assignments so there are no magic numbers.
  • New regression test in crates/plumb-cdp/tests/snapshot_all_default.rs::fake_driver_rewrites_viewport_sized_rects_to_target requests mobile 375×667 and asserts both html and body rects come back at 375×667.

Test plan

  • cargo test -p plumb-cdp --test snapshot_all_default — both tests pass
  • cargo test -p plumb-cdp — crate suite passes
  • cargo test --workspace — workspace passes
  • cargo clippy -p plumb-cdp --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

Closes #121

🤖 Generated with Claude Code

Closes #121

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aram-devdocs
aram-devdocs merged commit c0a853a into main Apr 25, 2026
13 of 14 checks passed
@aram-devdocs
aram-devdocs deleted the fix/121-fakedriver-viewport branch April 25, 2026 20:29
aram-devdocs added a commit that referenced this pull request Apr 28, 2026
Add an end-to-end CLI regression for #121 against the JSON
formatter: `plumb lint plumb-fake://hello --viewport mobile
--format json` against a `[viewports.mobile]` config MUST emit
`"width": 375 / "height": 812` rects, not the canned desktop
`1280x800`. PR #125's fix is at the FakeDriver layer; this guards
the symptom at the layer the issue was reported (CLI + JSON).

Audit follow-up: PR #125 merged with the Claude review check
failed (SDK max-turns infrastructure error, not a code finding)
so no recorded approval verdict exists. All other gates passed.
This PR adds the missing CLI-level regression test so the
acceptance-criteria check is durable.

Refs #121.
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.

fix(cdp): FakeDriver hardcodes 1280x800 viewport rect regardless of named viewport

1 participant