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
Bump app to v2.0.582
Louis Beaumonte9dfc0b0c72f
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 7e36207db..17ef26001 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.0.581"+version = "2.0.582"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/crates/screenpipe-accessibility/src/tree/macos.rs b/crates/screenpipe-accessibility/src/tree/macos.rsindex f72f598a9..408988d50 100644--- a/crates/screenpipe-accessibility/src/tree/macos.rs+++ b/crates/screenpipe-accessibility/src/tree/macos.rs@@ -242,9 +242,19 @@ impl MacosTreeWalker {}// 2. Get the focused window via AX API- let ax_app = ax::UiElement::with_app_pid(pid);+ let mut ax_app = ax::UiElement::with_app_pid(pid);let _ = ax_app.set_messaging_timeout_secs(self.config.element_timeout_secs);+ // Enable accessibility for Chromium/Electron apps. These apps only build+ // their DOM accessibility tree when they detect an assistive technology.+ // Setting AXEnhancedUserInterface = true signals "a screen reader is active"+ // and causes the renderer to materialize the full AX tree.+ // Ref: https://codereview.chromium.org/6909013+ // Ref: https://github.com/electron/electron/issues/7206+ let eui_attr_name = cf::String::from_str("AXEnhancedUserInterface");+ let eui_attr = ax::Attr::with_string(&eui_attr_name);+ let _ = ax_app.set_attr(&eui_attr, cf::Boolean::value_true());+let window_val = match ax_app.attr_value(ax::attr::focused_window()) {Ok(v) => v,Err(_) => return Ok(None),@@ -306,8 +316,8 @@ impl MacosTreeWalker {let text_content = state.text_buffer;// Don't bail on empty text — we still need the app_name and window_name- // for frame metadata. Chrome/Electron apps often return empty accessibility- // text but the app/window detection above already succeeded.+ // for frame metadata. Some apps may return empty text on the first walk+ // after AXEnhancedUserInterface is set (Chromium builds the tree async).// Truncate if neededlet text_content = if text_content.len() > self.config.max_text_length {@@ -765,396 +775,4 @@ mod tests {assert!(start.elapsed() < std::time::Duration::from_secs(5));}- /// Diagnostic test: walk the currently-focused window and dump every AX role- /// encountered plus the extracted text. Focus Discord (or any Electron app)- /// before running:- ///- /// cargo test -p screenpipe-accessibility test_dump_focused_window_ax_tree -- --nocapture- ///- /// This helps diagnose why certain apps return empty `text_content`.- #[test]- #[cfg(target_os = "macos")]- fn test_dump_focused_window_ax_tree() {- use std::collections::HashMap;-- // Use generous limits so we see everything- let config = TreeWalkerConfig {- max_depth: 50,- max_nodes: 10000,- walk_timeout: std::time::Duration::from_secs(5),- ..Default::default()- };- let walker = MacosTreeWalker::new(config);- let result = walker.walk_focused_window();- assert!(result.is_ok(), "walk_focused_window failed: {:?}", result.err());-- let Some(snapshot) = result.unwrap() else {- eprintln!("No focused window found (is an app focused?)");- return;- };-- eprintln!("=== Accessibility Tree Dump ===");- eprintln!("App: {}", snapshot.app_name);- eprintln!("Window: {}", snapshot.window_name);- eprintln!("Node count: {}", snapshot.node_count);- eprintln!("Text length: {}", snapshot.text_content.len());- eprintln!("Truncated: {}", snapshot.truncated);- eprintln!("Max depth: {}", snapshot.max_depth_reached);- eprintln!("Walk time: {:?}", snapshot.walk_duration);- eprintln!("Browser URL: {:?}", snapshot.browser_url);- eprintln!();-- // Show structured nodes by role- let mut role_counts: HashMap<String, usize> = HashMap::new();- for node in &snapshot.nodes {- *role_counts.entry(node.role.clone()).or_insert(0) += 1;- }- eprintln!("--- Nodes with extracted text (by role) ---");- let mut sorted: Vec<_> = role_counts.into_iter().collect();- sorted.sort_by(|a, b| b.1.cmp(&a.1));- for (role, count) in &sorted {- eprintln!(" {}: {}", role, count);- }- eprintln!();-- // Show first 50 text nodes- eprintln!("--- First 50 text nodes ---");- for (i, node) in snapshot.nodes.iter().take(50).enumerate() {- let text_preview = if node.text.len() > 80 {- format!("{}...", &node.text[..80])- } else {- node.text.clone()- };- eprintln!(- " [{:3}] depth={} role={:20} text={:?}",- i, node.depth, node.role, text_preview- );- }- eprintln!();-- // Show full text_content (first 2000 chars)- let preview_len = snapshot.text_content.len().min(2000);- eprintln!("--- text_content (first {} chars) ---", preview_len);- eprintln!("{}", &snapshot.text_content[..preview_len]);- eprintln!("=== End Dump ===");-- // Now do a raw role enumeration by walking the AX tree ourselves- // to see ALL roles, including ones we normally skip- eprintln!();- eprintln!("=== Raw AX Role Enumeration ===");- let workspace = ns::Workspace::shared();- let apps = workspace.running_apps();- let active_app = apps.iter().find(|a| a.is_active());- if let Some(app) = active_app {- let pid = app.pid();- let ax_app = ax::UiElement::with_app_pid(pid);- if let Ok(window_val) = ax_app.attr_value(ax::attr::focused_window()) {- if window_val.get_type_id() == ax::UiElement::type_id() {- let window: &ax::UiElement = unsafe { std::mem::transmute(&*window_val) };- let mut all_roles: HashMap<String, usize> = HashMap::new();- let mut total_nodes = 0usize;- raw_count_roles(window, 0, 50, &mut all_roles, &mut total_nodes, 10000);- eprintln!("Total raw nodes visited: {}", total_nodes);- let mut sorted: Vec<_> = all_roles.into_iter().collect();- sorted.sort_by(|a, b| b.1.cmp(&a.1));- for (role, count) in &sorted {- eprintln!(" {}: {}", role, count);- }- }- }- }- eprintln!("=== End Raw Roles ===");- }-- /// Test the AXEnhancedUserInterface / AXManualAccessibility hack.- /// Chromium/Electron apps only build their AX tree when they detect a- /// screen reader. Setting these attributes tells the app "a screen reader- /// is connected" and forces it to materialize the full tree.- ///- /// Discord must be running (doesn't need to be focused):- ///- /// cargo test -p screenpipe-accessibility test_electron_ax_enhanced_hack -- --nocapture- #[test]- #[cfg(target_os = "macos")]- fn test_electron_ax_enhanced_hack() {- let workspace = ns::Workspace::shared();- let apps = workspace.running_apps();-- // Find Discord (or any Electron app) by name, regardless of focus- let target_app = apps.iter().find(|a| {- a.localized_name()- .map(|s| s.to_string().to_lowercase().contains("discord"))- .unwrap_or(false)- });- let Some(app) = target_app else {- eprintln!("Discord is not running — skipping test");- return;- };- let app_name = app.localized_name().map(|s| s.to_string()).unwrap_or_default();- let pid = app.pid();- eprintln!("Target app: {} (pid={})", app_name, pid);-- let mut ax_app = ax::UiElement::with_app_pid(pid);- let _ = ax_app.set_messaging_timeout_secs(2.0);-- // --- BEFORE: walk without the hack ---- eprintln!("\n=== BEFORE (no hack) ===");- let before = walk_app_window(&ax_app);-- // --- Set AXEnhancedUserInterface = true ---- let eui_attr_name = cf::String::from_str("AXEnhancedUserInterface");- let eui_attr = ax::Attr::with_string(&eui_attr_name);- let true_val = cf::Boolean::value_true();- match ax_app.set_attr(eui_attr, true_val) {- Ok(()) => eprintln!("\nSet AXEnhancedUserInterface = true: OK"),- Err(e) => eprintln!("\nSet AXEnhancedUserInterface = true: FAILED ({:?})", e),- }-- // Also try AXManualAccessibility (used by some Chromium versions)- let ma_attr_name = cf::String::from_str("AXManualAccessibility");- let ma_attr = ax::Attr::with_string(&ma_attr_name);- match ax_app.set_attr(ma_attr, true_val) {- Ok(()) => eprintln!("Set AXManualAccessibility = true: OK"),- Err(e) => eprintln!("Set AXManualAccessibility = true: FAILED ({:?})", e),- }-- // Chromium builds the AX tree asynchronously — poll a few times- for wait_secs in [1, 2, 3, 5] {- eprintln!("\n=== AFTER (waited {}s total) ===", wait_secs);- std::thread::sleep(std::time::Duration::from_secs(if wait_secs == 1 { 1 } else { wait_secs - 1 }));- let after = walk_app_window(&ax_app);-- eprintln!("Before: {} nodes, {} text chars", before.0, before.1);- eprintln!("After: {} nodes, {} text chars", after.0, after.1);- if after.0 > before.0 {- eprintln!("HACK WORKED! {} more nodes exposed", after.0 - before.0);- break;- } else {- eprintln!("No change yet...");- }- }- }-- /// Walk the app's windows (focused first, then AXWindows list).- /// Returns (node_count, text_len) for the first window found.- #[cfg(target_os = "macos")]- fn walk_app_window(ax_app: &ax::UiElement) -> (usize, usize) {- // Try focused window first- if let Ok(val) = ax_app.attr_value(ax::attr::focused_window()) {- if val.get_type_id() == ax::UiElement::type_id() {- let window: &ax::UiElement = unsafe { std::mem::transmute(&*val) };- let title = get_string_attr(window, ax::attr::title()).unwrap_or_default();- eprintln!(" Window (focused): {}", title);- return walk_and_dump_window(window);- }- }- // Fall back to first child window from the "AXWindows" attribute- let windows_attr_name = cf::String::from_str("AXWindows");- let windows_attr = ax::Attr::with_string(&windows_attr_name);- if let Ok(val) = ax_app.attr_value(&windows_attr) {- let arr: &cf::ArrayOf<ax::UiElement> = unsafe { std::mem::transmute(&*val) };- if !arr.is_empty() {- let window = &arr[0];- let title = get_string_attr(window, ax::attr::title()).unwrap_or_default();- eprintln!(" Window (AXWindows[0]): {}", title);- return walk_and_dump_window(window);- }- }- eprintln!(" No windows found");- (0, 0)- }-- /// Walk a specific window's AX tree and dump stats. Returns (node_count, text_len).- #[cfg(target_os = "macos")]- fn walk_and_dump_window(window: &ax::UiElement) -> (usize, usize) {- use std::collections::HashMap;-- let mut all_roles: HashMap<String, usize> = HashMap::new();- let mut total_nodes = 0usize;- let mut text_buf = String::new();- raw_walk_with_text(window, 0, 50, &mut all_roles, &mut total_nodes, &mut text_buf, 10000);-- eprintln!(" Total nodes: {}", total_nodes);- eprintln!(" Text length: {}", text_buf.len());- let mut sorted: Vec<_> = all_roles.into_iter().collect();- sorted.sort_by(|a, b| b.1.cmp(&a.1));- for (role, count) in &sorted {- eprintln!(" {}: {}", role, count);- }- if !text_buf.is_empty() {- let preview = &text_buf[..text_buf.len().min(1000)];- eprintln!(" Text preview:\n{}", preview);- }- (total_nodes, text_buf.len())- }-- /// Recursively walk AX tree, collecting ALL roles AND extracting text.- #[cfg(target_os = "macos")]- fn raw_walk_with_text(- elem: &ax::UiElement,- depth: usize,- max_depth: usize,- roles: &mut std::collections::HashMap<String, usize>,- total: &mut usize,- text: &mut String,- max_nodes: usize,- ) {- if depth >= max_depth || *total >= max_nodes {- return;- }- *total += 1;- let _ = elem.set_messaging_timeout_secs(0.3);- let role_str = match elem.role() {- Ok(r) => r.to_string(),- Err(_) => return,- };- *roles.entry(role_str.clone()).or_insert(0) += 1;-- // Try to extract text from any role that might have it- if should_extract_text(&role_str) || role_str == "AXGroup" || role_str == "AXWebArea" {- if let Some(val) = get_string_attr(elem, ax::attr::value()) {- if !val.is_empty() {- append_text(text, &val);- }- } else if let Some(title) = get_string_attr(elem, ax::attr::title()) {- if !title.is_empty() {- append_text(text, &title);- }- } else if let Some(desc) = get_string_attr(elem, ax::attr::desc()) {- if !desc.is_empty() {- append_text(text, &desc);- }- }- }-- if let Ok(children) = elem.children() {- for i in 0..children.len() {- if *total >= max_nodes {- break;- }- raw_walk_with_text(&children[i], depth + 1, max_depth, roles, total, text, max_nodes);- }- }- }-- /// Dump ALL AX attributes of Discord to see what's available.- ///- /// cargo test -p screenpipe-accessibility test_dump_electron_ax_attrs -- --nocapture- #[test]- #[cfg(target_os = "macos")]- fn test_dump_electron_ax_attrs() {- let workspace = ns::Workspace::shared();- let apps = workspace.running_apps();- let target_app = apps.iter().find(|a| {- a.localized_name()- .map(|s| s.to_string().to_lowercase().contains("discord"))- .unwrap_or(false)- });- let Some(app) = target_app else {- eprintln!("Discord not running — skipping");- return;- };- let pid = app.pid();- let ax_app = ax::UiElement::with_app_pid(pid);- let _ = ax_app.set_messaging_timeout_secs(2.0);-- // List all attributes of the app element- eprintln!("=== App-level attributes ===");- if let Ok(attrs) = ax_app.attrs() {- for i in 0..attrs.len() {- let attr = &attrs[i];- let val_str = match ax_app.attr_value(attr) {- Ok(v) => format!("{:?}", v),- Err(e) => format!("ERROR: {:?}", e),- };- let settable = ax_app.is_settable(attr).unwrap_or(false);- eprintln!(" {:?} (settable={}) = {}", attr, settable,- if val_str.len() > 200 { &val_str[..200] } else { &val_str });- }- }-- // Get the focused window and dump its attrs- if let Ok(window_val) = ax_app.attr_value(ax::attr::focused_window()) {- if window_val.get_type_id() == ax::UiElement::type_id() {- let window: &ax::UiElement = unsafe { std::mem::transmute(&*window_val) };- eprintln!("\n=== Window attributes ===");- if let Ok(attrs) = window.attrs() {- for i in 0..attrs.len() {- let attr = &attrs[i];- let val_str = match window.attr_value(attr) {- Ok(v) => format!("{:?}", v),- Err(e) => format!("ERROR: {:?}", e),- };- let settable = window.is_settable(attr).unwrap_or(false);- eprintln!(" {:?} (settable={}) = {}", attr, settable,- if val_str.len() > 200 { &val_str[..200] } else { &val_str });- }- }-- // Walk first 3 levels and dump attrs- eprintln!("\n=== Child elements (depth 0-2) ===");- dump_children_attrs(window, 0, 2);- }- }- }-- #[cfg(target_os = "macos")]- fn dump_children_attrs(elem: &ax::UiElement, depth: usize, max_depth: usize) {- if depth > max_depth { return; }- let indent = " ".repeat(depth + 1);- if let Ok(children) = elem.children() {- for i in 0..children.len() {- let child = &children[i];- let _ = child.set_messaging_timeout_secs(0.5);- let role = child.role().map(|r| r.to_string()).unwrap_or_default();- eprintln!("{}[{}] role={}", indent, i, role);- // Show all attributes- if let Ok(attrs) = child.attrs() {- for j in 0..attrs.len() {- let attr = &attrs[j];- let attr_name = attr.to_string();- // Skip children/parent to avoid recursion- if attr_name.contains("AXChildren") || attr_name.contains("AXParent")- || attr_name.contains("AXTopLevelUIElement") || attr_name.contains("AXWindow") {- continue;- }- let val_str = match child.attr_value(attr) {- Ok(v) => format!("{:?}", v),- Err(e) => format!("ERR({:?})", e),- };- let short = if val_str.len() > 120 { &val_str[..120] } else { &val_str };- eprintln!("{} {} = {}", indent, attr_name, short);- }- }- dump_children_attrs(child, depth + 1, max_depth);- }- }- }-- /// Helper: recursively count ALL roles in the AX tree (no filtering).- fn raw_count_roles(- elem: &ax::UiElement,- depth: usize,- max_depth: usize,- roles: &mut std::collections::HashMap<String, usize>,- total: &mut usize,- max_nodes: usize,- ) {- if depth >= max_depth || *total >= max_nodes {- return;- }- *total += 1;- let _ = elem.set_messaging_timeout_secs(0.2);- if let Ok(role) = elem.role() {- *roles.entry(role.to_string()).or_insert(0) += 1;- }- if let Ok(children) = elem.children() {- for i in 0..children.len() {- if *total >= max_nodes {- break;- }- raw_count_roles(&children[i], depth + 1, max_depth, roles, total, max_nodes);- }- }- }}