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:
@@ -224,6 +224,7 @@ pub struct DaemonOptions<'a> {
|
||||
pub engine: Option<&'a str>,
|
||||
pub auto_connect: bool,
|
||||
pub idle_timeout: Option<&'a str>,
|
||||
pub default_timeout: Option<u64>,
|
||||
pub cdp: Option<&'a str>,
|
||||
pub no_auto_dialog: bool,
|
||||
}
|
||||
@@ -304,6 +305,9 @@ fn apply_daemon_env(cmd: &mut Command, session: &str, opts: &DaemonOptions) {
|
||||
if let Some(idle) = opts.idle_timeout {
|
||||
cmd.env("AGENT_BROWSER_IDLE_TIMEOUT_MS", idle);
|
||||
}
|
||||
if let Some(timeout) = opts.default_timeout {
|
||||
cmd.env("AGENT_BROWSER_DEFAULT_TIMEOUT", timeout.to_string());
|
||||
}
|
||||
if let Some(cdp) = opts.cdp {
|
||||
cmd.env("AGENT_BROWSER_CDP", cdp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user