diff --git a/cli/src/native/actions.rs b/cli/src/native/actions.rs index e50db6a..f502c0a 100644 --- a/cli/src/native/actions.rs +++ b/cli/src/native/actions.rs @@ -3489,6 +3489,25 @@ async fn handle_recording_start(cmd: &Value, state: &mut DaemonState) -> Result< let new_session_id = attach_result.session_id.clone(); mgr.enable_domains_pub(&new_session_id).await?; + // Re-apply download behavior to the recording context. + // Without this, downloads in the recording context are silently dropped + // because Browser.setDownloadBehavior at launch only applies to the default context. + if let Some(ref dl_path) = mgr.download_path { + let _ = mgr + .client + .send_command( + "Browser.setDownloadBehavior", + Some(json!({ + "behavior": "allow", + "downloadPath": dl_path, + "browserContextId": context_id, + "eventsEnabled": true + })), + None, + ) + .await; + } + // Transfer cookies to new context if let Some(ref cr) = cookies_result { if let Some(cookie_arr) = cr.get("cookies").and_then(|v| v.as_array()) { diff --git a/cli/src/native/browser.rs b/cli/src/native/browser.rs index 8aaa432..568238b 100644 --- a/cli/src/native/browser.rs +++ b/cli/src/native/browser.rs @@ -189,6 +189,8 @@ pub struct BrowserManager { pages: Vec, active_page_index: usize, default_timeout_ms: u64, + /// Stored download path from launch options, re-applied to new contexts (e.g., recording) + pub download_path: Option, } const LIGHTPANDA_CDP_CONNECT_TIMEOUT: Duration = Duration::from_secs(5); @@ -257,6 +259,7 @@ impl BrowserManager { pages: Vec::new(), active_page_index: 0, default_timeout_ms: 25_000, + download_path: download_path.clone(), }; manager.discover_and_attach_targets().await?; manager @@ -321,6 +324,7 @@ impl BrowserManager { pages: Vec::new(), active_page_index: 0, default_timeout_ms: 10_000, + download_path: None, // CDP connections don't have a launch-time download path }; manager.discover_and_attach_targets().await?; @@ -1252,6 +1256,7 @@ async fn initialize_lightpanda_manager( pages: Vec::new(), active_page_index: 0, default_timeout_ms: 25_000, + download_path: None, }; match discover_and_attach_lightpanda_targets(&mut manager, deadline).await {