BlueGit

ict rusty-teams

fix(browser): match Chrome by basename for macOS ps paths

`ps -o comm=` can return a full path; normalize before the image check.
Also declare the browser workspace dependency so the macOS app link resolves.

metis Joachim Mild · pushed by metis

Authored 2026-11-13 · 2 weeks ago

Hash
3a0f284ff0a4ff3216bb850beb57e5ded8297627
Parent
be96a9ba
1 file changed +13 −1
crates/browser/src/process.rs +13 −1
@@ -47,7 +47,14 @@ fn listener_pid(platform: Platform, port: u16) -> Result<u32, BrowserError> {
47 47 }
48 48
49 49 pub(crate) fn is_chrome_image(image_name: &str) -> bool {
50 let lowered = image_name.trim().trim_matches('"').to_ascii_lowercase();
50 // macOS `ps -o comm=` may return a full path; match on the basename.
51 let trimmed = image_name.trim().trim_matches('"');
52 let base = trimmed
53 .rsplit(['/', '\\'])
54 .next()
55 .unwrap_or(trimmed)
56 .trim();
57 let lowered = base.to_ascii_lowercase();
51 58 lowered.starts_with("chrome")
52 59 || lowered.starts_with("google chrome")
53 60 || lowered.starts_with("chromium")
@@ -97,7 +104,12 @@ mod tests {
97 104 assert!(is_chrome_image("chrome\n"));
98 105 assert!(is_chrome_image("Google Chrome"));
99 106 assert!(is_chrome_image("Chromium"));
107 assert!(is_chrome_image(
108 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
109 ));
110 assert!(is_chrome_image("/usr/bin/chromium"));
100 111 assert!(!is_chrome_image("\"wslrelay.exe\""));
112 assert!(!is_chrome_image("/Applications/Firefox.app/Contents/MacOS/firefox"));
101 113 assert!(!is_chrome_image(""));
102 114 }
103 115
@@ -47,7 +47,14 @@ fn listener_pid(platform: Platform, port: u16) -> Result<u32, BrowserError> {
47}
47}
48
48
49pub(crate) fn is_chrome_image(image_name: &str) -> bool {
49pub(crate) fn is_chrome_image(image_name: &str) -> bool {
50 let lowered = image_name.trim().trim_matches('"').to_ascii_lowercase();
50 // macOS `ps -o comm=` may return a full path; match on the basename.
51 let trimmed = image_name.trim().trim_matches('"');
52 let base = trimmed
53 .rsplit(['/', '\\'])
54 .next()
55 .unwrap_or(trimmed)
56 .trim();
57 let lowered = base.to_ascii_lowercase();
51 lowered.starts_with("chrome")
58 lowered.starts_with("chrome")
52 || lowered.starts_with("google chrome")
59 || lowered.starts_with("google chrome")
53 || lowered.starts_with("chromium")
60 || lowered.starts_with("chromium")
@@ -97,7 +104,12 @@ mod tests {
97 assert!(is_chrome_image("chrome\n"));
104 assert!(is_chrome_image("chrome\n"));
98 assert!(is_chrome_image("Google Chrome"));
105 assert!(is_chrome_image("Google Chrome"));
99 assert!(is_chrome_image("Chromium"));
106 assert!(is_chrome_image("Chromium"));
107 assert!(is_chrome_image(
108 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
109 ));
110 assert!(is_chrome_image("/usr/bin/chromium"));
100 assert!(!is_chrome_image("\"wslrelay.exe\""));
111 assert!(!is_chrome_image("\"wslrelay.exe\""));
112 assert!(!is_chrome_image("/Applications/Firefox.app/Contents/MacOS/firefox"));
101 assert!(!is_chrome_image(""));
113 assert!(!is_chrome_image(""));
102 }
114 }
103
115