fix(vtz): apply requested viewport before rendering screenshots [#2949]#3022
Merged
viniciusdacal merged 1 commit intomainfrom Apr 28, 2026
Merged
fix(vtz): apply requested viewport before rendering screenshots [#2949]#3022viniciusdacal merged 1 commit intomainfrom
viniciusdacal merged 1 commit intomainfrom
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vertz_browser_screenshotignoredviewport.width/heightand always rendered 1280x720.ChromiumoxideHandle::capturenow opensabout:blank, appliesEmulation.setDeviceMetricsOverridewithreq.viewport, then navigates — so responsive layouts see the requested viewport from the initial render.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)cargo test -p vtz --lib server::screenshot::chromium -- --ignored --test-threads=1real_chrome_captures_about_blank✅real_chrome_honors_request_viewport✅ (the regression case)🤖 Generated with Claude Code