From 0705b4ddac133df5eb44a87f2059d42927b3a3fe Mon Sep 17 00:00:00 2001 From: BusyBee3333 Date: Mon, 16 Mar 2026 17:31:51 -0400 Subject: [PATCH] fix: propagate --cdp flag to daemon for reliable CDP reconnection (#857) * fix: propagate --cdp flag to daemon via AGENT_BROWSER_CDP env var The --cdp flag was not being passed to the daemon process as an environment variable, causing auto-reconnection to fail. The daemon's auto_launch() function checks for AGENT_BROWSER_CDP, but this was never set when spawning the daemon. This commit adds: - cdp field to DaemonOptions struct - AGENT_BROWSER_CDP env var setting in apply_daemon_env() - flags.cdp propagation in main.rs This ensures reliable CDP connection recovery when using --cdp with external browsers like Lightpanda, Electron apps, or remote Chrome instances. Fixes reconnection issues with --cdp flag after connection drops. * chore: remove changeset --------- Co-authored-by: Jake Shore Co-authored-by: ctate <366502+ctate@users.noreply.github.com> --- cli/src/connection.rs | 4 ++++ cli/src/main.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/cli/src/connection.rs b/cli/src/connection.rs index fe493cb..38819f8 100644 --- a/cli/src/connection.rs +++ b/cli/src/connection.rs @@ -235,6 +235,7 @@ pub struct DaemonOptions<'a> { pub confirm_actions: Option<&'a str>, pub engine: Option<&'a str>, pub idle_timeout: Option<&'a str>, + pub cdp: Option<&'a str>, } fn apply_daemon_env(cmd: &mut Command, session: &str, opts: &DaemonOptions) { @@ -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(cdp) = opts.cdp { + cmd.env("AGENT_BROWSER_CDP", cdp); + } } pub fn ensure_daemon(session: &str, opts: &DaemonOptions) -> Result { diff --git a/cli/src/main.rs b/cli/src/main.rs index f79151d..cb9f36f 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -317,6 +317,7 @@ fn main() { confirm_actions: flags.confirm_actions.as_deref(), engine: flags.engine.as_deref(), idle_timeout: flags.idle_timeout.as_deref(), + cdp: flags.cdp.as_deref(), }; let daemon_result = match ensure_daemon(&flags.session, &daemon_opts) { Ok(result) => result,