fix(cli): honor AGENT_BROWSER_DEFAULT_TIMEOUT env var for wait commands (#1153)
* fix(cli): honor AGENT_BROWSER_DEFAULT_TIMEOUT env var for wait commands The `AGENT_BROWSER_DEFAULT_TIMEOUT` environment variable was being ignored by CLI wait commands, causing them to use hardcoded 30-second timeouts instead of the configured default. ## Changes Made - **Centralized timeout injection**: Modified `parse_command()` to automatically inject `flags.default_timeout` into any wait-family command that doesn't already have an explicit `--timeout` flag - **Environment variable parsing**: Added `default_timeout` field to `Flags` struct that reads from `AGENT_BROWSER_DEFAULT_TIMEOUT` env var - **Daemon propagation**: Updated daemon spawning to pass through the default timeout via environment variables - **Unified timeout handling**: Added `timeout_ms()` helper method in `DaemonState` that all wait handlers now use instead of scattered `unwrap_or()` calls - **Comprehensive test coverage**: Added 10 regression tests covering all wait command variants and edge cases ## Implementation Details The fix uses a two-stage approach: 1. CLI parses the env var and injects timeout values into command JSON for any `wait*` action 2. Daemon reads the env var and provides a centralized fallback via `timeout_ms()` helper This ensures new wait variants automatically inherit the default timeout without requiring per-variant wiring. Fixes #1147 * fix: preserve 30s default timeout for backward compatibility The default_timeout_ms fallback was set to 25_000ms, which silently changes the existing 30_000ms behavior for users who haven't set AGENT_BROWSER_DEFAULT_TIMEOUT. Restore the original 30s default. --------- Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -300,6 +300,7 @@ pub struct Flags {
|
||||
pub screenshot_quality: Option<u32>,
|
||||
pub screenshot_format: Option<String>,
|
||||
pub idle_timeout: Option<String>, // Canonical milliseconds string for AGENT_BROWSER_IDLE_TIMEOUT_MS
|
||||
pub default_timeout: Option<u64>, // AGENT_BROWSER_DEFAULT_TIMEOUT in ms
|
||||
pub no_auto_dialog: bool,
|
||||
|
||||
// Track which launch-time options were explicitly passed via CLI
|
||||
@@ -432,6 +433,9 @@ pub fn parse_flags(args: &[String]) -> Flags {
|
||||
"AGENT_BROWSER_IDLE_TIMEOUT_MS",
|
||||
)
|
||||
.or(config.idle_timeout),
|
||||
default_timeout: env::var("AGENT_BROWSER_DEFAULT_TIMEOUT")
|
||||
.ok()
|
||||
.and_then(|s| s.parse::<u64>().ok()),
|
||||
no_auto_dialog: env_var_is_truthy("AGENT_BROWSER_NO_AUTO_DIALOG")
|
||||
|| config.no_auto_dialog.unwrap_or(false),
|
||||
cli_executable_path: false,
|
||||
|
||||
Reference in New Issue
Block a user