fix(#491): auto-disable viewport for --start-maximized and --window-size args (#492)

Fixes #491

When `--start-maximized` or `--window-size` is passed as a browser arg, Playwright's default viewport (1280x720) overrides the browser's own window sizing, making those flags have no effect on the page content.

This change auto-detects those args and sets `viewport: null` so Playwright defers to the browser's window size. Explicit viewport values still take priority.

Also allows `viewport: null` in the launch protocol for agents that want to disable viewport emulation directly.
This commit is contained in:
Chris Tate
2026-02-17 20:27:38 -06:00
committed by GitHub
parent f9b33ac23d
commit 19dd2d0c0b
5 changed files with 82 additions and 8 deletions
+2
View File
@@ -16,6 +16,7 @@ const launchSchema = baseCommandSchema.extend({
width: z.number().positive(),
height: z.number().positive(),
})
.nullable()
.optional(),
browser: z.enum(['chromium', 'firefox', 'webkit']).optional(),
cdpPort: z.number().positive().optional(),
@@ -822,6 +823,7 @@ const windowNewSchema = baseCommandSchema.extend({
width: z.number().positive(),
height: z.number().positive(),
})
.nullable()
.optional(),
});