From ea9d45634196be89221e68f6b245d21999845e23 Mon Sep 17 00:00:00 2001 From: QuietyAwe <90510260+QuietyAwe@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:42:59 +0800 Subject: [PATCH] fix: respect --headed false flag in CLI (#757) When user explicitly sets --headed false, the CLI was ignoring this flag because the launch condition only checked if flags.headed was true. This meant that --headed false would not trigger a launch command, and subsequent commands would auto-launch with default headless=true. The fix adds a cli_headed flag to track when the user explicitly sets --headed (regardless of value), and includes this in the launch condition check. Fixes #743 --- cli/src/commands.rs | 1 + cli/src/flags.rs | 3 +++ cli/src/main.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cli/src/commands.rs b/cli/src/commands.rs index 00baeb0..f4b57ea 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -2164,6 +2164,7 @@ mod tests { cli_annotate: false, cli_download_path: false, cli_native: false, + cli_headed: false, annotate: false, color_scheme: None, download_path: None, diff --git a/cli/src/flags.rs b/cli/src/flags.rs index 3446d48..c48b26b 100644 --- a/cli/src/flags.rs +++ b/cli/src/flags.rs @@ -267,6 +267,7 @@ pub struct Flags { pub cli_annotate: bool, pub cli_download_path: bool, pub cli_native: bool, + pub cli_headed: bool, } pub fn parse_flags(args: &[String]) -> Flags { @@ -382,6 +383,7 @@ pub fn parse_flags(args: &[String]) -> Flags { cli_annotate: false, cli_download_path: false, cli_native: false, + cli_headed: false, }; let mut i = 0; @@ -404,6 +406,7 @@ pub fn parse_flags(args: &[String]) -> Flags { "--headed" => { let (val, consumed) = parse_bool_arg(args, i); flags.headed = val; + flags.cli_headed = true; if consumed { i += 1; } diff --git a/cli/src/main.rs b/cli/src/main.rs index 3518ab2..3dda514 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -496,6 +496,7 @@ fn main() { flags.cli_allow_file_access.then_some("--allow-file-access"), flags.cli_download_path.then_some("--download-path"), flags.cli_native.then_some("--native"), + flags.cli_headed.then_some("--headed"), ] .into_iter() .flatten() @@ -723,6 +724,7 @@ fn main() { // Launch headed browser or configure browser options (without CDP or provider) if (flags.headed + || flags.cli_headed // User explicitly set --headed (even if false) || flags.executable_path.is_some() || flags.profile.is_some() || flags.state.is_some()