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 Intel macOS launch crash and make vision smoke deterministic (#5126)
Louis Beaumont0fca56ea555b
diff --git a/.github/workflows/macos-intel-launch-smoke.yml b/.github/workflows/macos-intel-launch-smoke.ymlindex 8a4a27c6f..4046869f0 100644--- a/.github/workflows/macos-intel-launch-smoke.yml+++ b/.github/workflows/macos-intel-launch-smoke.yml@@ -233,12 +233,14 @@ jobs:# looks at reports generated by *this* launch.BEFORE_EPOCH=$(date +%s)- # onboarding-only (no `no-recording`): vision/audio stay enabled so- # the real capture pipeline — the thing #4968 crashes in — actually- # runs. This is the exact override e2e/helpers/app-launcher.ts's- # comment describes for hosts that do have TCC granted.+ # Keep real vision capture enabled while skipping audio/model startup.+ # This lane targets the Intel ScreenCaptureKit path from #4968; cold+ # Whisper/VAD/diarization initialization can consume the entire watch+ # window before VisionManager starts and turn a healthy launch red.+ # `no-audio` is the existing vision-only E2E mode documented by+ # e2e/helpers/app-launcher.ts.SCREENPIPE_DATA_DIR="$DATA_DIR" \- SCREENPIPE_E2E_SEED="onboarding" \+ SCREENPIPE_E2E_SEED="onboarding,no-audio" \SCREENPIPE_FOCUS_PORT="11436" \RUST_BACKTRACE=1 \"$APP_BIN" >"$LOG" 2>&1 &diff --git a/Cargo.lock b/Cargo.lockindex b79c5d045..360434798 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1401,11 +1401,11 @@ dependencies = [[[package]]name = "cidre"-version = "0.13.1"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "aeb5b1ace98faf1a55e3631d63427f267897cfab7b65b1d5928cb0b8e6a4a194"+version = "0.15.1"+source = "git+https://github.com/yury/cidre.git?rev=8481f3f0dc7dd39bb5be80d9424bfac0cad3801a#8481f3f0dc7dd39bb5be80d9424bfac0cad3801a"dependencies = [- "cidre-macros 0.4.0",+ "cc",+ "cidre-macros 0.5.0","half","parking_lot","tokio",@@ -1414,7 +1414,7 @@ dependencies = [[[package]]name = "cidre"version = "0.15.1"-source = "git+https://github.com/yury/cidre.git?rev=8481f3f0dc7dd39bb5be80d9424bfac0cad3801a#8481f3f0dc7dd39bb5be80d9424bfac0cad3801a"+source = "git+https://github.com/yury/cidre.git#8481f3f0dc7dd39bb5be80d9424bfac0cad3801a"dependencies = ["cc","cidre-macros 0.5.0",@@ -1425,11 +1425,11 @@ dependencies = [[[package]]name = "cidre"-version = "0.15.1"-source = "git+https://github.com/yury/cidre.git#8481f3f0dc7dd39bb5be80d9424bfac0cad3801a"+version = "0.16.1"+source = "git+https://github.com/yury/cidre.git?rev=8d0f7307d201d75328ed82ea0d4ca7bb0a649716#8d0f7307d201d75328ed82ea0d4ca7bb0a649716"dependencies = ["cc",- "cidre-macros 0.5.0",+ "cidre-macros 0.6.0","half","parking_lot","tokio",@@ -1437,15 +1437,15 @@ dependencies = [[[package]]name = "cidre-macros"-version = "0.4.0"+version = "0.5.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5da2cdee573cf967cf4fec1f95f12a16dce31efb6d104238a8cb114cbdae1780"+checksum = "6facfeffa8b9792dc014bb4e65e364d13518b74e06783d56249810a3e48cfad7"[[package]]name = "cidre-macros"-version = "0.5.0"+version = "0.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6facfeffa8b9792dc014bb4e65e364d13518b74e06783d56249810a3e48cfad7"+checksum = "3f32b3f1473b6147c2cf3a3f76ad680f49c95fb36a0292425af5e019132f3236"[[package]]name = "cipher"@@ -8125,7 +8125,7 @@ dependencies = ["arboard","arc-swap","chrono",- "cidre 0.13.1",+ "cidre 0.16.1","core-foundation 0.10.1","core-graphics","crossbeam-channel",diff --git a/crates/screenpipe-a11y/Cargo.toml b/crates/screenpipe-a11y/Cargo.tomlindex 09a80e4fb..ae419ed1e 100644--- a/crates/screenpipe-a11y/Cargo.toml+++ b/crates/screenpipe-a11y/Cargo.toml@@ -48,7 +48,7 @@ rusqlite = { version = "0.29", features = ["bundled"] }url = { workspace = true }[target.'cfg(target_os = "macos")'.dependencies]-cidre = { version = "0.13", features = ["ax", "cg", "blocks", "ns", "app", "dispatch"] }+cidre = { git = "https://github.com/yury/cidre.git", rev = "8d0f7307d201d75328ed82ea0d4ca7bb0a649716", features = ["ax", "cg", "blocks", "ns", "app", "dispatch"] }objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "NSPasteboard"] }# Window-server frontmost-app query (CGWindowList) — the run-loop-free# source of truth the focused-app resolver cross-checks AX focus against.diff --git a/crates/screenpipe-a11y/src/platform/macos.rs b/crates/screenpipe-a11y/src/platform/macos.rsindex a8fb80913..af58505a4 100644--- a/crates/screenpipe-a11y/src/platform/macos.rs+++ b/crates/screenpipe-a11y/src/platform/macos.rs@@ -2570,6 +2570,16 @@ mod tests {assert!(!is_own_process((std::process::id() as i32) + 1));}+ #[test]+ fn test_ax_status_errors_return_without_aborting() {+ for status in [-25204, -25205] {+ let error = cidre::os::Status(status)+ .result()+ .expect_err("AX failure status should return an error");+ assert_eq!(error.status(), cidre::os::Status(status));+ }+ }+#[test]fn test_get_clipboard_returns_option() {// Should not panic regardless of clipboard statediff --git a/crates/screenpipe-a11y/src/tree/macos.rs b/crates/screenpipe-a11y/src/tree/macos.rsindex c2d53f68d..ed1789cb7 100644--- a/crates/screenpipe-a11y/src/tree/macos.rs+++ b/crates/screenpipe-a11y/src/tree/macos.rs@@ -1047,22 +1047,22 @@ fn parse_xterm_bare_desc(val: &str) -> Option<String> {// 2026-07-10). `children()` stays separate (needed as elements for traversal)// and the parameterized line-bounds subsystem is left alone.//-// cidre 0.13.1 does not wrap this API, so declare it here, mirroring cidre's+// cidre does not wrap this API, so declare it here, mirroring cidre's// own extern pattern (see `AXUIElementGetPid` in cidre `src/ax/ui_element.rs`).#[link(name = "ApplicationServices", kind = "framework")]unsafe extern "C-unwind" {fn AXUIElementCopyMultipleAttributeValues(element: &ax::UiElement,- attributes: &cf::Array, // of cf::String attribute names- options: u32, // 0 — parallel array, NOT stop-on-error (1)- values: *mut Option<arc::R<cf::Array>>,+ attributes: &cf::ArrayOf<ax::Attr>,+ options: u32, // 0 — parallel array, NOT stop-on-error (1)+ values: *mut Option<arc::R<cf::ArrayOf<cf::Type>>>,) -> ax::Error;}thread_local! {/// The six attribute names, in request order, built once per walker thread./// The returned values array is parallel to this list (index-for-index).- static BATCH_ATTR_NAMES: arc::R<cf::Array> = {+ static BATCH_ATTR_NAMES: arc::R<cf::ArrayOf<ax::Attr>> = {let names: [&ax::Attr; 6] = [ax::attr::role(),ax::attr::value(),@@ -1071,14 +1071,14 @@ thread_local! {ax::attr::pos(),ax::attr::size(),];- cf::Array::from_slice(&names).expect("batch attr name array")+ cf::ArrayOf::from_slice(&names)};/// The automation-prop attribute names read by `fill_ax_props`, in request/// order. Batched separately from the primary six because `fill_ax_props`/// runs only for text-emitting nodes — folding these into the per-node batch/// would marshal 10 extra attrs for every container/skipped node too.- static FILL_ATTR_NAMES: arc::R<cf::Array> = {+ static FILL_ATTR_NAMES: arc::R<cf::ArrayOf<ax::Attr>> = {let names: [&ax::Attr; 10] = [ax::attr::id(), // 0 automation_idax::attr::subrole(), // 1 subrole@@ -1091,7 +1091,7 @@ thread_local! {ax::attr::selected(), // 8 is_selected (interactive)ax::attr::expanded(), // 9 is_expanded (interactive)];- cf::Array::from_slice(&names).expect("fill attr name array")+ cf::ArrayOf::from_slice(&names)};}@@ -1156,7 +1156,7 @@ fn batch_bool(entry: &cf::Type) -> Option<bool> {/// messaging timeout) — the same conditions under which the old `elem.role()`/// read would have failed and the node been skipped without walking children.fn read_node_attrs(elem: &ax::UiElement) -> Option<NodeAttrs> {- let mut out: Option<arc::R<cf::Array>> = None;+ let mut out: Option<arc::R<cf::ArrayOf<cf::Type>>> = None;// options = 0: the returned array is parallel to the request, with// AXError placeholders for missing attrs. Never stop-on-error (1) — one// missing attr would kill the whole batch.@@ -1188,8 +1188,8 @@ fn read_node_attrs(elem: &ax::UiElement) -> Option<NodeAttrs> {/// Returns the parallel values array (indices match `FILL_ATTR_NAMES`), or/// `None` on a failed batch — matching the old path, where every individual/// read would have failed and left each prop `None`.-fn read_fill_attrs(elem: &ax::UiElement) -> Option<arc::R<cf::Array>> {- let mut out: Option<arc::R<cf::Array>> = None;+fn read_fill_attrs(elem: &ax::UiElement) -> Option<arc::R<cf::ArrayOf<cf::Type>>> {+ let mut out: Option<arc::R<cf::ArrayOf<cf::Type>>> = None;let status = FILL_ATTR_NAMES.with(|names| unsafe { AXUIElementCopyMultipleAttributeValues(elem, names, 0, &mut out) });if !status.is_ok() {diff --git a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs b/crates/screenpipe-screen/src/capture_screenshot_by_window.rsindex f23bd03d5..7f72a5dfe 100644--- a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs+++ b/crates/screenpipe-screen/src/capture_screenshot_by_window.rs@@ -392,6 +392,7 @@ impl Rect {#[cfg(target_os = "macos")]#[derive(Debug, Clone)]pub struct CGWindowInfo {+ window_id: u32,pid: i32,layer: i32,bounds: Rect,@@ -430,6 +431,27 @@ fn get_cg_window_list() -> (Vec<CGWindowInfo>, HashSet<u32>) {}let dict = dict_ref as core_foundation::dictionary::CFDictionaryRef;+ // CGWindowNumber matches ScreenCaptureKit's SCWindow.windowID.+ // Reading it here avoids the unsafe SCWindow title bridge on Intel Macs.+ let window_id_key = CFString::new("kCGWindowNumber");+ let mut window_id_val = std::ptr::null();+ if core_foundation::dictionary::CFDictionaryGetValueIfPresent(+ dict,+ window_id_key.as_concrete_TypeRef() as *const _,+ &mut window_id_val,+ ) == 0+ || window_id_val.is_null()+ {+ continue;+ }+ let window_id_num = CFNumber::wrap_under_get_rule(+ window_id_val as core_foundation::number::CFNumberRef,+ );+ let Some(window_id) = window_id_num.to_i64().and_then(|id| u32::try_from(id).ok())+ else {+ continue;+ };+// Extract PIDlet pid_key = CFString::new("kCGWindowOwnerPID");let mut pid_val = std::ptr::null();@@ -531,6 +553,7 @@ fn get_cg_window_list() -> (Vec<CGWindowInfo>, HashSet<u32>) {};windows.push(CGWindowInfo {+ window_id,pid: w_pid as i32,layer,bounds,@@ -919,36 +942,8 @@ pub fn get_excluded_sck_window_ids(window_filters: &WindowFilters) -> Vec<u32> {return Vec::new();}- let excluded = match cidre::objc::ar_pool(|| -> Result<Vec<u32>, String> {- let windows = SckWindow::all().map_err(|e| e.to_string())?;- let mut excluded = Vec::new();-- for w in &windows {- let app_name = w.app_name().unwrap_or_default();- let title = w.title().unwrap_or_default();-- if app_name.is_empty() {- continue;- }-- if !window_filters.is_valid(&app_name, &title) {- if let Ok(id) = w.id() {- excluded.push(id);- }- }- }-- Ok(excluded)- }) {- Ok(ids) => ids,- Err(e) => {- debug!(- "get_excluded_sck_window_ids: failed to enumerate windows: {}",- e- );- return Vec::new();- }- };+ let (cg_windows, _) = get_cg_window_list();+ let excluded = excluded_sck_window_ids_from_cg_windows(&cg_windows, window_filters);if !excluded.is_empty() {debug!(@@ -961,6 +956,23 @@ pub fn get_excluded_sck_window_ids(window_filters: &WindowFilters) -> Vec<u32> {excluded}+/// Resolve filtered windows to SCK-compatible IDs without enumerating SCWindow strings.+///+/// On Intel macOS 15, `sck_rs::Window::all()` can pass a null window title to+/// `CFStringGetLength`, which terminates the process before Rust can return an error.+#[cfg(target_os = "macos")]+fn excluded_sck_window_ids_from_cg_windows(+ cg_windows: &[CGWindowInfo],+ window_filters: &WindowFilters,+) -> Vec<u32> {+ cg_windows+ .iter()+ .filter(|window| window.window_id != 0 && !window.owner_name.is_empty())+ .filter(|window| !window_filters.is_valid(&window.owner_name, &window.window_name))+ .map(|window| window.window_id)+ .collect()+}+/// Non-macOS stub — SCK exclusion is not available.#[cfg(not(target_os = "macos"))]pub fn get_excluded_sck_window_ids(_window_filters: &WindowFilters) -> Vec<u32> {@@ -1722,6 +1734,7 @@ mod tests {title: &str,) -> CGWindowInfo {CGWindowInfo {+ window_id: pid as u32,pid,layer,bounds: Rect {@@ -1762,6 +1775,48 @@ mod tests {);}+ #[test]+ fn test_excluded_sck_ids_respect_ignore_patterns() {+ let windows = vec![+ make_window(111, 0, 0, 0, 800, 600, "Password Manager", "Vault"),+ make_window(222, 0, 0, 0, 800, 600, "Notes", "Daily note"),+ ];+ let filters = WindowFilters::new(&["password".to_string()], &[], &[]);++ assert_eq!(+ excluded_sck_window_ids_from_cg_windows(&windows, &filters),+ vec![111]+ );+ }++ #[test]+ fn test_excluded_sck_ids_respect_include_patterns() {+ let windows = vec![+ make_window(111, 0, 0, 0, 800, 600, "Terminal", "Build"),+ make_window(222, 0, 0, 0, 800, 600, "Notes", "Daily note"),+ ];+ let filters = WindowFilters::new(&[], &["terminal".to_string()], &[]);++ assert_eq!(+ excluded_sck_window_ids_from_cg_windows(&windows, &filters),+ vec![222]+ );+ }++ #[test]+ fn test_excluded_sck_ids_skip_unusable_rows() {+ let missing_owner = make_window(111, 0, 0, 0, 800, 600, "", "Vault");+ let mut missing_id = make_window(222, 0, 0, 0, 800, 600, "Password Manager", "Vault");+ missing_id.window_id = 0;+ let filters = WindowFilters::new(&["vault".to_string()], &[], &[]);++ assert!(excluded_sck_window_ids_from_cg_windows(+ &[missing_owner, missing_id],+ &filters+ )+ .is_empty());+ }+#[test]fn test_topmost_skips_overlay_layers() {// Wispr Flow overlay (layer 25) is first in z-order but should be skipped