YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(meetings): detect browser meetings in pop-out and Little Arc windows
Ezra Ellettee94a85dc9d76
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rsindex d0a4369b9..c53f95f2e 100644--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs@@ -8,15 +8,22 @@ use super::*;use crate::meeting_watcher::shared::ignore::{is_browser_app, meeting_app_is_ignored_with_terms};use crate::meeting_watcher::shared::profiles::MeetingDetectionProfile;-/// Ask each mic-holding browser directly for its active-tab URL and match it+/// Ask each mic-holding browser directly for its window URLs and match them/// against the meeting profiles.////// Uses the same per-browser detector as the vision pipeline-/// (`browser_utils::create_url_detector`): AppleScript for Arc, AXDocument /-/// AX address-bar walk for the rest. AppleScript reads the URL even when the+/// (`browser_utils::create_url_detector`), via `get_window_urls`: AppleScript+/// over every Arc window, AXDocument across all windows (focused first, with+/// the address-bar walk) for the rest. AppleScript reads the URL even when the/// browser shows no URL bar at all, so this resolves e.g. Arc + Google Meet/// within one poll of the mic being taken instead of waiting for the vision-/// pipeline to happen to capture a frame.+/// pipeline to happen to capture a frame. Enumerating ALL windows — not just+/// the focused one — is what catches a call in a pop-out or secondary window+/// while the user focuses something else.+///+/// Little Arc mini windows are invisible even to that (no AppleScript entry,+/// no AXDocument); their bare-meeting-code AX title is accepted as evidence+/// via `little_arc_meet_candidate`, Arc-only and strictly shaped.////// Only called while a browser candidate is still unresolved (same gating as/// `ax_resolved_candidates`), so the ~100ms osascript round-trip runs at most@@ -39,18 +46,29 @@ pub(crate) async fn active_tab_url_candidates(if pid <= 0 {return None;}- let url = match detector.get_active_url(app, pid, "") {- Ok(Some(url)) => url,- Ok(None) => return None,+ let urls = match detector.get_window_urls(app, pid) {+ Ok(urls) => urls,Err(e) => {debug!(- "audio-process meeting detector: active-tab URL probe failed for {}: {}",+ "audio-process meeting detector: window URL probe failed for {}: {}",app, e);- return None;+ Vec::new()}};- let candidate = resolve_active_tab_url_candidate(app, &url, &profiles)?;+ let candidate = urls+ .iter()+ .find_map(|url| resolve_active_tab_url_candidate(app, url, &profiles))+ .or_else(|| {+ // Gate before the AX round-trip: only Arc has Little+ // Arc windows, so don't pay for window titles on other+ // browsers.+ if !app.eq_ignore_ascii_case("arc") {+ return None;+ }+ let titles = crate::meeting_watcher::ui_scan::browser_window_titles(pid);+ little_arc_meet_candidate(app, &titles, &profiles)+ })?;let profile = profiles.get(candidate.profile_index)?;let platform = platform_name_for_profile(profile, true);if meeting_app_is_ignored_with_terms(&platform, profile, &ignored_terms) {diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rsindex 62e656f6a..c1feb9a8b 100644--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs@@ -122,6 +122,50 @@ pub(crate) fn resolve_active_tab_url_candidate(})}+/// Return the Google Meet meeting code if a window title IS one: exactly+/// `xxx-yyyy-zzz`, lowercase ASCII letters (the regex `^[a-z]{3}-[a-z]{4}-[a-z]{3}$`).+///+/// Nothing looser: this shape is used as standalone meeting evidence for+/// Little Arc (see `little_arc_meet_candidate`), so a hyphenated slug, a+/// dashed document name, uppercase, digits, or the code embedded in a longer+/// title must all be rejected.+pub(crate) fn arc_window_title_meet_code(title: &str) -> Option<&str> {+ let bytes = title.as_bytes();+ if bytes.len() != 12 {+ return None;+ }+ let shape_ok = bytes.iter().enumerate().all(|(i, &b)| match i {+ 3 | 8 => b == b'-',+ _ => b.is_ascii_lowercase(),+ });+ shape_ok.then_some(title)+}++/// Little Arc fallback: accept a mic-holding Arc process as Google Meet+/// evidence when one of its AX window titles is a bare Meet meeting code.+///+/// Little Arc mini windows are invisible to every other evidence path: they+/// are not in Arc's AppleScript `windows` collection and expose no AXDocument+/// — the title (the bare meeting code) is their entire AX footprint. Gated to+/// Arc AND the strict code shape (`arc_window_title_meet_code`), and routed+/// through `resolve_active_tab_url_candidate` with the canonical+/// `https://meet.google.com/<code>` URL so the candidate shape (profile+/// matching, ignore filtering, live evidence) is identical to the URL probe's.+pub(crate) fn little_arc_meet_candidate(+ browser_app: &str,+ window_titles: &[String],+ profiles: &[MeetingDetectionProfile],+) -> Option<AxResolvedCandidate> {+ if !browser_app.eq_ignore_ascii_case("arc") {+ return None;+ }+ window_titles.iter().find_map(|title| {+ let code = arc_window_title_meet_code(title.trim())?;+ let url = format!("https://meet.google.com/{}", code);+ resolve_active_tab_url_candidate(browser_app, &url, profiles)+ })+}+pub(crate) async fn db_find_browser_evidence(db: &DatabaseManager,) -> Result<Vec<BrowserPageEvidence>, sqlx::Error> {diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rsindex cb2f6357c..dd7505b65 100644--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs@@ -376,6 +376,114 @@ fn active_tab_meeting_link_in_query_does_not_resolve() {.is_none());}+#[test]+fn meet_code_title_shape_is_strict() {+ // The bare meeting code is standalone meeting evidence for Little Arc, so+ // only the exact ^[a-z]{3}-[a-z]{4}-[a-z]{3}$ shape may pass.+ assert_eq!(+ arc_window_title_meet_code("abc-defg-hij"),+ Some("abc-defg-hij")+ );+ assert_eq!(+ arc_window_title_meet_code("phv-jdrc-vxw"),+ Some("phv-jdrc-vxw")+ );++ // Anything looser is rejected.+ for title in [+ "",+ "abc-defg-hi", // last group too short+ "abc-defg-hijk", // last group too long+ "ab-cdefg-hij", // first group too short+ "ABC-DEFG-HIJ", // uppercase+ "abc-defg-hi1", // digit+ "abc_defg_hij", // wrong separator+ "abc-defg-hij ", // trailing whitespace (caller trims)+ "Meet - abc-defg-hij", // code embedded in a longer title+ "meet.google.com", // domain, not a code+ "one-two-three-four", // hyphenated slug+ "new-doc-nov", // 3-3-3 dashed doc name+ "\u{0430}bc-defg-hij", // non-ASCII lookalike (Cyrillic а)+ ] {+ assert_eq!(arc_window_title_meet_code(title), None, "{:?}", title);+ }+}++#[test]+fn little_arc_meet_code_title_resolves_google_meet_candidate() {+ // Little Arc windows expose no AXDocument and are absent from Arc's+ // AppleScript `windows` collection; their AX title is the bare meeting+ // code. That title must resolve to a live Google Meet candidate with the+ // same shape as the URL probe's.+ let profiles = load_detection_profiles();+ let titles = vec!["Untitled".to_string(), "phv-jdrc-vxw".to_string()];+ let candidate = little_arc_meet_candidate("Arc", &titles, &profiles)+ .expect("meeting-code title should resolve");+ assert_eq!(candidate.browser_app, "Arc");+ assert_eq!(+ platform_name_for_profile(&profiles[candidate.profile_index], true),+ "Google Meet"+ );+ assert_eq!(+ candidate.meeting_url.as_deref(),+ Some("https://meet.google.com/phv-jdrc-vxw")+ );+}++#[test]+fn little_arc_candidate_is_gated_to_arc() {+ // The bare-code heuristic is justified only by Little Arc's rendering+ // (title == code, no other footprint); other browsers must never resolve+ // from a title-shaped code.+ let profiles = load_detection_profiles();+ let titles = vec!["phv-jdrc-vxw".to_string()];+ assert!(little_arc_meet_candidate("Google Chrome", &titles, &profiles).is_none());+ assert!(little_arc_meet_candidate("Safari", &titles, &profiles).is_none());+ // Arc but no code-shaped title -> nothing.+ assert!(little_arc_meet_candidate(+ "Arc",+ &["Meet - planning".to_string(), "Arc".to_string()],+ &profiles+ )+ .is_none());+ assert!(little_arc_meet_candidate("Arc", &[], &profiles).is_none());+}++#[test]+fn little_arc_candidate_starts_meeting_as_live_evidence() {+ // End-to-end through resolve_process_candidate: the Little Arc candidate+ // must behave exactly like a URL-probe candidate — live evidence, Google+ // Meet platform, canonical meeting URL.+ let profiles = load_detection_profiles();+ let process = arc_process();+ let titles = vec!["phv-jdrc-vxw".to_string()];+ let ax = vec![little_arc_meet_candidate("Arc", &titles, &profiles).unwrap()];+ let candidate = resolve_process_candidate(+ ProcessKey::from_process(&process).unwrap(),+ Instant::now(),+ &process,+ &profiles,+ &[],+ &ax,+ &[],+ );+ match candidate {+ ResolvedMeetingCandidate::Browser {+ platform,+ meeting_url,+ browser_app,+ live_evidence,+ ..+ } => {+ assert_eq!(platform, "Google Meet");+ assert_eq!(meeting_url, "https://meet.google.com/phv-jdrc-vxw");+ assert_eq!(browser_app, "Arc");+ assert!(live_evidence);+ }+ other => panic!("expected Browser candidate, got {:?}", other),+ }+}+#[test]fn unresolved_browser_does_not_start_after_confirmation() {let process = chrome_process();diff --git a/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs b/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rsindex e41a0dbd9..700338051 100644--- a/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs@@ -165,6 +165,61 @@ pub(crate) fn browser_window_matches_meeting(false}+/// Per-window decision for the macOS AX window sweep, which sees each window's+/// AXDocument (the page URL, when the browser exposes one — Safari does,+/// Chrome mostly doesn't) and its title.+///+/// - Page URL: matched against `browser_url_patterns` (query/fragment+/// stripped, #4246).+/// - Title vs dotted `browser_url_patterns`: only a verbatim domain in the+/// title ("meet.google.com") counts — bare text like "Google Meet" appears+/// in calendar pages and must not match.+/// - Anchored `browser_title_patterns` (see `browser_title_matches_pattern`):+/// consulted ONLY when the window exposes no page URL, mirroring the+/// URL-first rule of `browser_window_matches_meeting`. This is what catches+/// a Chrome/Edge Meet pop-out titled "Meet – abc-defg-hij" (no AXDocument,+/// no domain in the title) without letting a page whose URL is known to be+/// non-meeting resolve off its title.+pub(crate) fn ax_window_matches_meeting(+ doc: Option<&str>,+ title: Option<&str>,+ profile: &MeetingDetectionProfile,+) -> bool {+ let ids = &profile.app_identifiers;+ let doc = doc.map(str::trim).filter(|d| !d.is_empty());+ if let Some(doc) = doc {+ let doc_for_match = url_without_query_or_fragment(doc);+ if ids+ .browser_url_patterns+ .iter()+ .any(|p| browser_url_pattern_matches(doc_for_match, p))+ {+ return true;+ }+ }+ if let Some(title) = title {+ if ids+ .browser_url_patterns+ .iter()+ .filter(|p| p.contains('.'))+ .any(|p| browser_url_pattern_matches(title, p))+ {+ return true;+ }+ if doc.is_none() {+ let title_lower = title.to_lowercase();+ if ids+ .browser_title_patterns+ .iter()+ .any(|p| browser_title_matches_pattern(&title_lower, p))+ {+ return true;+ }+ }+ }+ false+}+pub(crate) fn contains_case_insensitive(haystack: &str, needle: &str) -> bool {if needle.is_empty() {return false;diff --git a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/macos.rs b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/macos.rsindex 8c3b1f91d..99cee4cae 100644--- a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/macos.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/macos.rs@@ -326,7 +326,7 @@ pub fn find_running_meeting_apps(// Check browser URL patterns — only if this is a browserif !profile.app_identifiers.browser_url_patterns.is_empty()&& BROWSER_NAMES.iter().any(|b| name_lower.contains(b))- && has_browser_meeting_url(pid, profile.app_identifiers.browser_url_patterns)+ && has_browser_meeting_url(pid, profile){results.push(RunningMeetingApp {pid,@@ -344,14 +344,14 @@ pub fn find_running_meeting_apps(}/// Check if a browser process has a window whose AXDocument (page URL) or tab-/// title matches a meeting URL pattern.+/// title matches the profile.///-/// We prefer AXDocument (the actual page URL) over window title because window-/// titles can contain arbitrary page content (e.g. Google Calendar showing-/// "Join with Google Meet" text). Window titles are only checked for patterns-/// that look like domain names (contain a dot) to avoid false positives from-/// page content text like "Google Meet" appearing in calendar events.-pub(crate) fn has_browser_meeting_url(pid: i32, url_patterns: &[&str]) -> bool {+/// The per-window decision lives in `ax_window_matches_meeting` (pure, shared,+/// tested): AXDocument URL first, then a verbatim-domain title check, then the+/// anchored `browser_title_patterns` — the last only for windows exposing no+/// page URL, so a Meet pop-out titled "Meet – abc-defg-hij" (Chrome exposes no+/// AXDocument) is caught without letting arbitrary page text match.+pub(crate) fn has_browser_meeting_url(pid: i32, profile: &MeetingDetectionProfile) -> bool {cidre::objc::ar_pool(|| -> bool {let ax_app = cidre::ax::UiElement::with_app_pid(pid);let _ = ax_app.set_messaging_timeout_secs(0.3);@@ -365,36 +365,38 @@ pub(crate) fn has_browser_meeting_url(pid: i32, url_patterns: &[&str]) -> bool {let window = &windows[i];let _ = window.set_messaging_timeout_secs(0.2);- // Primary: check AXDocument attribute (actual page URL, most reliable).- // Match only against the scheme+host+path, never the query/fragment:- // a meeting URL carried as a `?redirect=…` / `#…` parameter on an- // unrelated page is not the page you're on, and matching it makes the- // browser a phantom meeting candidate (#4246).- if let Some(doc) = get_ax_string_attr(window, cidre::ax::attr::document()) {- let doc_for_match = url_without_query_or_fragment(&doc);- if url_patterns- .iter()- .any(|p| browser_url_pattern_matches(doc_for_match, p))- {- return true;- }+ let doc = get_ax_string_attr(window, cidre::ax::attr::document());+ let title = get_ax_string_attr(window, cidre::ax::attr::title());+ if ax_window_matches_meeting(doc.as_deref(), title.as_deref(), profile) {+ return true;}+ }- // Fallback: check window title, but ONLY for domain-like patterns- // (containing a dot, e.g. "meet.google.com") to avoid matching- // page content like "Join with Google Meet" on calendar pages.- if let Some(title) = get_ax_string_attr(window, cidre::ax::attr::title()) {- if url_patterns- .iter()- .filter(|p| p.contains('.'))- .any(|p| browser_url_pattern_matches(&title, p))- {- return true;+ false+ })+}++/// Titles of all AX windows of a process (best-effort, bounded timeouts).+///+/// Used by the meeting probe's Little Arc fallback: Little Arc windows expose+/// neither AXDocument nor an AppleScript `windows` entry — their only AX+/// footprint is a window title carrying the bare Meet meeting code.+pub(crate) fn browser_window_titles(pid: i32) -> Vec<String> {+ cidre::objc::ar_pool(|| -> Vec<String> {+ let ax_app = cidre::ax::UiElement::with_app_pid(pid);+ let _ = ax_app.set_messaging_timeout_secs(0.3);++ let mut titles = Vec::new();+ if let Ok(windows) = ax_app.children() {+ for i in 0..windows.len() {+ let window = &windows[i];+ let _ = window.set_messaging_timeout_secs(0.2);+ if let Some(title) = get_ax_string_attr(window, cidre::ax::attr::title()) {+ titles.push(title);}}}-- false+ titles})}diff --git a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/mod.rs b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/mod.rsindex 319c34696..a49d23c42 100644--- a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/mod.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/mod.rs@@ -34,7 +34,9 @@ mod null;mod windows;#[cfg(target_os = "macos")]-pub(crate) use macos::{discord_profile, find_running_meeting_apps, resolve_browser_pid};+pub(crate) use macos::{+ browser_window_titles, discord_profile, find_running_meeting_apps, resolve_browser_pid,+};#[cfg(not(target_os = "macos"))]pub(crate) use null::resolve_browser_pid;#[cfg(not(any(target_os = "macos", target_os = "windows")))]diff --git a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rsindex 5bd2ba8cb..0c7f99f3c 100644--- a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs+++ b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs@@ -2781,6 +2781,121 @@ fn test_non_meet_titles_do_not_match_google_meet_profile() {}}+// ── ax_window_matches_meeting: per-window decision of the macOS AX sweep ────+//+// The sweep walks ALL windows of a mic-holding browser (secondary windows and+// pop-outs included). These tests pin the evidence ordering: AXDocument URL+// first, verbatim-domain title check, and anchored `browser_title_patterns`+// only for windows that expose no page URL.++fn google_meet_profile(profiles: &[MeetingDetectionProfile]) -> &MeetingDetectionProfile {+ profiles+ .iter()+ .find(|p| {+ p.app_identifiers+ .browser_url_patterns+ .contains(&"meet.google.com")+ })+ .expect("Google Meet profile not found")+}++#[test]+fn ax_window_popout_title_matches_without_document_url() {+ // Chrome/Edge Meet pop-outs expose no AXDocument; the window title is the+ // only evidence ("Meet – abc-defg-hij"). The anchored title patterns must+ // catch it — this was the secondary-window "never detected" gap.+ let profiles = load_detection_profiles();+ let meet = google_meet_profile(&profiles);++ let popout_titles = [+ "Meet – abc-defg-hij",+ "Meet - abc-defg-hij - Google Chrome",+ "Meet", // Arc main window+ ];+ for title in &popout_titles {+ assert!(+ ax_window_matches_meeting(None, Some(title), meet),+ "pop-out title {:?} with no page URL should match",+ title+ );+ }+}++#[test]+fn ax_window_title_patterns_not_consulted_when_url_known() {+ // URL-first (#4246 family): when the window's page URL is known and is+ // NOT a meeting URL, the title alone must not resolve a meeting.+ let profiles = load_detection_profiles();+ let meet = google_meet_profile(&profiles);++ assert!(!ax_window_matches_meeting(+ Some("https://docs.google.com/document/d/123"),+ Some("Meet – planning notes"),+ meet+ ));+ // Whitespace-only doc counts as "no URL" — the title fallback applies.+ assert!(ax_window_matches_meeting(+ Some(" "),+ Some("Meet – abc-defg-hij"),+ meet+ ));+}++#[test]+fn ax_window_document_url_matches() {+ let profiles = load_detection_profiles();+ let meet = google_meet_profile(&profiles);++ assert!(ax_window_matches_meeting(+ Some("https://meet.google.com/abc-defg-hij"),+ None,+ meet+ ));+ // Query/fragment stripped before matching (#4246): a meeting link carried+ // as a parameter on an unrelated page is not the page you're on.+ assert!(!ax_window_matches_meeting(+ Some("https://example.com/redirect?to=https://meet.google.com/abc-defg-hij"),+ None,+ meet+ ));+}++#[test]+fn ax_window_dotted_domain_in_title_still_matches_with_url() {+ // The verbatim-domain title check predates the anchored patterns and is+ // kept regardless of AXDocument: a title literally carrying+ // "meet.google.com" is unambiguous.+ let profiles = load_detection_profiles();+ let meet = google_meet_profile(&profiles);++ assert!(ax_window_matches_meeting(+ Some("https://example.com"),+ Some("meet.google.com/abc-defg-hij"),+ meet+ ));+}++#[test]+fn ax_window_calendar_page_text_does_not_match() {+ // Page-content text mentioning Meet (calendar events, reminders) must not+ // resolve — the anchored matcher requires the pattern at position 0.+ let profiles = load_detection_profiles();+ let meet = google_meet_profile(&profiles);++ let non_meet_titles = [+ "Join with Google Meet - Calendar - Google Chrome",+ "Meeting reminders - Gmail",+ "Google Calendar - Week of March 16, 2026",+ ];+ for title in &non_meet_titles {+ assert!(+ !ax_window_matches_meeting(None, Some(title), meet),+ "non-Meet title {:?} should NOT match",+ title+ );+ }+}+// ── role_matches cross-platform tolerance ──────────────────────────────────//// Profiles declare roles as macOS PascalCase (`AXButton`, `AXMenuItem`,diff --git a/crates/screenpipe-screen/src/browser_utils/macos.rs b/crates/screenpipe-screen/src/browser_utils/macos.rsindex 1d126c62a..d219298a6 100644--- a/crates/screenpipe-screen/src/browser_utils/macos.rs+++ b/crates/screenpipe-screen/src/browser_utils/macos.rs@@ -4,7 +4,7 @@use accessibility_sys::{kAXChildrenAttribute, kAXDocumentAttribute, kAXFocusedWindowAttribute, kAXRoleAttribute,- kAXTextFieldRole, kAXValueAttribute, AXUIElementCopyAttributeValue,+ kAXTextFieldRole, kAXValueAttribute, kAXWindowsAttribute, AXUIElementCopyAttributeValue,AXUIElementCreateApplication, AXUIElementRef,};use anyhow::Result;@@ -18,6 +18,12 @@ use url::Url;use super::{titles_match, BrowserUrlDetector};+/// Cap on how many AX windows the all-window URL probe inspects. Each+/// AXDocument read is a synchronous cross-process AX IPC; the probe call site+/// runs under a 3s timeout, so a pathological many-window session must not eat+/// the whole budget on one browser.+const MAX_PROBED_WINDOWS: usize = 16;+pub struct MacOSUrlDetector;impl Default for MacOSUrlDetector {@@ -31,9 +37,39 @@ impl MacOSUrlDetector {Self}+ /// Read one window's AXDocument attribute. This returns the *loaded page*+ /// URL (not the address bar text), so it's naturally consistent with the+ /// rendered content. Works well for Safari.+ ///+ /// `window` is borrowed — the caller keeps ownership of the AX element.+ unsafe fn window_document_url(&self, window: AXUIElementRef) -> Option<String> {+ let mut doc_value: CFTypeRef = std::ptr::null_mut();+ let doc_status = AXUIElementCopyAttributeValue(+ window,+ CFString::from_static_string(kAXDocumentAttribute).as_concrete_TypeRef(),+ &mut doc_value,+ );++ if doc_status != accessibility_sys::kAXErrorSuccess || doc_value.is_null() {+ return None;+ }++ let cf_doc = CFString::wrap_under_create_rule(doc_value as _);+ let doc_str = cf_doc.to_string();++ // AXDocument often returns file:// URLs for the page, or the actual URL+ // Filter to only http/https URLs+ if (doc_str.starts_with("http://") || doc_str.starts_with("https://"))+ && Url::parse(&doc_str).is_ok()+ {+ debug!("got URL via AXDocument: {}", doc_str);+ Some(doc_str)+ } else {+ None+ }+ }+/// Try to get the document URL from the focused window's AXDocument attribute.- /// This returns the *loaded page* URL (not the address bar text), so it's- /// naturally consistent with the rendered content. Works well for Safari.unsafe fn get_document_url(&self, process_id: i32) -> Option<String> {let app_element = AXUIElementCreateApplication(process_id);@@ -49,33 +85,7 @@ impl MacOSUrlDetector {return None;}- // Try AXDocument attribute on the window- let mut doc_value: CFTypeRef = std::ptr::null_mut();- let doc_status = AXUIElementCopyAttributeValue(- focused_window as AXUIElementRef,- CFString::from_static_string(kAXDocumentAttribute).as_concrete_TypeRef(),- &mut doc_value,- );-- let result = if doc_status == accessibility_sys::kAXErrorSuccess && !doc_value.is_null() {- let cf_doc = CFString::wrap_under_create_rule(doc_value as _);- let doc_str = cf_doc.to_string();-- // AXDocument often returns file:// URLs for the page, or the actual URL- // Filter to only http/https URLs- if doc_str.starts_with("http://") || doc_str.starts_with("https://") {- if Url::parse(&doc_str).is_ok() {- debug!("got URL via AXDocument: {}", doc_str);- Some(doc_str)- } else {- None- }- } else {- None- }- } else {- None- };+ let result = self.window_document_url(focused_window as AXUIElementRef);CFRelease(focused_window);CFRelease(app_element as CFTypeRef);@@ -226,6 +236,87 @@ end tell"#;Ok(result)}}++ /// URL of the active tab of EVERY Arc window in one AppleScript call.+ /// AppleScript's `windows` collection is ordered front-to-back, so the+ /// focused window's URL comes first (same fast path as `get_active_url`).+ /// Little Arc mini windows are NOT in the `windows` collection — they have+ /// no AppleScript footprint at all (handled by the caller via AX titles).+ fn get_arc_all_window_urls(&self) -> Result<Vec<String>> {+ let script = r#"tell application "Arc"+ set out to ""+ repeat with w in windows+ try+ set out to out & (URL of active tab of w) & linefeed+ end try+ end repeat+ return out+end tell"#;+ let output = std::process::Command::new("osascript")+ .arg("-e")+ .arg(script)+ .output()?;++ if !output.status.success() {+ return Ok(Vec::new());+ }+ let raw = String::from_utf8(output.stdout)?;+ let mut urls: Vec<String> = Vec::new();+ for line in raw.lines() {+ let url = line.trim();+ if !url.is_empty() && !urls.iter().any(|u| u == url) {+ urls.push(url.to_string());+ }+ }+ Ok(urls)+ }++ /// All-window URL enumeration for the meeting probe.+ ///+ /// The focused window keeps the full `get_active_url` path (AXDocument,+ /// then the address-bar tree walk); the remaining windows are+ /// AXDocument-only — a tree walk per window would multiply the dominant+ /// AX IPC cost by the window count, and the probe call site runs under a+ /// 3s timeout.+ fn get_window_urls_via_accessibility(&self, process_id: i32) -> Result<Vec<String>> {+ let mut urls: Vec<String> = Vec::new();+ if let Ok(Some(url)) = self.get_url_via_accessibility(process_id) {+ urls.push(url);+ }++ unsafe {+ let app_element = AXUIElementCreateApplication(process_id);++ let mut windows_ref: CFTypeRef = std::ptr::null_mut();+ let status = AXUIElementCopyAttributeValue(+ app_element,+ CFString::from_static_string(kAXWindowsAttribute).as_concrete_TypeRef(),+ &mut windows_ref,+ );++ if status == accessibility_sys::kAXErrorSuccess && !windows_ref.is_null() {+ // +1 retained — create_rule releases the array on drop+ let windows =+ CFArray::<*const std::ffi::c_void>::wrap_under_create_rule(windows_ref as _);+ for (i, window) in windows.iter().enumerate() {+ if i >= MAX_PROBED_WINDOWS {+ break;+ }+ // The focused window shows up here too; string dedupe+ // keeps the list clean without AX element comparisons.+ if let Some(url) = self.window_document_url(*window as AXUIElementRef) {+ if !urls.contains(&url) {+ urls.push(url);+ }+ }+ }+ }++ CFRelease(app_element as CFTypeRef);+ }++ Ok(urls)+ }}impl BrowserUrlDetector for MacOSUrlDetector {@@ -267,4 +358,32 @@ impl BrowserUrlDetector for MacOSUrlDetector {self.get_url_via_accessibility(process_id)}}++ /// Meeting-probe path: URLs from every window, not just the focused one.+ /// A Meet call in a pop-out / secondary window holds the mic while the+ /// focused window shows something else entirely, so focused-only probing+ /// leaves the browser unresolvable forever. `get_active_url` (screen+ /// capture) keeps its focused-window semantics untouched.+ fn get_window_urls(&self, app_name: &str, process_id: i32) -> Result<Vec<String>> {+ if app_name == "Arc" {+ match self.get_arc_all_window_urls() {+ Ok(urls) => Ok(urls),+ Err(e) => {+ debug!(+ "Arc all-window URL fetch failed, falling back to front window: {}",+ e+ );+ let script =+ r#"tell application "Arc" to return URL of active tab of front window"#;+ Ok(self+ .get_url_via_applescript(script)?+ .filter(|url| !url.trim().is_empty())+ .into_iter()+ .collect())+ }+ }+ } else {+ self.get_window_urls_via_accessibility(process_id)+ }+ }}diff --git a/crates/screenpipe-screen/src/browser_utils/mod.rs b/crates/screenpipe-screen/src/browser_utils/mod.rsindex 6e31d5281..a359f50fb 100644--- a/crates/screenpipe-screen/src/browser_utils/mod.rs+++ b/crates/screenpipe-screen/src/browser_utils/mod.rs@@ -12,6 +12,21 @@ pub trait BrowserUrlDetector {process_id: i32,window_title: &str,) -> Result<Option<String>>;++ /// Page URLs across ALL of the browser's windows, focused window first.+ ///+ /// Used by the meeting probe: a call can live in an unfocused pop-out or+ /// secondary window that `get_active_url` (focused-window semantics, used+ /// by screen capture to attribute the frame being captured — must not+ /// change) is structurally blind to. Default falls back to the focused+ /// window only, which keeps the Windows/Linux detectors behaving exactly+ /// as before.+ fn get_window_urls(&self, app_name: &str, process_id: i32) -> Result<Vec<String>> {+ Ok(self+ .get_active_url(app_name, process_id, "")?+ .into_iter()+ .collect())+ }}// Factory function