From eaa968e229565285613be47a067448db2f830777 Mon Sep 17 00:00:00 2001 From: Li Yang <76434265+hewliyang@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:17:14 +0800 Subject: [PATCH] fix: suppress spurious --native warning when set via env var (#611) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: suppress spurious --native warning when set via env var When AGENT_BROWSER_NATIVE=1 is set via environment variable, every command after the first would warn: ⚠ --native ignored: daemon already running. This is a false positive — the daemon was already spawned in native mode and inherited the env var. The warning should only fire when --native is explicitly passed on the CLI to an already-running daemon. Add cli_native flag (consistent with existing cli_* pattern) to distinguish CLI origin from env var origin. * fix: add flag to test cfg * fix: cli_native should track flag presence, not value --native false on CLI should still warn when daemon is already running, since the user is explicitly trying to change the mode. --- cli/src/commands.rs | 1 + cli/src/flags.rs | 3 +++ cli/src/main.rs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/src/commands.rs b/cli/src/commands.rs index 0f228a2..4166159 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -2100,6 +2100,7 @@ mod tests { cli_allow_file_access: false, cli_annotate: false, cli_download_path: false, + cli_native: false, annotate: false, color_scheme: None, download_path: None, diff --git a/cli/src/flags.rs b/cli/src/flags.rs index 3bbdf51..b897e31 100644 --- a/cli/src/flags.rs +++ b/cli/src/flags.rs @@ -250,6 +250,7 @@ pub struct Flags { pub cli_allow_file_access: bool, pub cli_annotate: bool, pub cli_download_path: bool, + pub cli_native: bool, } pub fn parse_flags(args: &[String]) -> Flags { @@ -352,6 +353,7 @@ pub fn parse_flags(args: &[String]) -> Flags { cli_allow_file_access: false, cli_annotate: false, cli_download_path: false, + cli_native: false, }; let mut i = 0; @@ -568,6 +570,7 @@ pub fn parse_flags(args: &[String]) -> Flags { "--native" => { let (val, consumed) = parse_bool_arg(args, i); flags.native = val; + flags.cli_native = true; if consumed { i += 1; } diff --git a/cli/src/main.rs b/cli/src/main.rs index f6476f5..330475d 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -463,7 +463,7 @@ fn main() { flags.ignore_https_errors.then_some("--ignore-https-errors"), flags.cli_allow_file_access.then_some("--allow-file-access"), flags.cli_download_path.then_some("--download-path"), - flags.native.then_some("--native"), + flags.cli_native.then_some("--native"), ] .into_iter() .flatten()