Summary
Add viewport and deviceScaleFactor config fields to agent-browser.json / ~/.agent-browser/config.json so a pinned viewport+DPR survives daemon restarts.
Motivation
The runtime command agent-browser set viewport <w> <h> [scale] works perfectly for pinning dimensions + DPR. But there's no persistent equivalent in the config file — every config key from the Configuration docs is enumerated and viewport/DPR is not among them.
This forces a per-session ritual: call set viewport W H 1 at the start of every workflow before any screenshot, or accept whatever the daemon's CDP defaults produce.
On macOS Retina (DPR=2) with --start-maximized in args (for a comfortable headed-mode window), screenshots come out at physical-pixel dimensions — e.g. screenshot at innerWidth 1920 × innerHeight 1057 produces 3840 × 2114 px PNG files. These are accurate but reviewer-hostile when committed to a Git host (GitHub blob view, etc.) and scrolled at 1:1 zoom.
Why config.json args doesn't work
args: "--start-maximized --force-device-scale-factor=1" has no effect on DPR. The daemon appears to call CDP Emulation.setDeviceMetricsOverride after launch and clobbers whatever Chrome was launched with. Tested with daemon restart on agent-browser 0.27.0, macOS Retina:
$ jq '.args' ~/.agent-browser/config.json
"--start-maximized --force-device-scale-factor=1"
$ agent-browser eval "({iw:innerWidth, ih:innerHeight, dpr:devicePixelRatio})"
{ "iw": 1920, "ih": 1057, "dpr": 2 } # DPR still 2
$ agent-browser screenshot /tmp/test.png && sips -g pixelWidth -g pixelHeight /tmp/test.png
pixelWidth: 3840
pixelHeight: 2114
Compared with runtime override that does work:
$ agent-browser set viewport 1920 1080 1
$ agent-browser eval "({iw:innerWidth, ih:innerHeight, dpr:devicePixelRatio})"
{ "iw": 1920, "ih": 1080, "dpr": 1 } # DPR pinned
$ agent-browser screenshot /tmp/test.png && sips -g pixelWidth -g pixelHeight /tmp/test.png
pixelWidth: 1920
pixelHeight: 1080
Proposed config keys
Or as a flat shorthand (matching CLI set viewport <w> <h> [scale]):
Either shape applied at daemon-start via the same CDP path the runtime command uses (Emulation.setDeviceMetricsOverride).
Use cases
- Reviewer-friendly screenshots committed to a repo: pin to 1280×800 or 1920×1080 DPR=1 so blob-view zoom is 1:1 with no compression
- Witness/QA ceremonies where evidence images need deterministic dimensions across sessions
- CI environments where each spawned daemon should produce comparable screenshots
- Workaround today: bash function wrapping
agent-browser that runs set viewport after open — works but every operator has to add it
Environment
- agent-browser 0.27.0 (latest)
- macOS 24.3.0, Retina display
- Chrome via daemon,
headed: true
Summary
Add
viewportanddeviceScaleFactorconfig fields toagent-browser.json/~/.agent-browser/config.jsonso a pinned viewport+DPR survives daemon restarts.Motivation
The runtime command
agent-browser set viewport <w> <h> [scale]works perfectly for pinning dimensions + DPR. But there's no persistent equivalent in the config file — every config key from the Configuration docs is enumerated and viewport/DPR is not among them.This forces a per-session ritual: call
set viewport W H 1at the start of every workflow before anyscreenshot, or accept whatever the daemon's CDP defaults produce.On macOS Retina (DPR=2) with
--start-maximizedinargs(for a comfortable headed-mode window), screenshots come out at physical-pixel dimensions — e.g.screenshotat innerWidth 1920 × innerHeight 1057 produces3840 × 2114 pxPNG files. These are accurate but reviewer-hostile when committed to a Git host (GitHub blob view, etc.) and scrolled at 1:1 zoom.Why config.json args doesn't work
args: "--start-maximized --force-device-scale-factor=1"has no effect on DPR. The daemon appears to call CDPEmulation.setDeviceMetricsOverrideafter launch and clobbers whatever Chrome was launched with. Tested with daemon restart on agent-browser 0.27.0, macOS Retina:Compared with runtime override that does work:
Proposed config keys
{ "viewport": { "width": 1920, "height": 1080 }, "deviceScaleFactor": 1 }Or as a flat shorthand (matching CLI
set viewport <w> <h> [scale]):{ "viewport": "1920x1080@1" }Either shape applied at daemon-start via the same CDP path the runtime command uses (
Emulation.setDeviceMetricsOverride).Use cases
agent-browserthat runsset viewportafteropen— works but every operator has to add itEnvironment
headed: true