Skip to content

Add rodney viewport command for persistent viewport resizing#33

Open
matthewbjones wants to merge 1 commit into
simonw:mainfrom
matthewbjones:feature/viewport-command
Open

Add rodney viewport command for persistent viewport resizing#33
matthewbjones wants to merge 1 commit into
simonw:mainfrom
matthewbjones:feature/viewport-command

Conversation

@matthewbjones
Copy link
Copy Markdown

@matthewbjones matthewbjones commented Feb 18, 2026

Summary

  • Adds rodney viewport command to get/set/reset the browser viewport size using CDP's EmulationSetDeviceMetricsOverride
  • Viewport dimensions persist across commands via the state file (CDP overrides are per-session, so they're re-applied in withPage())
  • rodney screenshot respects the saved viewport when no explicit -w/-h flags are given

Usage

rodney viewport              # Print current size: 1280x800
rodney viewport 390 844      # Set mobile viewport (persists)
rodney click ".hamburger"    # Interact at mobile width
rodney screenshot mobile.png # Screenshot captures at 390px
rodney viewport --reset      # Back to default

Motivation

When doing QA testing at different viewport sizes, I need to interact with the page at a specific viewport — not just take a screenshot. For example, clicking a mobile hamburger menu or testing mobile-only UI elements. The existing screenshot -w/-h flags set the viewport only for the duration of the capture.

Closes #32

Test plan

  • go test ./... passes
  • Manual testing: viewport persists across invocations, window.innerWidth confirms resize, CSS media queries trigger correctly, --reset restores default, screenshot respects saved viewport

Adds a new `viewport` command that uses CDP's EmulationSetDeviceMetricsOverride
to set the browser viewport, enabling responsive testing with CSS media queries.

- `rodney viewport` — print current viewport size
- `rodney viewport 390 844` — set viewport (persists across commands)
- `rodney viewport --reset` — reset to default

Viewport dimensions are saved to the state file and re-applied on each
command invocation, since CDP emulation overrides are scoped to the session.
The screenshot command also respects the saved viewport when no explicit
-w/-h flags are given.

Closes simonw#32

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sosso
Copy link
Copy Markdown

sosso commented Mar 25, 2026

This would be great! Just ran into this using Rodney for the first time today.

@matthewbjones
Copy link
Copy Markdown
Author

@simonw are you looking for contributions and/or assistance with maintaining this project? The tool has been great to use so far, getting used daily on projects I'm working on.

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.

Add rodney viewport WIDTH HEIGHT command for persistent viewport resizing

2 participants