Skip to content

fix(vtz): apply requested viewport before rendering screenshots [#2949]#3022

Merged
viniciusdacal merged 1 commit intomainfrom
fix/screenshot-viewport-2949
Apr 28, 2026
Merged

fix(vtz): apply requested viewport before rendering screenshots [#2949]#3022
viniciusdacal merged 1 commit intomainfrom
fix/screenshot-viewport-2949

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

  • Fixes vtz: vertz_browser_screenshot ignores viewport width/height (renders 1280x720 regardless) #2949vertz_browser_screenshot ignored viewport.width/height and always rendered 1280x720.
  • ChromiumoxideHandle::capture now opens about:blank, applies Emulation.setDeviceMetricsOverride with req.viewport, then navigates — so responsive layouts see the requested viewport from the initial render.
  • Adds a regression test that decodes the PNG IHDR header and asserts rendered dimensions match the request.

Public API Changes

None. Internal screenshot pipeline only.

Test plan

  • cargo test -p vtz --lib server::screenshot (125 passed, 2 ignored)
  • cargo clippy -p vtz --all-targets -- -D warnings (clean)
  • cargo fmt --all -- --check (clean)
  • Real-Chrome opt-in: cargo test -p vtz --lib server::screenshot::chromium -- --ignored --test-threads=1
    • real_chrome_captures_about_blank
    • real_chrome_honors_request_viewport ✅ (the regression case)

🤖 Generated with Claude Code

`vertz_browser_screenshot` was rendering every PNG at the launch
viewport (1280x720) regardless of the `viewport` arg passed to the MCP
tool. The metadata reported the requested dimensions back, but the
rasterized image and on-disk filename did not match — cross-viewport
visual QA (the #2865 dogfood goal) was unusable.

`ChromiumoxideHandle::capture` now opens a blank page first, applies
`Emulation.setDeviceMetricsOverride` with `req.viewport`, and only then
navigates to the URL — so responsive layouts see the requested viewport
from the initial render. Adds a regression test that decodes the PNG
IHDR header and asserts the rendered dimensions match the request, plus
unit coverage for the PNG-dimension helper.

Closes #2949.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@viniciusdacal viniciusdacal merged commit 61ea677 into main Apr 28, 2026
7 checks passed
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.

vtz: vertz_browser_screenshot ignores viewport width/height (renders 1280x720 regardless)

1 participant