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: filter browser extension popups in accessibility tree walker
Louis Beaumont52d20987ae4f
diff --git a/crates/screenpipe-a11y/src/tree/linux.rs b/crates/screenpipe-a11y/src/tree/linux.rsindex 95b39ca5d..9fb52ccc2 100644--- a/crates/screenpipe-a11y/src/tree/linux.rs+++ b/crates/screenpipe-a11y/src/tree/linux.rs@@ -472,6 +472,9 @@ struct WalkState {window_y: f64,window_w: f64,window_h: f64,+ /// User-configured ignored window patterns (lowercase) for filtering browser+ /// extension popups whose DocumentWeb name matches an ignored keyword.+ ignored_windows_lower: Vec<String>,}impl WalkState {@@ -491,6 +494,11 @@ impl WalkState {window_y: 0.0,window_w: 0.0,window_h: 0.0,+ ignored_windows_lower: config+ .ignored_windows+ .iter()+ .map(|s| s.to_lowercase())+ .collect(),}}@@ -535,6 +543,21 @@ fn walk_accessible(conn: &Connection, aref: &AccessibleRef, depth: usize, state:return;}+ // Browser extension popup detection: DocumentWeb/DocumentFrame nodes in+ // Chromium carry the extension name as their accessible name. If it matches+ // an ignored-window pattern, skip the entire subtree.+ if matches!(role, 95 | 94 | 82) && !state.ignored_windows_lower.is_empty() {+ let name = get_accessible_name(conn, aref).to_lowercase();+ if !name.is_empty()+ && state+ .ignored_windows_lower+ .iter()+ .any(|ig| name.contains(ig.as_str()))+ {+ return;+ }+ }+// Extract text from text-bearing elementsif should_extract_text(role) {extract_text(conn, aref, role, depth, state);diff --git a/crates/screenpipe-a11y/src/tree/macos.rs b/crates/screenpipe-a11y/src/tree/macos.rsindex fa39513da..cbd71911d 100644--- a/crates/screenpipe-a11y/src/tree/macos.rs+++ b/crates/screenpipe-a11y/src/tree/macos.rs@@ -401,6 +401,9 @@ struct WalkState {monitor_y: f64,monitor_w: f64,monitor_h: f64,+ /// User-configured ignored window patterns (lowercase) for filtering browser+ /// extension popups whose AXWebArea title matches an ignored keyword.+ ignored_windows_lower: Vec<String>,}impl WalkState {@@ -425,6 +428,11 @@ impl WalkState {monitor_y: config.monitor_y,monitor_w: config.monitor_width,monitor_h: config.monitor_height,+ ignored_windows_lower: config+ .ignored_windows+ .iter()+ .map(|s| s.to_lowercase())+ .collect(),}}@@ -523,13 +531,38 @@ fn walk_element(elem: &ax::UiElement, depth: usize, state: &mut WalkState) {// Extract text from this elementif should_extract_text(&role_str) {extract_text(elem, &role_str, depth, state);- } else if role_str == "AXGroup" || role_str == "AXWebArea" {+ } else if role_str == "AXWebArea" {+ // Browser extension popup detection: AXWebArea nodes inside Chrome/Arc/Edge+ // carry the extension name as their title and a chrome-extension:// URL.+ // If the title matches an ignored-window pattern, skip the entire subtree+ // to prevent capturing password manager or other sensitive extension content.+ if !state.ignored_windows_lower.is_empty() {+ let matches = |val: &str| {+ let lower = val.to_lowercase();+ state+ .ignored_windows_lower+ .iter()+ .any(|ig| lower.contains(ig.as_str()))+ };+ if get_string_attr(elem, ax::attr::title()).is_some_and(|t| matches(&t))+ || get_string_attr(elem, ax::attr::url()).is_some_and(|u| matches(&u))+ {+ return;+ }+ }// Groups and web areas: only extract if they have a direct valueif let Some(val) = get_string_attr(elem, ax::attr::value()) {if !val.is_empty() {append_text(&mut state.text_buffer, &val);}}+ } else if role_str == "AXGroup" {+ // Groups: only extract if they have a direct value+ if let Some(val) = get_string_attr(elem, ax::attr::value()) {+ if !val.is_empty() {+ append_text(&mut state.text_buffer, &val);+ }+ }}if state.should_stop() {diff --git a/crates/screenpipe-a11y/src/tree/windows.rs b/crates/screenpipe-a11y/src/tree/windows.rsindex 8cd0f76ae..81198c569 100644--- a/crates/screenpipe-a11y/src/tree/windows.rs+++ b/crates/screenpipe-a11y/src/tree/windows.rs@@ -244,6 +244,12 @@ impl TreeWalkerPlatform for WindowsTreeWalker {let mut text_buffer = String::with_capacity(4096);let mut nodes = Vec::with_capacity(256);let mut browser_url: Option<String> = None;+ let ignored_lower: Vec<String> = self+ .config+ .ignored_windows+ .iter()+ .map(|s| s.to_lowercase())+ .collect();extract_text_from_tree(&root,0,@@ -252,6 +258,7 @@ impl TreeWalkerPlatform for WindowsTreeWalker {&mut nodes,&mut browser_url,&monitor_rect,+ &ignored_lower,);// Don't bail on empty text — we still need the app_name and window_name@@ -401,6 +408,7 @@ fn extract_text_from_tree(nodes: &mut Vec<AccessibilityTreeNode>,browser_url: &mut Option<String>,monitor_rect: &Option<MonitorRect>,+ ignored_windows_lower: &[String],) {if depth > max_depth {return;@@ -445,6 +453,22 @@ fn extract_text_from_tree(// node is the root of the entire web content tree — its children are the// actual UI elements (buttons, text, links, etc.).if ct.eq_ignore_ascii_case("Document") {+ // Browser extension popup detection: Document nodes for Chrome extensions+ // carry the extension name in `name` and a chrome-extension:// URL in `value`.+ // If either matches an ignored-window pattern, skip the entire subtree.+ if !ignored_windows_lower.is_empty() {+ let matches = |val: &str| {+ let lower = val.to_lowercase();+ ignored_windows_lower+ .iter()+ .any(|ig| lower.contains(ig.as_str()))+ };+ if node.name.as_deref().is_some_and(|n| matches(n))+ || node.value.as_deref().is_some_and(|v| matches(v))+ {+ return;+ }+ }if let Some(ref val) = node.value {let trimmed = val.trim();if !trimmed.is_empty() {@@ -520,6 +544,7 @@ fn extract_text_from_tree(nodes,browser_url,monitor_rect,+ ignored_windows_lower,);}}@@ -627,7 +652,7 @@ mod tests {let mut buf = String::new();let mut nodes = Vec::new();let mut url = None;- extract_text_from_tree(&tree, 0, 10, &mut buf, &mut nodes, &mut url, &None);+ extract_text_from_tree(&tree, 0, 10, &mut buf, &mut nodes, &mut url, &None, &[]);// Text node's name should be capturedassert!(@@ -719,7 +744,7 @@ mod tests {let mut buf = String::new();let mut nodes = Vec::new();let mut url = None;- extract_text_from_tree(&tree, 0, 30, &mut buf, &mut nodes, &mut url, &None);+ extract_text_from_tree(&tree, 0, 30, &mut buf, &mut nodes, &mut url, &None, &[]);// URL should be captured as browser_url, NOT as textassert_eq!(diff --git a/crates/screenpipe-db/src/types.rs b/crates/screenpipe-db/src/types.rsindex 9b7244974..48cb114dc 100644--- a/crates/screenpipe-db/src/types.rs+++ b/crates/screenpipe-db/src/types.rs@@ -77,7 +77,7 @@ impl StdError for DatabaseError {}/// Search result variants for different content types.///-/// Note: `UI` is for accessibility text traversal (ui_monitoring table).+/// Note: `UI` is for accessibility text traversal (accessibility table)./// `Input` is for user actions like clicks/keystrokes (ui_events table).#[derive(OaSchema, Debug, Serialize, Deserialize)]pub enum SearchResult {