Skip to content

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

fix(meetings): harden the four meeting/piggyback fixes per adversarial review

Ezra Elletteac506e306ebc
diff --git a/TESTING.md b/TESTING.md
index c2a09d99d..5d8179aed 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -113,7 +113,8 @@ commits: `28e5c247`
- [ ] **piggyback fallback: tap build failure** — flag on, force tap failure (revoke System Audio Recording permission): capture continues on the user's configured capture — the System Audio stream via whichever backend their settings select (SCK by default, CoreAudio global tap when `experimentalCoreaudioSystemAudio` is on) plus their configured/pinned mics; a warning logs, ≤3 retries per meeting with 60s cooldown, no notification unless the fallback capture is also silent.
- [ ] **piggyback fallback is backend-neutral** — repeat the tap-build-failure test with `experimentalCoreaudioSystemAudio` ON: the fallback System Audio stream comes up as the CoreAudio global tap (log shows a Process Tap gen start, not SCK), proving the piggyback fallback re-derives the backend from user settings at start time rather than hardcoding one. Same expectation for any future backend.
- [ ] **piggyback fallback: app quits mid-meeting** — kill the meeting app: tap stream tears down within ~2s, global output resumes (unsuspended) until the watcher ends the meeting; no crash, no rebuild storm.
-- [ ] **piggyback fallback: no pid (manual/ui_scan/reattach)** — a meeting without a detected pid behaves exactly like flag-off (stable path).
+- [ ] **piggyback fallback: no pid (ui_scan/reattach)** — a DETECTED meeting whose sensor can't identify the process (ui_scan, post-restart reattach) behaves exactly like flag-off (stable path). Manual meetings are NOT in this bucket — they derive their pid set from the live mic-holder enumeration (see the manual-piggyback item above).
+- [ ] **browser pop-out / Little Arc meeting detection** — join a Google Meet call in a Chrome pop-out window or an Arc "Little Arc" window, then focus a different app: the meeting is detected within one poll of the mic being held (log shows the `UnresolvedBrowser` -> `Active` promotion); a non-meeting window whose title merely looks like a meeting code (e.g. a doc named "abc-defg-hij") with no mic held must NOT trigger detection. (`ff0337416`)
- [ ] **piggyback on unsupported OS** — flag on, macOS <14.4 / Windows <20348: one-time log "using the stable capture path", capture identical to flag-off. Windows must fail the PID-specific tap and let the normal configured/default output capture path run; the Meeting Tap stream itself must not silently downgrade to endpoint-wide loopback.
- [ ] **mid-call mic switch in the app** — change Zoom's mic mid-call: capture follows within ~4s (old session mic stops, new one starts); changing the OS default while Zoom is pinned elsewhere does NOT switch capture.
- [ ] **mic switch must not flap the meeting** — switch the meeting app's mic (AirPods → phone → built-in, several times): `meeting_status_changed` stays active=true throughout — NO end/re-start pair ~20s after each switch, no Meeting Tap teardown/rebuild, no System Audio resume/suspend churn. (Root cause was device-derived session keys: macOS synthesized the audio-session id from the device set and WASAPI GUIDs are per-endpoint, so a mic switch re-keyed the session and the meeting rode the 20s ending grace into EndMeeting + instant restart.)
diff --git a/crates/screenpipe-audio/src/audio_manager/meeting_piggyback.rs b/crates/screenpipe-audio/src/audio_manager/meeting_piggyback.rs
index 16e2c21d2..35bb82d56 100644
--- a/crates/screenpipe-audio/src/audio_manager/meeting_piggyback.rs
+++ b/crates/screenpipe-audio/src/audio_manager/meeting_piggyback.rs
@@ -381,6 +381,13 @@ pub(crate) struct PiggybackState {
/// costs a rebuild. Reset on meeting end.
pub manual_pids_adopted: Vec<i32>,
pub manual_pids_candidate: Option<Vec<i32>>,
+ /// One-shot per meeting: the MANUAL-meeting mic-holder enumeration
+ /// returned an error (or reported unsupported) and the sweep logged it.
+ /// Errored ticks keep the previously adopted pid set in force instead of
+ /// feeding adoption (see [`adopt_manual_snapshot`]); warning on every 2s
+ /// tick would be noise. Reset at the meeting-end edge alongside
+ /// `manual_pids_adopted`.
+ pub manual_enum_error_logged: bool,
}
/// Two-tick adoption for a MANUAL meeting's mic-holder pid set: a freshly
@@ -399,6 +406,29 @@ pub(crate) fn adopt_manual_pids(state: &mut PiggybackState, fresh: Vec<i32>) ->
state.manual_pids_adopted.clone()
}
+/// Feeds one mic-holder enumeration snapshot into MANUAL-meeting pid
+/// adoption. A failed (`error: Some`) or unsupported snapshot carries
+/// `processes: []`, which at the pid level is indistinguishable from "no mic
+/// holders" — feeding it into [`adopt_manual_pids`] would adopt the empty set
+/// after two consecutive error ticks and tear down a healthy piggyback. So on
+/// error the previously adopted set stays in force untouched (candidate
+/// included: an error tick neither confirms nor refutes a pending candidate)
+/// and only a healthy snapshot feeds two-tick adoption. Pure state
+/// transition — unit-tested directly; the sweep owns the once-per-meeting
+/// error logging.
+pub(crate) fn adopt_manual_snapshot(
+ state: &mut PiggybackState,
+ snapshot: &crate::meeting_processes::AudioProcessSnapshot,
+) -> Vec<i32> {
+ if !snapshot.supported || snapshot.error.is_some() {
+ return state.manual_pids_adopted.clone();
+ }
+ let mut fresh: Vec<i32> = snapshot.processes.iter().filter_map(|p| p.pid).collect();
+ fresh.sort_unstable();
+ fresh.dedup();
+ adopt_manual_pids(state, fresh)
+}
+
/// Increments `state.tap_strikes` by one and, on the edge where that crosses
/// into [`MAX_TAP_STRIKES`] (not merely being AT it — a strike recorded while
/// already exhausted, which can't normally happen since the sweep stops
@@ -444,6 +474,10 @@ pub(crate) struct MeetingTelemetry {
pub strikes_max: u32,
pub unavailable: bool,
pub pid_known: bool,
+ /// The user started this meeting manually (no sensor pid ever; the pid
+ /// set comes from the live mic-holder enumeration). Lets the PostHog
+ /// dashboards segment the manual-meeting population from detected ones.
+ pub manual: bool,
pub bundle_id: Option<String>,
pub mic_resolved_devices: std::collections::BTreeSet<String>,
pub mic_session_started: bool,
@@ -478,6 +512,7 @@ pub(crate) struct PiggybackMeetingSummary {
pub mic_capture_failed: bool,
pub meeting_app_bundle_id: Option<String>,
pub pid_known: bool,
+ pub manual: bool,
pub platform: &'static str,
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<String>,
@@ -518,6 +553,7 @@ pub(crate) fn build_meeting_summary(t: &MeetingTelemetry) -> PiggybackMeetingSum
mic_capture_failed: t.capture_failed,
meeting_app_bundle_id: t.bundle_id.clone(),
pid_known: t.pid_known,
+ manual: t.manual,
platform: std::env::consts::OS,
os_version: os_version_string(),
}
@@ -647,16 +683,32 @@ pub(crate) async fn run_meeting_piggyback_sweep(
let meeting: Option<Vec<i32>> = active.as_ref().map(|m| {
if m.manual {
// The enumeration is a CoreAudio/WASAPI process walk — pay it
- // only when the result could actually engage the tap.
- if engaged && tap_avail {
- let mut fresh: Vec<i32> = crate::meeting_processes::current_input_processes()
- .processes
- .iter()
- .filter_map(|p| p.pid)
- .collect();
- fresh.sort_unstable();
- fresh.dedup();
- adopt_manual_pids(state, fresh)
+ // whenever the flag is engaged, even with the tap UNAVAILABLE:
+ // a non-empty pid set is what routes a manual meeting on an old
+ // OS (macOS <14.4 / Windows <20348) into the decider's
+ // WarnUnavailableOnce and the "unavailable" telemetry outcome —
+ // gating on tap availability left the pid set empty there, so
+ // the warn never fired and telemetry misreported "no_pid". Cost:
+ // a per-2s-tick process walk during manual meetings only, the
+ // same class of work the engine watcher already does at 1s for
+ // auto detection.
+ if engaged {
+ let snapshot = crate::meeting_processes::current_input_processes();
+ if !snapshot.supported || snapshot.error.is_some() {
+ // Log the failure once per meeting; the errored ticks
+ // keep the previously adopted set in force instead of
+ // feeding adoption (see `adopt_manual_snapshot`).
+ if !state.manual_enum_error_logged {
+ warn!(
+ "[MEETING_PIGGYBACK] mic-holder enumeration failed (supported={}): {} — keeping previously adopted pid set {:?}",
+ snapshot.supported,
+ snapshot.error.as_deref().unwrap_or("unknown error"),
+ state.manual_pids_adopted
+ );
+ state.manual_enum_error_logged = true;
+ }
+ }
+ adopt_manual_snapshot(state, &snapshot)
} else {
Vec::new()
}
@@ -761,6 +813,7 @@ pub(crate) async fn run_meeting_piggyback_sweep(
telemetry.meeting_seen = true;
telemetry.meeting_ticks += 1;
telemetry.pid_known |= !meeting_pids.is_empty();
+ telemetry.manual |= active.as_ref().is_some_and(|m| m.manual);
if telemetry.bundle_id.is_none() {
telemetry.bundle_id = detector
.as_ref()
@@ -855,6 +908,31 @@ pub(crate) async fn run_meeting_piggyback_sweep(
"[MEETING_PIGGYBACK] failed to rebuild meeting tap over new pid set (strike {}/{}): {}",
state.tap_strikes, MAX_TAP_STRIKES, e
);
+ // The stable "(output)" devices were suspended for the
+ // tap that just died with this failed rebuild — resume
+ // them NOW rather than waiting for the next tick's
+ // decider pass, which would leave a ~2s far-end capture
+ // hole. Mirrors the Resume handler above: unsuspend
+ // first, then restart immediately (gated on
+ // enabled_devices because start_device would otherwise
+ // ADD the device) instead of deferring to the monitor's
+ // enabled pass, which already ran this tick.
+ for name in audio_manager.suspended_devices() {
+ if !name.ends_with("(output)") {
+ continue;
+ }
+ audio_manager.unsuspend_device(&name);
+ if audio_manager.enabled_devices().await.contains(&name) {
+ if let Ok(device) = parse_audio_device(&name) {
+ if let Err(e) = audio_manager.start_device(&device).await {
+ warn!(
+ "[MEETING_PIGGYBACK] failed to restart resumed device {} after tap rebuild failure: {}",
+ name, e
+ );
+ }
+ }
+ }
+ }
} else {
state.tap_pids = pids;
state.telemetry.tap_started_count += 1;
@@ -1060,9 +1138,11 @@ pub(crate) async fn run_meeting_piggyback_sweep(
let _ = screenpipe_events::send_event("piggyback_meeting_summary", summary);
state.telemetry = MeetingTelemetry::default();
// Manual pid-set bookkeeping is meeting-scoped: the next manual
- // meeting starts from an empty adopted set (two-tick warm-up).
+ // meeting starts from an empty adopted set (two-tick warm-up) and
+ // gets its own one-shot enumeration-error log.
state.manual_pids_adopted = Vec::new();
state.manual_pids_candidate = None;
+ state.manual_enum_error_logged = false;
}
state.last_meeting_seen = meeting_now;
@@ -1204,6 +1284,102 @@ mod tests {
);
}
+ #[test]
+ fn manual_meeting_on_unavailable_platform_warns() {
+ // Manual meetings enumerate mic holders whenever the flag is engaged,
+ // even with the tap UNAVAILABLE (the sweep gates enumeration on
+ // `engaged` alone), so this decider cell is REACHABLE: a non-empty
+ // multi-pid set (the mic-holder enumeration result) with no tap must
+ // fire WarnUnavailableOnce and ride the stable path — the same
+ // outcome as a detected meeting on macOS <14.4 / Windows <20348.
+ // Telemetry then classifies the meeting "unavailable" instead of the
+ // misleading "no_pid".
+ let mut obs = base();
+ obs.meeting = Some(vec![100, 200]);
+ obs.tap_available = false;
+ assert_eq!(
+ decide_piggyback(&obs),
+ vec![PiggybackAction::WarnUnavailableOnce]
+ );
+ }
+
+ fn snapshot_ok(pids: Vec<i32>) -> crate::meeting_processes::AudioProcessSnapshot {
+ crate::meeting_processes::AudioProcessSnapshot {
+ supported: true,
+ processes: pids
+ .into_iter()
+ .map(|pid| crate::meeting_processes::AudioInputProcess {
+ audio_session_id: None,
+ audio_object_id: None,
+ pid: Some(pid),
+ bundle_id: None,
+ process_name: None,
+ owner_app_name: None,
+ owner_bundle_id: None,
+ first_seen_at_ms: None,
+ })
+ .collect(),
+ error: None,
+ }
+ }
+
+ #[test]
+ fn enumeration_error_keeps_adopted_pids_in_force() {
+ let mut state = PiggybackState::default();
+ // Healthy enumeration adopts {10, 20} over two ticks.
+ let healthy = snapshot_ok(vec![20, 10, 10]); // unsorted + dup: normalized
+ assert!(adopt_manual_snapshot(&mut state, &healthy).is_empty());
+ assert_eq!(adopt_manual_snapshot(&mut state, &healthy), vec![10, 20]);
+
+ // An errored snapshot (processes:[] + error:Some) must NOT feed
+ // adoption — two consecutive error ticks would otherwise adopt the
+ // empty set and tear down a healthy piggyback.
+ let errored = crate::meeting_processes::AudioProcessSnapshot {
+ supported: true,
+ processes: Vec::new(),
+ error: Some("enumeration blew up".into()),
+ };
+ assert_eq!(adopt_manual_snapshot(&mut state, &errored), vec![10, 20]);
+ assert_eq!(adopt_manual_snapshot(&mut state, &errored), vec![10, 20]);
+ assert!(
+ state.manual_pids_candidate.is_none(),
+ "error ticks must not seed a candidate"
+ );
+
+ // An unsupported snapshot is the same non-signal.
+ let unsupported = crate::meeting_processes::AudioProcessSnapshot::unsupported("plan9");
+ assert_eq!(adopt_manual_snapshot(&mut state, &unsupported), vec![10, 20]);
+
+ // Recovery: a HEALTHY empty snapshot ("everyone hung up their mic")
+ // does feed adoption again, through the normal two-tick damping.
+ let empty_ok = snapshot_ok(vec![]);
+ assert_eq!(adopt_manual_snapshot(&mut state, &empty_ok), vec![10, 20]);
+ assert!(adopt_manual_snapshot(&mut state, &empty_ok).is_empty());
+ }
+
+ #[test]
+ fn enumeration_error_leaves_pending_candidate_as_is() {
+ // A candidate awaiting its second sighting survives an error tick
+ // untouched: the error neither confirms nor refutes it.
+ let mut state = PiggybackState {
+ manual_pids_adopted: vec![10, 20],
+ manual_pids_candidate: Some(vec![10, 30]),
+ ..Default::default()
+ };
+ let errored = crate::meeting_processes::AudioProcessSnapshot {
+ supported: true,
+ processes: Vec::new(),
+ error: Some("transient".into()),
+ };
+ assert_eq!(adopt_manual_snapshot(&mut state, &errored), vec![10, 20]);
+ assert_eq!(state.manual_pids_candidate, Some(vec![10, 30]));
+ // Its next healthy sighting still completes adoption.
+ assert_eq!(
+ adopt_manual_snapshot(&mut state, &snapshot_ok(vec![30, 10])),
+ vec![10, 30]
+ );
+ }
+
#[test]
fn meeting_with_pid_starts_tap() {
let obs = base();
@@ -1588,6 +1764,7 @@ mod tests {
t.bundle_id = Some("us.zoom.xos".into());
t.mic_resolved_devices.insert("Rode NT (input)".into());
t.mic_session_started = true;
+ t.manual = true;
let s = build_meeting_summary(&t);
assert_eq!(s.outcome, "full_piggyback");
assert_eq!(s.meeting_seconds, 1800);
@@ -1600,7 +1777,10 @@ mod tests {
assert_eq!(s.meeting_app_bundle_id.as_deref(), Some("us.zoom.xos"));
assert_eq!(s.mic_resolved_devices, vec!["Rode NT (input)".to_string()]);
assert!(s.mic_session_started);
+ assert!(s.manual, "manual marker must survive into the summary");
assert_eq!(s.platform, std::env::consts::OS);
+ // Detected meetings stay segmentable: manual defaults to false.
+ assert!(!build_meeting_summary(&telem()).manual);
}
#[test]
diff --git a/crates/screenpipe-audio/src/meeting_detector.rs b/crates/screenpipe-audio/src/meeting_detector.rs
index 6f6fb5148..002b5cac0 100644
--- a/crates/screenpipe-audio/src/meeting_detector.rs
+++ b/crates/screenpipe-audio/src/meeting_detector.rs
@@ -35,14 +35,19 @@ fn now_ms() -> u64 {
/// `pid: None` is a legal published state meaning "a meeting is active but
/// the sensor that detected it can't identify the process" (ui_scan, a
/// post-restart reattach, or a `BlockedByActive` outcome where a different,
-/// already-active meeting owns the mic). Consumers must fall back to the
-/// stable (non-per-process) capture path in that case — this is not an
-/// error condition.
+/// already-active meeting owns the mic). For DETECTED meetings consumers
+/// must fall back to the stable (non-per-process) capture path in that
+/// case — this is not an error condition. The exception is `manual: true`:
+/// manual meetings never carry a sensor pid, and the piggyback sweep
+/// derives its tap targets from the live mic-holder enumeration instead of
+/// riding the stable path.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ActiveMeeting {
/// Detected meeting process. None when the sensor can't know one
- /// (ui_scan, post-restart reattach) — the piggyback layer must fall
- /// back to the stable capture path in that case.
+ /// (ui_scan, post-restart reattach) — the piggyback layer falls back
+ /// to the stable capture path then, EXCEPT when `manual` is true: a
+ /// manual meeting's pid is always None, and the sweep derives its tap
+ /// targets from the live mic-holder enumeration instead (see `manual`).
pub pid: Option<i32>,
pub bundle_id: Option<String>,
/// The user started this meeting manually — no sensor attributed a
diff --git a/crates/screenpipe-audio/src/meeting_processes.rs b/crates/screenpipe-audio/src/meeting_processes.rs
index fe21575f5..98ba4fb2d 100644
--- a/crates/screenpipe-audio/src/meeting_processes.rs
+++ b/crates/screenpipe-audio/src/meeting_processes.rs
@@ -522,8 +522,15 @@ mod platform {
_ => continue,
};
- // Globally-unique, lifetime-stable session id → drives engine
- // session identity / stickiness (ProcessKey).
+ // WASAPI SessionInstanceIdentifier: unique while the session
+ // lives, but PER-ENDPOINT — when the app switches input
+ // devices its session lands on a different endpoint and this
+ // id ROTATES. It feeds ProcessKey identity, so that rotation
+ // used to re-key the engine's meeting session on every in-app
+ // mic switch (riding the ending grace into an end/restart
+ // pair); the platform-based native keep-alive (67645e665) is
+ // what holds meetings together across it. Do NOT treat this
+ // id as lifetime-stable process identity.
let session_instance = control2
.GetSessionInstanceIdentifier()
.ok()
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/lifecycle.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/lifecycle.rs
index 2990f22b0..1f12f5526 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/lifecycle.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/lifecycle.rs
@@ -273,9 +273,17 @@ pub(crate) async fn apply_state_action(
meeting_id
);
*state = AudioProcessMeetingState::Idle;
- // A different meeting already owns the active slot; we
- // don't know its process identity from here.
- sync_meeting_flag(true, None, in_meeting_flag, detector);
+ // A different meeting already owns the active slot —
+ // BlockedByActive means "someone else owns it", so do not
+ // erase the owner's published identity. In particular a
+ // manual meeting's start route publishes
+ // ActiveMeeting{manual: true}; overwriting it with None
+ // here stripped the manual piggyback and false-fired the
+ // sweep's meeting-end edge for one tick. Preserve whatever
+ // the detector currently holds (None if nothing published).
+ let current_active_meeting =
+ detector.as_ref().and_then(|d| d.active_meeting());
+ sync_meeting_flag(true, current_active_meeting, in_meeting_flag, detector);
if let Ok(status) = resolve_meeting_status_from(db, manual_meeting).await {
emit_meeting_status_changed(&status);
}
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs
index c53f95f2e..58f00e0af 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/macos.rs
@@ -23,7 +23,9 @@ use crate::meeting_watcher::shared::profiles::MeetingDetectionProfile;
///
/// 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.
+/// via `little_arc_meet_candidate_excluding`, Arc-only, strictly shaped, and
+/// with AppleScript-visible full-window titles subtracted so an already
+/// URL-resolved full window can't re-enter off a slug-shaped tab title.
///
/// Only called while a browser candidate is still unresolved (same gating as
/// `ax_resolved_candidates`), so the ~100ms osascript round-trip runs at most
@@ -66,8 +68,21 @@ pub(crate) async fn active_tab_url_candidates(
if !app.eq_ignore_ascii_case("arc") {
return None;
}
+ // Subtract the AppleScript-visible FULL windows from
+ // the AX title set: their active-tab URLs were just
+ // resolved above as non-meeting, so a full window
+ // whose tab title is a code-shaped slug must not
+ // re-enter as Meet evidence. Little Arc windows have
+ // no AppleScript entry, so their titles survive.
+ let applescript_titles =
+ detector.get_window_titles(app, pid).unwrap_or_default();
let titles = crate::meeting_watcher::ui_scan::browser_window_titles(pid);
- little_arc_meet_candidate(app, &titles, &profiles)
+ little_arc_meet_candidate_excluding(
+ app,
+ &titles,
+ &applescript_titles,
+ &profiles,
+ )
})?;
let profile = profiles.get(candidate.profile_index)?;
let platform = platform_name_for_profile(profile, true);
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/mod.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/mod.rs
index 8b796c3f7..e40e1b6be 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/mod.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/mod.rs
@@ -132,12 +132,17 @@ pub async fn run_audio_process_meeting_detection_loop(
};
// Reattaching after a restart: the DB knows a meeting was active but
// the sensor has no live process snapshot to attribute it to yet.
+ // Derive `manual` from the meeting row's detection_source: this publish
+ // deterministically runs AFTER the app's capture-restart restore path
+ // (which publishes ActiveMeeting{manual: true} for manual meetings —
+ // see recording.rs), and hardcoding `manual: false` here clobbered
+ // that, stripping a restored manual meeting of its manual piggyback.
sync_meeting_flag(
true,
Some(screenpipe_audio::meeting_detector::ActiveMeeting {
pid: None,
bundle_id: None,
- manual: false,
+ manual: meeting.detection_source == "manual",
}),
&in_meeting_flag,
&detector,
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs
index c1feb9a8b..bff299f49 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/resolve.rs
@@ -151,21 +151,50 @@ pub(crate) fn arc_window_title_meet_code(title: &str) -> Option<&str> {
/// 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(
+///
+/// `excluded_titles` are the AppleScript-visible FULL-window titles: those
+/// windows' active-tab URLs were just resolved by the AppleScript probe (and
+/// did NOT match a meeting, or we wouldn't be in this fallback), so a full
+/// window whose tab title merely LOOKS like a meeting code (a lowercase 3-4-3
+/// kebab slug) must not fabricate a Meet meeting here. Little Arc windows are
+/// absent from Arc's AppleScript `windows` collection, so their titles
+/// survive the subtraction. Titles are trim-compared.
+pub(crate) fn little_arc_meet_candidate_excluding(
browser_app: &str,
window_titles: &[String],
+ excluded_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 title = title.trim();
+ if excluded_titles
+ .iter()
+ .any(|excluded| excluded.trim() == title)
+ {
+ return None;
+ }
+ let code = arc_window_title_meet_code(title)?;
let url = format!("https://meet.google.com/{}", code);
resolve_active_tab_url_candidate(browser_app, &url, profiles)
})
}
+/// `little_arc_meet_candidate_excluding` with no exclusions. Kept under the
+/// original name so existing callers/tests of the plain fallback stay valid;
+/// the live probe (`active_tab_url_candidates`) passes the AppleScript window
+/// titles through the `_excluding` variant.
+#[cfg_attr(not(test), allow(dead_code))]
+pub(crate) fn little_arc_meet_candidate(
+ browser_app: &str,
+ window_titles: &[String],
+ profiles: &[MeetingDetectionProfile],
+) -> Option<AxResolvedCandidate> {
+ little_arc_meet_candidate_excluding(browser_app, window_titles, &[], profiles)
+}
+
pub(crate) async fn db_find_browser_evidence(
db: &DatabaseManager,
) -> Result<Vec<BrowserPageEvidence>, sqlx::Error> {
@@ -862,3 +891,89 @@ pub(crate) async fn build_candidates(
.collect();
(candidates, live_candidates)
}
+
+#[cfg(test)]
+mod little_arc_exclusion_tests {
+ use super::*;
+ use crate::meeting_watcher::shared::profiles::load_detection_profiles;
+
+ fn titles(items: &[&str]) -> Vec<String> {
+ items.iter().map(|s| s.to_string()).collect()
+ }
+
+ #[test]
+ fn full_window_slug_title_is_excluded() {
+ // A FULL Arc window whose active-tab title happens to be a lowercase
+ // 3-4-3 kebab slug: the AppleScript probe already resolved that
+ // window's URL as non-meeting, so its title must not fabricate a
+ // Meet meeting via the Little Arc fallback.
+ let profiles = load_detection_profiles();
+ let ax_titles = titles(&["abc-defg-hij"]);
+ let applescript_titles = titles(&["abc-defg-hij"]);
+ assert!(little_arc_meet_candidate_excluding(
+ "Arc",
+ &ax_titles,
+ &applescript_titles,
+ &profiles
+ )
+ .is_none());
+ }
+
+ #[test]
+ fn little_arc_window_survives_exclusion() {
+ // Little Arc windows are absent from Arc's AppleScript `windows`
+ // collection: the AX title set contains the meeting-code window plus
+ // full windows, the exclusion list only the full windows' titles.
+ let profiles = load_detection_profiles();
+ let ax_titles = titles(&["My Docs - Notion", "abc-defg-hij"]);
+ let applescript_titles = titles(&["My Docs - Notion"]);
+ let candidate = little_arc_meet_candidate_excluding(
+ "Arc",
+ &ax_titles,
+ &applescript_titles,
+ &profiles,
+ )
+ .expect("Little Arc code title should resolve");
+ assert_eq!(
+ candidate.meeting_url.as_deref(),
+ Some("https://meet.google.com/abc-defg-hij")
+ );
+ }
+
+ #[test]
+ fn exclusion_is_trim_compared() {
+ // AX and AppleScript may disagree on surrounding whitespace for the
+ // same window title; the subtraction must still hit.
+ let profiles = load_detection_profiles();
+ let ax_titles = titles(&[" abc-defg-hij "]);
+ let applescript_titles = titles(&["abc-defg-hij "]);
+ assert!(little_arc_meet_candidate_excluding(
+ "Arc",
+ &ax_titles,
+ &applescript_titles,
+ &profiles
+ )
+ .is_none());
+ }
+
+ #[test]
+ fn empty_exclusion_matches_plain_fallback() {
+ let profiles = load_detection_profiles();
+ let ax_titles = titles(&["abc-defg-hij"]);
+ let with_empty =
+ little_arc_meet_candidate_excluding("Arc", &ax_titles, &[], &profiles);
+ let plain = little_arc_meet_candidate("Arc", &ax_titles, &profiles);
+ assert_eq!(with_empty.is_some(), plain.is_some());
+ assert!(with_empty.is_some());
+ }
+
+ #[test]
+ fn non_arc_browsers_never_resolve() {
+ let profiles = load_detection_profiles();
+ let ax_titles = titles(&["abc-defg-hij"]);
+ assert!(
+ little_arc_meet_candidate_excluding("Google Chrome", &ax_titles, &[], &profiles)
+ .is_none()
+ );
+ }
+}
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/state.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/state.rs
index ec1967644..ed56642c0 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/state.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/state.rs
@@ -355,7 +355,10 @@ fn advance_from_active(
session_candidates: &[ResolvedMeetingCandidate],
now: Instant,
) -> (AudioProcessMeetingState, Option<AudioProcessStateAction>) {
- if session_present(
+ // Adopt the matching candidate's key: a platform-only native keep-alive
+ // means the session was re-keyed by a mic switch, and the eventual
+ // end-of-meeting suppression must target the LIVE key, not the stale one.
+ if let Some(adopted_key) = matching_session_key(
session_candidates,
&session_key,
&platform,
@@ -365,7 +368,7 @@ fn advance_from_active(
AudioProcessMeetingState::Active {
meeting_id,
platform,
- session_key,
+ session_key: adopted_key,
meeting_url,
first_seen_at,
last_seen_at: now,
@@ -404,7 +407,10 @@ fn advance_from_ending(
now: Instant,
ending_grace: Duration,
) -> (AudioProcessMeetingState, Option<AudioProcessStateAction>) {
- if session_present(
+ // Revive with the matching candidate's key (see `advance_from_active`):
+ // a re-keyed native session mid-grace must leave the state carrying the
+ // live key so end-of-meeting suppression works.
+ if let Some(adopted_key) = matching_session_key(
session_candidates,
&session_key,
&platform,
@@ -414,7 +420,7 @@ fn advance_from_ending(
AudioProcessMeetingState::Active {
meeting_id,
platform,
- session_key,
+ session_key: adopted_key,
meeting_url,
first_seen_at,
last_seen_at: now,
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/suppress.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/suppress.rs
index 4720e92c1..36598c4a8 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/suppress.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/suppress.rs
@@ -5,12 +5,29 @@
use super::*;
+/// Boolean facade over [`matching_session_key`] for callers that only need
+/// presence, not the (possibly adopted) key.
+#[allow(dead_code)]
pub(crate) fn session_present(
candidates: &[ResolvedMeetingCandidate],
session_key: &ProcessKey,
platform: &str,
meeting_url: Option<&str>,
) -> bool {
+ matching_session_key(candidates, session_key, platform, meeting_url).is_some()
+}
+
+/// Returns the session key the live state should carry when some candidate
+/// keeps this meeting alive, or `None` when nothing does. Exact-key matches
+/// (and reattached sessions) return the EXISTING key unchanged; the
+/// platform-only native fallback returns the MATCHING CANDIDATE's key so the
+/// state ADOPTS the re-keyed session.
+pub(crate) fn matching_session_key(
+ candidates: &[ResolvedMeetingCandidate],
+ session_key: &ProcessKey,
+ platform: &str,
+ meeting_url: Option<&str>,
+) -> Option<ProcessKey> {
// A reattached meeting (adopted from the DB after a restart) has a synthetic
// session key and no real process/url to reconcile against — and a browser
// meeting (e.g. Google Meet) can take several poll cycles to re-resolve its
@@ -18,35 +35,28 @@ pub(crate) fn session_present(
// Keep it alive while *any* live meeting session is present; genuine
// disappearance still flows through the normal ending grace.
if session_key.is_reattached() {
- return candidates.iter().any(|candidate| {
- matches!(
- candidate,
- ResolvedMeetingCandidate::Native { .. }
- | ResolvedMeetingCandidate::Browser { .. }
- | ResolvedMeetingCandidate::UnresolvedBrowser { .. }
- )
- });
+ return candidates
+ .iter()
+ .any(|candidate| {
+ matches!(
+ candidate,
+ ResolvedMeetingCandidate::Native { .. }
+ | ResolvedMeetingCandidate::Browser { .. }
+ | ResolvedMeetingCandidate::UnresolvedBrowser { .. }
+ )
+ })
+ .then(|| session_key.clone());
}
- // Non-reattached sessions must match on the real process key (the
- // `is_reattached()` branch above is the only place a synthetic key matches).
- candidates.iter().any(|candidate| match candidate {
- // A native meeting's session key is NOT stable across the app
- // switching input devices: macOS synthesized it from the device set
- // the process records from (fixed to pid-keying now, but stale keys
- // can persist in live state), and Windows WASAPI sessions are
- // per-endpoint, so picking a different mic mints a new GUID. Ending a
- // live call over that rotation — Active → Ending → 20s grace →
- // EndMeeting, then an instant "new" meeting under the new key — tears
- // capture down for ~20s per mic switch. The same native platform
- // holding ANY mic is proof the call is ongoing, so keep-alive matches
- // on platform alone; keys still gate meeting START. (One audio-holding
- // process per native platform is the operating assumption, and
- // back-to-back calls in the same app were already glued by the
- // ending grace.)
+ // Non-reattached sessions match on the real process key first (the
+ // `is_reattached()` branch above is the only place a synthetic key
+ // matches); an exact match takes precedence over the platform-only native
+ // fallback below and keeps the existing key.
+ let exact_match = candidates.iter().any(|candidate| match candidate {
ResolvedMeetingCandidate::Native {
platform: candidate_platform,
+ session_key: key,
..
- } => meeting_url.is_none() && candidate_platform == platform,
+ } => meeting_url.is_none() && candidate_platform == platform && key == session_key,
// A confirmed browser meeting is keyed by its audio session. Once it is
// live, the same browser audio session still holding the mic is sufficient
// proof the call is ongoing — so keep it alive on the `session_key` alone.
@@ -67,6 +77,32 @@ pub(crate) fn session_present(
session_key: key, ..
} => key == session_key,
_ => false,
+ });
+ if exact_match {
+ return Some(session_key.clone());
+ }
+ // A native meeting's session key is NOT stable across the app switching
+ // input devices: macOS synthesized it from the device set the process
+ // records from (fixed to pid-keying now, but stale keys can persist in
+ // live state), and Windows WASAPI sessions are per-endpoint, so picking a
+ // different mic mints a new GUID. Ending a live call over that rotation —
+ // Active → Ending → 20s grace → EndMeeting, then an instant "new" meeting
+ // under the new key — tears capture down for ~20s per mic switch. The same
+ // native platform holding ANY mic is proof the call is ongoing, so
+ // keep-alive matches on platform alone; keys still gate meeting START.
+ // (One audio-holding process per native platform is the operating
+ // assumption, and back-to-back calls in the same app were already glued by
+ // the ending grace.) Crucially the state ADOPTS the matching candidate's
+ // key: keeping the stale key would make the eventual end-of-meeting
+ // suppression target a dead session, letting the live one instantly
+ // restart the meeting the user just stopped.
+ candidates.iter().find_map(|candidate| match candidate {
+ ResolvedMeetingCandidate::Native {
+ platform: candidate_platform,
+ session_key: key,
+ ..
+ } if meeting_url.is_none() && candidate_platform == platform => Some(key.clone()),
+ _ => None,
})
}
diff --git a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs
index dd7505b65..a3f42086a 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/audio_process/tests.rs
@@ -1654,7 +1654,7 @@ fn native_meeting_survives_mic_switch_rekey() {
let candidates = [ResolvedMeetingCandidate::Native {
platform: "Zoom".to_string(),
- session_key: new_key,
+ session_key: new_key.clone(),
first_seen_at: now,
process: samsung,
}];
@@ -1676,13 +1676,18 @@ fn native_meeting_survives_mic_switch_rekey() {
Duration::from_secs(20),
);
assert!(action.is_none(), "expected no action, got {action:?}");
- assert!(
- matches!(
- next,
- AudioProcessMeetingState::Active { meeting_id: 67, .. }
+ match next {
+ AudioProcessMeetingState::Active {
+ meeting_id: 67,
+ session_key,
+ ..
+ } => assert_eq!(
+ session_key, new_key,
+ "active state must adopt the re-keyed session so end-of-meeting \
+ suppression targets the live process"
),
- "meeting must stay active across a mic-switch re-key, got {next:?}"
- );
+ other => panic!("meeting must stay active across a mic-switch re-key, got {other:?}"),
+ }
}
#[test]
@@ -1697,10 +1702,11 @@ fn ending_native_meeting_revives_on_rekeyed_session() {
let mut samsung = zoom_process();
samsung.audio_session_id = Some("coreaudio-process:200:input:samsung-uid".to_string());
+ let new_key = ProcessKey::from_process(&samsung).unwrap();
let candidates = [ResolvedMeetingCandidate::Native {
platform: "Zoom".to_string(),
- session_key: ProcessKey::from_process(&samsung).unwrap(),
+ session_key: new_key.clone(),
first_seen_at: now,
process: samsung,
}];
@@ -1722,11 +1728,115 @@ fn ending_native_meeting_revives_on_rekeyed_session() {
Duration::from_secs(20),
);
assert!(action.is_none(), "expected no action, got {action:?}");
- assert!(
- matches!(
- next,
- AudioProcessMeetingState::Active { meeting_id: 67, .. }
+ match next {
+ AudioProcessMeetingState::Active {
+ meeting_id: 67,
+ session_key,
+ ..
+ } => assert_eq!(
+ session_key, new_key,
+ "revived state must adopt the re-keyed session so end-of-meeting \
+ suppression targets the live process"
),
- "ending meeting must revive on a re-keyed session, got {next:?}"
+ other => panic!("ending meeting must revive on a re-keyed session, got {other:?}"),
+ }
+}
+
+#[test]
+fn end_after_mic_switch_rekey_suppresses_adopted_session_key() {
+ // The suppression consequence of key adoption: after a mic switch re-keys
+ // the native session, the Active state must carry the NEW candidate key,
+ // so when the meeting ends the EndMeeting action suppresses the LIVE
+ // session. Suppressing the stale pre-switch key would be a no-op (Windows
+ // WASAPI keys are per-endpoint GUIDs, so the dead key never matches) and
+ // the process still holding the mic would instantly restart the meeting
+ // the user just stopped.
+ let now = Instant::now();
+ let mut airpods = zoom_process();
+ airpods.audio_session_id = Some("coreaudio-process:200:input:airpods-uid".to_string());
+ let old_key = ProcessKey::from_process(&airpods).unwrap();
+
+ let mut samsung = zoom_process();
+ samsung.audio_session_id = Some("coreaudio-process:200:input:samsung-uid".to_string());
+ let new_key = ProcessKey::from_process(&samsung).unwrap();
+ assert_ne!(old_key, new_key, "fixture must model a re-keyed session");
+
+ let candidates = [ResolvedMeetingCandidate::Native {
+ platform: "Zoom".to_string(),
+ session_key: new_key.clone(),
+ first_seen_at: now,
+ process: samsung.clone(),
+ }];
+
+ // Mic switch mid-meeting: the platform-only keep-alive fires and the
+ // state adopts the new key.
+ let (active, action) = advance_audio_process_state(
+ AudioProcessMeetingState::Active {
+ meeting_id: 67,
+ platform: "Zoom".to_string(),
+ session_key: old_key.clone(),
+ meeting_url: None,
+ first_seen_at: now - Duration::from_secs(120),
+ last_seen_at: now - Duration::from_secs(1),
+ is_browser: false,
+ },
+ &[],
+ &candidates,
+ now,
+ Duration::from_secs(1),
+ Duration::from_secs(20),
+ );
+ assert!(action.is_none(), "expected no action, got {action:?}");
+
+ // The call winds down: no candidates → Ending.
+ let (ending, action) = advance_audio_process_state(
+ active,
+ &[],
+ &[],
+ now + Duration::from_secs(1),
+ Duration::from_secs(1),
+ Duration::from_secs(20),
+ );
+ assert!(
+ matches!(ending, AudioProcessMeetingState::Ending { .. }),
+ "expected Ending, got {ending:?}"
+ );
+ assert!(action.is_none(), "expected no action, got {action:?}");
+
+ // Past the ending grace → EndMeeting, whose suppression must carry the
+ // ADOPTED key, not the stale pre-switch one.
+ let (_idle, action) = advance_audio_process_state(
+ ending,
+ &[],
+ &[],
+ now + Duration::from_secs(22),
+ Duration::from_secs(1),
+ Duration::from_secs(20),
+ );
+ let Some(AudioProcessStateAction::EndMeeting {
+ meeting_id: 67,
+ suppressed_session: Some(suppressed),
+ }) = action
+ else {
+ panic!("expected EndMeeting with a suppressed session, got {action:?}");
+ };
+ assert_eq!(
+ suppressed.session_key, new_key,
+ "suppression must target the adopted (live) key, not the stale pre-switch key"
+ );
+
+ // And the suppression must actually bite: the process still holding the
+ // mic under the new key is filtered out, so the just-ended meeting cannot
+ // instantly restart.
+ let mut live_candidates = vec![ResolvedMeetingCandidate::Native {
+ platform: "Zoom".to_string(),
+ session_key: new_key,
+ first_seen_at: now + Duration::from_secs(22),
+ process: samsung,
+ }];
+ filter_suppressed_candidates(&mut live_candidates, &[suppressed]);
+ assert!(
+ live_candidates.is_empty(),
+ "the live re-keyed session must stay suppressed after the meeting ends"
);
}
diff --git a/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs b/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs
index 700338051..890391616 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/shared/ignore.rs
@@ -176,10 +176,23 @@ pub(crate) fn browser_window_matches_meeting(
/// 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.
+/// URL-first rule of `browser_window_matches_meeting`, AND only when the
+/// title also carries a Google-Meet-code-shaped token (see
+/// `title_contains_meeting_code`). 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.
+///
+/// The meeting-code gate deliberately narrows the AX-sweep escalation added
+/// in ff0337416: the sweep is NOT gated on the browser holding the mic, so an
+/// anchored-but-ordinary title ("Meet the Team - Acme", "Meet Kevin -
+/// YouTube", "Meet: quarterly planning") in any open browser window was
+/// enough live evidence to start a false meeting. Only the Google Meet
+/// profile declares `browser_title_patterns` today, and every real
+/// Chrome/Edge pop-out title embeds the meeting code, so requiring it costs
+/// no genuine detection. The mic-gated URL probe and DB-evidence paths
+/// (`browser_window_matches_meeting`) are unchanged, and non-Meet platforms
+/// keep their coverage via URL patterns and the Windows UIA path.
pub(crate) fn ax_window_matches_meeting(
doc: Option<&str>,
title: Option<&str>,
@@ -206,7 +219,7 @@ pub(crate) fn ax_window_matches_meeting(
{
return true;
}
- if doc.is_none() {
+ if doc.is_none() && title_contains_meeting_code(title) {
let title_lower = title.to_lowercase();
if ids
.browser_title_patterns
@@ -220,6 +233,40 @@ pub(crate) fn ax_window_matches_meeting(
false
}
+/// True when `title` contains a standalone Google-Meet-code-shaped token:
+/// lowercase `[a-z]{3}-[a-z]{4}-[a-z]{3}` bounded by non-alphanumeric,
+/// non-`-` characters (or the string ends). `-` is treated as extending the
+/// token so a code-shaped run inside a longer kebab slug
+/// ("how-to-run-fast-fyi") does not count as standalone.
+///
+/// A real Chrome/Edge Meet pop-out is titled "Meet – abc-defg-hij"; this is
+/// the gate `ax_window_matches_meeting` applies on top of the anchored
+/// `browser_title_patterns` fallback for URL-less windows. Byte-level scan is
+/// UTF-8 safe: multi-byte separators (the en dash above) have non-ASCII bytes,
+/// which neither form the code nor extend the token.
+pub(crate) fn title_contains_meeting_code(title: &str) -> bool {
+ const CODE_LEN: usize = 12; // aaa-bbbb-ccc
+ let bytes = title.as_bytes();
+ if bytes.len() < CODE_LEN {
+ return false;
+ }
+ let is_code_at = |start: usize| {
+ bytes[start..start + CODE_LEN]
+ .iter()
+ .enumerate()
+ .all(|(i, &b)| match i {
+ 3 | 8 => b == b'-',
+ _ => b.is_ascii_lowercase(),
+ })
+ };
+ let extends_token = |b: u8| b.is_ascii_alphanumeric() || b == b'-';
+ (0..=bytes.len() - CODE_LEN).any(|start| {
+ is_code_at(start)
+ && (start == 0 || !extends_token(bytes[start - 1]))
+ && (start + CODE_LEN == bytes.len() || !extends_token(bytes[start + CODE_LEN]))
+ })
+}
+
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/tests.rs b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs
index 0c7f99f3c..0e4b9bfa2 100644
--- a/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs
+++ b/crates/screenpipe-engine/src/meeting_watcher/ui_scan/tests.rs
@@ -2807,11 +2807,7 @@ fn ax_window_popout_title_matches_without_document_url() {
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
- ];
+ let popout_titles = ["Meet – abc-defg-hij", "Meet - abc-defg-hij - Google Chrome"];
for title in &popout_titles {
assert!(
ax_window_matches_meeting(None, Some(title), meet),
@@ -2821,6 +2817,63 @@ fn ax_window_popout_title_matches_without_document_url() {
}
}
+#[test]
+fn ax_window_title_fallback_requires_meeting_code() {
+ // The AX sweep is NOT gated on the browser holding the mic, so anchored
+ // titles that are ordinary pages must not become live meeting evidence.
+ // The URL-less title fallback additionally requires a standalone
+ // Meet-code-shaped token (see `title_contains_meeting_code`).
+ let profiles = load_detection_profiles();
+ let meet = google_meet_profile(&profiles);
+
+ let anchored_but_ordinary_titles = [
+ "Meet the Team | Acme",
+ "Meet Kevin - YouTube",
+ "Meet: quarterly planning",
+ // Arc's bare "Meet" main-window title no longer resolves via the AX
+ // sweep; Arc keeps coverage through the mic-gated AppleScript URL
+ // probe, the Little Arc code-title fallback, and DB frame evidence
+ // (`browser_window_matches_meeting`, which is unchanged).
+ "Meet",
+ ];
+ for title in &anchored_but_ordinary_titles {
+ assert!(
+ !ax_window_matches_meeting(None, Some(title), meet),
+ "anchored non-call title {:?} must NOT match without a meeting code",
+ title
+ );
+ }
+}
+
+#[test]
+fn title_contains_meeting_code_requires_standalone_lowercase_token() {
+ // Real pop-out shapes.
+ assert!(title_contains_meeting_code("Meet – abc-defg-hij"));
+ assert!(title_contains_meeting_code(
+ "Meet - abc-defg-hij - Google Chrome"
+ ));
+ assert!(title_contains_meeting_code("abc-defg-hij"));
+
+ // No code at all.
+ assert!(!title_contains_meeting_code("Meet the Team | Acme"));
+ assert!(!title_contains_meeting_code("Meet Kevin - YouTube"));
+ assert!(!title_contains_meeting_code("Meet: quarterly planning"));
+ assert!(!title_contains_meeting_code("Meet"));
+
+ // Wrong shape: uppercase, digits, wrong segment lengths.
+ assert!(!title_contains_meeting_code("Meet – ABC-DEFG-HIJ"));
+ assert!(!title_contains_meeting_code("Meet – ab1-defg-hij"));
+ assert!(!title_contains_meeting_code("Meet – ab-defg-hij"));
+ assert!(!title_contains_meeting_code("Meet – abc-def-hij"));
+
+ // Code-shaped run embedded in a longer kebab slug or word is not
+ // standalone: `-` and alphanumerics extend the token on both sides.
+ assert!(!title_contains_meeting_code("how-to-run-fast-fyi"));
+ assert!(!title_contains_meeting_code("xabc-defg-hij"));
+ assert!(!title_contains_meeting_code("abc-defg-hijx"));
+ assert!(!title_contains_meeting_code("abc-defg-hij9"));
+}
+
#[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
diff --git a/crates/screenpipe-screen/src/browser_utils/macos.rs b/crates/screenpipe-screen/src/browser_utils/macos.rs
index d219298a6..f78dc2644 100644
--- a/crates/screenpipe-screen/src/browser_utils/macos.rs
+++ b/crates/screenpipe-screen/src/browser_utils/macos.rs
@@ -5,7 +5,7 @@
use accessibility_sys::{
kAXChildrenAttribute, kAXDocumentAttribute, kAXFocusedWindowAttribute, kAXRoleAttribute,
kAXTextFieldRole, kAXValueAttribute, kAXWindowsAttribute, AXUIElementCopyAttributeValue,
- AXUIElementCreateApplication, AXUIElementRef,
+ AXUIElementCreateApplication, AXUIElementRef, AXUIElementSetMessagingTimeout,
};
use anyhow::Result;
use core_foundation::{
@@ -24,6 +24,17 @@ use super::{titles_match, BrowserUrlDetector};
/// the whole budget on one browser.
const MAX_PROBED_WINDOWS: usize = 16;
+/// Per-element AX messaging timeout for the all-window probe, replacing the
+/// ~6s system default. Budget math: the probe issues up to 17 synchronous AX
+/// IPCs (1 windows-list read + up to `MAX_PROBED_WINDOWS` AXDocument reads),
+/// so 17 × 1s worst case still exceeds the caller's 3s tokio timeout — but
+/// that timeout only *abandons* the blocking thread, it cannot stop it. With
+/// the default, a hung browser pinned the thread ~6s per IPC while the
+/// 1s-cadence caller kept spawning more; with 1s it fails fast on the FIRST
+/// call. The focused-window fast path (`get_url_via_accessibility`) is
+/// unchanged.
+const AX_PROBE_MESSAGING_TIMEOUT_SECS: f32 = 1.0;
+
pub struct MacOSUrlDetector;
impl Default for MacOSUrlDetector {
@@ -271,6 +282,40 @@ end tell"#;
Ok(urls)
}
+ /// Title of EVERY Arc window in one AppleScript call, mirroring
+ /// `get_arc_all_window_urls` (per-window `try` guard, front-to-back
+ /// order). Like the URL enumeration, Little Arc mini windows are NOT in
+ /// the `windows` collection — so this is exactly the set of full windows
+ /// whose active-tab URL the AppleScript probe can (and did) resolve,
+ /// which is what the meeting probe subtracts from the AX title set before
+ /// its Little Arc meeting-code fallback.
+ fn get_arc_all_window_titles(&self) -> Result<Vec<String>> {
+ let script = r#"tell application "Arc"
+ set out to ""
+ repeat with w in windows
+ try
+ set out to out & (name 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)?;
+ Ok(raw
+ .lines()
+ .map(str::trim)
+ .filter(|title| !title.is_empty())
+ .map(str::to_string)
+ .collect())
+ }
+
/// All-window URL enumeration for the meeting probe.
///
/// The focused window keeps the full `get_active_url` path (AXDocument,
@@ -286,6 +331,12 @@ end tell"#;
unsafe {
let app_element = AXUIElementCreateApplication(process_id);
+ // See AX_PROBE_MESSAGING_TIMEOUT_SECS: bound each synchronous AX
+ // IPC so a hung browser fails fast instead of pinning the
+ // abandoned blocking thread ~6s (system default) per call. The
+ // timeout is per AXUIElement, so the window elements below need
+ // their own.
+ let _ = AXUIElementSetMessagingTimeout(app_element, AX_PROBE_MESSAGING_TIMEOUT_SECS);
let mut windows_ref: CFTypeRef = std::ptr::null_mut();
let status = AXUIElementCopyAttributeValue(
@@ -302,9 +353,12 @@ end tell"#;
if i >= MAX_PROBED_WINDOWS {
break;
}
+ let window = *window as AXUIElementRef;
+ let _ =
+ AXUIElementSetMessagingTimeout(window, AX_PROBE_MESSAGING_TIMEOUT_SECS);
// 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 let Some(url) = self.window_document_url(window) {
if !urls.contains(&url) {
urls.push(url);
}
@@ -386,4 +440,16 @@ impl BrowserUrlDetector for MacOSUrlDetector {
self.get_window_urls_via_accessibility(process_id)
}
}
+
+ /// Titles of the windows visible to Arc's AppleScript `windows`
+ /// collection (the same windows `get_window_urls` resolves URLs for).
+ /// Other browsers keep the default empty answer — the meeting probe only
+ /// needs this for Arc's Little Arc exclusion.
+ fn get_window_titles(&self, app_name: &str, _process_id: i32) -> Result<Vec<String>> {
+ if app_name == "Arc" {
+ self.get_arc_all_window_titles()
+ } else {
+ Ok(Vec::new())
+ }
+ }
}
diff --git a/crates/screenpipe-screen/src/browser_utils/mod.rs b/crates/screenpipe-screen/src/browser_utils/mod.rs
index a359f50fb..e1545ffc1 100644
--- a/crates/screenpipe-screen/src/browser_utils/mod.rs
+++ b/crates/screenpipe-screen/src/browser_utils/mod.rs
@@ -27,6 +27,17 @@ pub trait BrowserUrlDetector {
.into_iter()
.collect())
}
+
+ /// Titles of the browser windows the detector can enumerate natively
+ /// (e.g. Arc's AppleScript `windows` collection on macOS).
+ ///
+ /// Used by the meeting probe to subtract full windows — whose active-tab
+ /// URL `get_window_urls` already resolved — from AX-title fallbacks that
+ /// only see windows invisible to the native enumeration (Little Arc).
+ /// Default: no native enumeration, nothing to subtract.
+ fn get_window_titles(&self, _app_name: &str, _process_id: i32) -> Result<Vec<String>> {
+ Ok(Vec::new())
+ }
}
// Factory function