Skip to content

Conversation

@Sanchay-T
Copy link
Contributor

@Sanchay-T Sanchay-T commented Feb 5, 2026

Summary

  • Add AGENT_BROWSER_VIEWPORT env var to set default viewport size for auto-launched browser sessions (e.g., 1920x1080 or 1920,1080)
  • Extract parseViewportEnv() helper in src/daemon.ts with full unit test coverage
  • Reject non-positive dimensions (e.g., 0x720) to avoid Playwright errors
  • Add Environment Variables reference table to README

Motivation

The daemon auto-launch hardcodes 1280x720 with no way to persist a preferred viewport. Users had to send an explicit launch command or set viewport on every session. This follows the same pattern as AGENT_BROWSER_EXECUTABLE_PATH, AGENT_BROWSER_SESSION, etc.

Changes

File Change
src/daemon.ts Add parseViewportEnv() + pass viewport to auto-launch
src/daemon.test.ts 13 unit tests for viewport parsing
README.md Add Environment Variables table

Test plan

  • AGENT_BROWSER_VIEWPORT=1920x1080 → browser reports innerWidth:1920, innerHeight:1080
  • No env var → defaults to 1280x720
  • New tabs inherit the viewport from context
  • 0x1080, 1920x0, 0x0 → rejected, falls back to default
  • Unit tests: valid formats (WxH, W,H), invalid/empty/undefined inputs
  • Full test suite passes (181 tests)
  • TypeScript builds clean

@vercel
Copy link
Contributor

vercel bot commented Feb 5, 2026

@Sanchay-T is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f62871e1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/daemon.ts Outdated
Comment on lines 22 to 24
const match = value.match(/^(\d+)[x,](\d+)$/);
if (!match) return undefined;
return { width: parseInt(match[1], 10), height: parseInt(match[2], 10) };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject non-positive viewport dimensions from env

parseViewportEnv() currently accepts 0 values (for example AGENT_BROWSER_VIEWPORT=0x720) because the regex allows any digits, then forwards that viewport to browser.launch() during daemon auto-launch. Playwright viewport sizes must be positive, so this causes auto-launch to throw on the first non-launch command and effectively breaks the daemon for that session instead of ignoring invalid env input and falling back to defaults.

Useful? React with 👍 / 👎.

The daemon auto-launch hardcodes 1280x720, with no way to set a default
viewport without an explicit launch command. This adds support for the
AGENT_BROWSER_VIEWPORT env var (e.g., "1920x1080" or "1920,1080") so
users can persist their preferred viewport size across sessions.
@Sanchay-T Sanchay-T force-pushed the feat/viewport-env-var branch from 5f62871 to 8b1d739 Compare February 5, 2026 17:17
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.

1 participant