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(a11y): reset depth counter at AXWebArea boundary so Electron apps get the full walk budget (#3555)

Akarsh Hegde2b06b643da7d
diff --git a/crates/screenpipe-a11y/src/tree/macos.rs b/crates/screenpipe-a11y/src/tree/macos.rs
index f78d2e99d..142c5ee94 100644
--- a/crates/screenpipe-a11y/src/tree/macos.rs
+++ b/crates/screenpipe-a11y/src/tree/macos.rs
@@ -747,7 +747,18 @@ fn walk_element(elem: &ax::UiElement, depth: usize, state: &mut WalkState) {
return;
}
- // Recurse into children
+ // Recurse into children.
+ // Reset the depth counter to 0 when entering an AXWebArea so that Electron
+ // apps (VS Code, Slack, Discord, Obsidian, Notion, …) get the full
+ // max_depth budget for their DOM content tree. Without this reset, the
+ // budget is partially consumed by the Electron shell layers above the
+ // AXWebArea (typically 7-9 AXGroup levels), leaving fewer levels for the
+ // actual app content — silently dropping terminal output, editor text, etc.
+ let next_depth = if role_str == "AXWebArea" {
+ 0
+ } else {
+ depth + 1
+ };
let children = elem.children();
if let Ok(children) = children {
for i in 0..children.len() {
@@ -755,7 +766,7 @@ fn walk_element(elem: &ax::UiElement, depth: usize, state: &mut WalkState) {
break;
}
let child = &children[i];
- walk_element(child, depth + 1, state);
+ walk_element(child, next_depth, state);
}
}
}