fix: load storage state at launch when --state / AGENT_BROWSER_STATE is set (#1241)
* fix: load storage state at launch when --state / AGENT_BROWSER_STATE is set The `--state` flag and `AGENT_BROWSER_STATE` env var were documented as restoring saved browser state (cookies + localStorage) at launch, but `load_state()` was never called after the browser started. The feature has been broken since it was introduced. Adds `try_load_storage_state()` and calls it from every early-return path in `auto_launch()` (lazy launch triggered by commands like `navigate`) and from `handle_launch()` (explicit `launch` command). Also adds 4 e2e tests covering all state-persistence paths: - Explicit launch with `storageState` field - Auto-launch via `AGENT_BROWSER_STATE` env var - Session-name auto-restore via `try_auto_restore_state` - Explicit `state_load` command (baseline sanity check) Fixes #1164. * style: apply cargo fmt to e2e_tests.rs Reformats a single long format\! call to satisfy CI's rustfmt check. No behavior change. * fix: call try_load_storage_state in all handle_launch branches The CDP URL, CDP port, auto-connect, and provider early-return branches were skipping storage state loading because try_load_storage_state was only called in the normal BrowserManager::launch() path at the bottom of handle_launch(). Also compute storage_state_owned once and reuse it across all branches rather than borrowing storage_state (a &str tied to cmd) in a helper that needs an owned Option<String>. * Fix storage state reload on reused launches * Fix storage-state launch errors * Fix storage state replay ordering * Align storage-state errors across launch paths * Fix storageState launch cleanup
T
Tom Dale committed
19808d08f89dcc09dff3c687bb2db4ebade9c92d
Parent: a884960
Committed by GitHub <noreply@github.com>
on 4/16/2026, 1:38:54 PM