From a943572e7f1e5f4114a28ffbd740ac427769f973 Mon Sep 17 00:00:00 2001 From: Hanako Date: Tue, 1 Sep 2026 02:34:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?checkpoint:=20=E7=A7=BB=E9=99=A4=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E8=BF=9B=E7=A8=8B=E9=97=A8=E5=8D=AB=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20Edge=20=E7=AD=89=E4=BB=BB=E6=84=8F=20Chrom?= =?UTF-8?q?ium=20=E6=B5=8F=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不再通过 is_chrome_running() 检测 chrome.exe / msedge.exe 进程名, connect_daemon_page 直接进入 daemon 握手;浏览器是否可用由 daemon 与扩展 的真实连接状态决定,而非臆测的进程名。 对比 Issue #55 提议的"加 msedge 白名单"方案,本改动更彻底: - 通用:任何装了扩展的 Chromium 浏览器(Chrome/Edge/Brave/Arc 等)直接可用 - 诚实:扩展未连时报 'Chrome extension not connected' 而非伪装成 'Chrome is not running' - 零维护:无需随浏览器种类增长维护进程名清单 只改动 crates/autocli-browser/src/bridge.rs,删除 is_chrome_running 及其调用门卫。 --- crates/autocli-browser/src/bridge.rs | 45 +++------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/crates/autocli-browser/src/bridge.rs b/crates/autocli-browser/src/bridge.rs index dc40af4..6e3ade7 100644 --- a/crates/autocli-browser/src/bridge.rs +++ b/crates/autocli-browser/src/bridge.rs @@ -39,17 +39,10 @@ impl BrowserBridge { pub async fn connect_daemon_page(&mut self) -> Result, CliError> { let client = Arc::new(DaemonClient::new(self.port)); - // Step 1: Check Chrome is running - if !is_chrome_running() { - return Err(CliError::BrowserConnect { - message: "Chrome is not running".into(), - suggestions: vec![ - "Please open Google Chrome with the OpenCLI extension installed".into(), - "The extension connects to the daemon automatically when Chrome is open".into(), - ], - source: None, - }); - } + // Step 1: No browser-process gate. Any Chromium browser (Chrome, Edge, etc.) with the + // extension installed connects to the daemon on its own; the daemon handshake below is the + // only authority on whether a browser is usable. Skipping process-name detection keeps Edge + // and other Chromium browsers working without a per-browser allowlist (see issue #55). // Step 2: Ensure daemon is running if client.is_running().await { @@ -167,36 +160,6 @@ impl BrowserBridge { } } -/// Check if Chrome/Chromium is running as a process. -fn is_chrome_running() -> bool { - if cfg!(target_os = "macos") { - // macOS: check for "Google Chrome" process - std::process::Command::new("pgrep") - .args(["-x", "Google Chrome"]) - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .status() - .map(|s| s.success()) - .unwrap_or(false) - } else if cfg!(target_os = "windows") { - // Windows: check for chrome.exe - std::process::Command::new("tasklist") - .args(["/FI", "IMAGENAME eq chrome.exe", "/NH"]) - .output() - .map(|o| String::from_utf8_lossy(&o.stdout).contains("chrome.exe")) - .unwrap_or(false) - } else { - // Linux: check for chrome or chromium - std::process::Command::new("pgrep") - .args(["-x", "chrome|chromium"]) - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .status() - .map(|s| s.success()) - .unwrap_or(false) - } -} - /// Try to wake up Chrome by opening a window. /// When Chrome is running but has no windows, the extension Service Worker is suspended. /// Opening a window activates the Service Worker, which then reconnects to the daemon. From b02e3a36ddc5f9bb8b3154190f92591a05f9d7ab Mon Sep 17 00:00:00 2001 From: Hanako Date: Tue, 1 Sep 2026 02:42:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?checkpoint:=20wake=5Fchrome=20=E5=BC=80?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=B5=8F=E8=A7=88=E5=99=A8=E8=80=8C=E9=9D=9E?= =?UTF-8?q?=E7=A1=AC=E7=BC=96=E7=A0=81=20Chrome?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wake_chrome() 在扩展 5s 未连上时触发,原实现硬编码拉起 Chrome (macOS: open -a "Google Chrome";Windows: start chrome),会在未装/不 用 Chrome 的机器上误拉起 Chrome。 改为开系统默认浏览器: - Windows: cmd /C start "" about:blank(空标题参数使 about:blank 被当 URL) - macOS/Linux: open / xdg-open about:blank 这样 Edge/Brave/Arc 等任意默认 Chromium 浏览器都能被唤醒,且不绑定 具体浏览器二进制。与"移除 is_chrome_running 门卫"同一思路(PR #66)。 --- crates/autocli-browser/src/bridge.rs | 35 +++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/crates/autocli-browser/src/bridge.rs b/crates/autocli-browser/src/bridge.rs index 6e3ade7..dce0a7d 100644 --- a/crates/autocli-browser/src/bridge.rs +++ b/crates/autocli-browser/src/bridge.rs @@ -164,30 +164,33 @@ impl BrowserBridge { /// When Chrome is running but has no windows, the extension Service Worker is suspended. /// Opening a window activates the Service Worker, which then reconnects to the daemon. fn wake_chrome() { - let result = if cfg!(target_os = "macos") { - std::process::Command::new("open") - .args(["-a", "Google Chrome", "about:blank"]) - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .spawn() - } else if cfg!(target_os = "windows") { + // Open a blank window in the SYSTEM DEFAULT browser to wake a suspended extension + // Service Worker. We deliberately avoid naming Chrome/Edge: `open about:blank` (macOS), + // `xdg-open about:blank` (Linux) and `cmd /C start "" about:blank` (Windows, empty title arg + // so about:blank is treated as a URL, not a program name) all resolve to the user's default + // Chromium browser. This keeps Edge/Brave/Arc working without hardcoding a binary (see #55). + let result = if cfg!(target_os = "windows") { std::process::Command::new("cmd") - .args(["/C", "start", "chrome", "about:blank"]) + .args(["/C", "start", "", "about:blank"]) .stdout(std::process::Stdio::null()) .stderr(std::process::Stdio::null()) .spawn() } else { - // Linux: try common Chrome executables - std::process::Command::new("xdg-open") - .arg("about:blank") - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .spawn() + // macOS and Linux both have a default-browser opener + std::process::Command::new(if cfg!(target_os = "macos") { + "open" + } else { + "xdg-open" + }) + .arg("about:blank") + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .spawn() }; match result { - Ok(_) => debug!("Opened Chrome window to wake extension"), - Err(e) => debug!("Failed to open Chrome window: {e}"), + Ok(_) => debug!("Opened default browser window to wake extension"), + Err(e) => debug!("Failed to open browser window: {e}"), } }