Skip to content

feat: add --wait-until flag to open command and change default to domcontentloaded#480

Open
go-to-the-future wants to merge 1 commit intovercel-labs:mainfrom
go-to-the-future:feat/wait-until-flag
Open

feat: add --wait-until flag to open command and change default to domcontentloaded#480
go-to-the-future wants to merge 1 commit intovercel-labs:mainfrom
go-to-the-future:feat/wait-until-flag

Conversation

@go-to-the-future
Copy link

Summary

  • Add --wait-until <strategy> flag to the open command (load, domcontentloaded, networkidle)
  • Also configurable via AGENT_BROWSER_WAIT_UNTIL environment variable
  • Change the default waitUntil from load to domcontentloaded in handleNavigate, aligning it with handleTabNew which already uses domcontentloaded

Motivation

The load event waits for all resources (images, stylesheets, iframes, third-party scripts) to finish loading. On modern SPAs that depend on external auth providers, analytics, or other async resources, this frequently causes navigation timeouts — especially problematic for AI agent workflows where a timeout wastes an entire agent turn.

domcontentloaded fires when the HTML is parsed and the DOM is ready, which is sufficient for most interactions. Agent workflows already follow a navigate → snapshot → interact pattern, so waiting for full load provides no additional value.

See also: Playwright docs recommend using lighter waitUntil strategies combined with element-based assertions for SPA testing.

Changes

File Change
cli/src/flags.rs Add wait_until: Option<String> field, --wait-until flag parsing, clean_args support, env var AGENT_BROWSER_WAIT_UNTIL, and tests
cli/src/commands.rs Pass flags.wait_until as waitUntil in the navigate JSON command, add default_flags() field, and 4 new tests
cli/src/output.rs Document --wait-until in open help, global options, and environment variables
src/actions.ts Change default: command.waitUntil ?? 'load'command.waitUntil ?? 'domcontentloaded'

Usage

# Use domcontentloaded (new default — no flag needed)
agent-browser open https://example.com

# Explicitly wait for all resources
agent-browser open https://example.com --wait-until load

# Wait for network to settle
agent-browser open https://example.com --wait-until networkidle

# Set via environment variable
AGENT_BROWSER_WAIT_UNTIL=networkidle agent-browser open https://example.com

Closes #479

…contentloaded

The open command now accepts --wait-until <strategy> to control when
navigation is considered complete. Valid values: load, domcontentloaded,
networkidle. Also configurable via AGENT_BROWSER_WAIT_UNTIL env var.

The default wait strategy for handleNavigate is changed from load to
domcontentloaded, aligning it with handleTabNew which already used
domcontentloaded. The load event frequently times out on modern SPAs
that load external scripts (analytics, auth providers), making it a poor
default for agent workflows.

Closes vercel-labs#479
@vercel
Copy link
Contributor

vercel bot commented Feb 16, 2026

@go-to-the-future is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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 --wait-until flag to open command and change default to domcontentloaded

1 participant