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 <jakeshore@Jakes-Mac-mini.local>
Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
BusyBee3333
2026-03-16 16:31:51 -05:00
committed by GitHub
co-authored by Jake Shore ctate
parent 811e66f99e
commit 0705b4ddac
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -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<DaemonResult, String> {
+1
View File
@@ -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,