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
feat: add automation properties to accessibility tree (Windows, macOS, Linux)
Louis Beaumont1b7d0db5b5c1
diff --git a/crates/screenpipe-a11y/src/events.rs b/crates/screenpipe-a11y/src/events.rsindex a5fda8dcc..9a4c6cb8f 100644--- a/crates/screenpipe-a11y/src/events.rs+++ b/crates/screenpipe-a11y/src/events.rs@@ -164,7 +164,7 @@ pub struct ElementBounds {// ============================================================================/// A node in the accessibility tree-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Default, Serialize, Deserialize)]pub struct AccessibilityNode {/// Control type (e.g., "Button", "Edit", "Text", "Window")pub control_type: String,@@ -200,6 +200,34 @@ pub struct AccessibilityNode {#[serde(skip_serializing_if = "Option::is_none")]pub is_keyboard_focusable: Option<bool>,+ /// Tooltip or help text (UIA HelpText)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub help_text: Option<String>,++ /// Whether the element is a password field (UIA IsPassword)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_password: Option<bool>,++ /// Whether the element is selected (UIA SelectionItem.IsSelected)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_selected: Option<bool>,++ /// Whether the element is expanded (UIA ExpandCollapse.ExpandCollapseState)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_expanded: Option<bool>,++ /// Keyboard shortcut (UIA AcceleratorKey)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub accelerator_key: Option<String>,++ /// Access key mnemonic (UIA AccessKey)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub access_key: Option<String>,++ /// Localized control type description (UIA LocalizedControlType)+ #[serde(skip_serializing_if = "Option::is_none")]+ pub localized_control_type: Option<String>,+/// Child elements#[serde(default, skip_serializing_if = "Vec::is_empty")]pub children: Vec<AccessibilityNode>,diff --git a/crates/screenpipe-a11y/src/platform/windows_uia.rs b/crates/screenpipe-a11y/src/platform/windows_uia.rsindex b315750c9..9345ce0cd 100644--- a/crates/screenpipe-a11y/src/platform/windows_uia.rs+++ b/crates/screenpipe-a11y/src/platform/windows_uia.rs@@ -28,10 +28,12 @@ use windows::Win32::UI::Accessibility::{AutomationElementMode_Full, AutomationElementMode_None, CUIAutomation, IUIAutomation,IUIAutomationCacheRequest, IUIAutomationElement, IUIAutomationFocusChangedEventHandler,IUIAutomationFocusChangedEventHandler_Impl, IUIAutomationTreeWalker, TreeScope_Element,- TreeScope_Subtree, UIA_AutomationIdPropertyId, UIA_BoundingRectanglePropertyId,- UIA_ClassNamePropertyId, UIA_ControlTypePropertyId, UIA_HasKeyboardFocusPropertyId,- UIA_IsEnabledPropertyId, UIA_IsKeyboardFocusablePropertyId, UIA_NamePropertyId,- UIA_ValueValuePropertyId, UIA_PROPERTY_ID,+ TreeScope_Subtree, UIA_AcceleratorKeyPropertyId, UIA_AccessKeyPropertyId,+ UIA_AutomationIdPropertyId, UIA_BoundingRectanglePropertyId, UIA_ClassNamePropertyId,+ UIA_ControlTypePropertyId, UIA_HasKeyboardFocusPropertyId, UIA_HelpTextPropertyId,+ UIA_IsEnabledPropertyId, UIA_IsKeyboardFocusablePropertyId, UIA_IsPasswordPropertyId,+ UIA_LocalizedControlTypePropertyId, UIA_NamePropertyId, UIA_ValueValuePropertyId,+ UIA_PROPERTY_ID,};use windows::Win32::UI::WindowsAndMessaging::{DispatchMessageW, GetForegroundWindow, GetWindowTextW, GetWindowThreadProcessId, PeekMessageW,@@ -78,6 +80,11 @@ impl UiaContext {cache_request.AddProperty(UIA_ValueValuePropertyId)?;cache_request.AddProperty(UIA_HasKeyboardFocusPropertyId)?;cache_request.AddProperty(UIA_IsKeyboardFocusablePropertyId)?;+ cache_request.AddProperty(UIA_HelpTextPropertyId)?;+ cache_request.AddProperty(UIA_IsPasswordPropertyId)?;+ cache_request.AddProperty(UIA_AcceleratorKeyPropertyId)?;+ cache_request.AddProperty(UIA_AccessKeyPropertyId)?;+ cache_request.AddProperty(UIA_LocalizedControlTypePropertyId)?;// Use Control View (skips raw layout elements, ~50% fewer nodes)let control_view_condition = automation.ControlViewCondition()?;@@ -102,6 +109,11 @@ impl UiaContext {walker_cache_request.AddProperty(UIA_ValueValuePropertyId)?;walker_cache_request.AddProperty(UIA_HasKeyboardFocusPropertyId)?;walker_cache_request.AddProperty(UIA_IsKeyboardFocusablePropertyId)?;+ walker_cache_request.AddProperty(UIA_HelpTextPropertyId)?;+ walker_cache_request.AddProperty(UIA_IsPasswordPropertyId)?;+ walker_cache_request.AddProperty(UIA_AcceleratorKeyPropertyId)?;+ walker_cache_request.AddProperty(UIA_AccessKeyPropertyId)?;+ walker_cache_request.AddProperty(UIA_LocalizedControlTypePropertyId)?;let control_view_condition2 = automation.ControlViewCondition()?;walker_cache_request.SetTreeFilter(&control_view_condition2)?;walker_cache_request.SetAutomationElementMode(AutomationElementMode_Full)?;@@ -199,6 +211,12 @@ impl UiaContext {let is_focused = self.get_cached_bool_opt(element, UIA_HasKeyboardFocusPropertyId);let is_keyboard_focusable =self.get_cached_bool_opt(element, UIA_IsKeyboardFocusablePropertyId);+ let help_text = self.get_cached_string(element, UIA_HelpTextPropertyId);+ let is_password = self.get_cached_bool_opt(element, UIA_IsPasswordPropertyId);+ let accelerator_key = self.get_cached_string(element, UIA_AcceleratorKeyPropertyId);+ let access_key = self.get_cached_string(element, UIA_AccessKeyPropertyId);+ let localized_control_type =+ self.get_cached_string(element, UIA_LocalizedControlTypePropertyId);let mut children = Vec::new();if *count < max_elements {@@ -237,6 +255,13 @@ impl UiaContext {is_enabled,is_focused,is_keyboard_focusable,+ help_text,+ is_password,+ is_selected: None, // requires SelectionItemPattern, not available via simple cache+ is_expanded: None, // requires ExpandCollapsePattern, not available via simple cache+ accelerator_key,+ access_key,+ localized_control_type,children,}}@@ -260,6 +285,12 @@ impl UiaContext {let is_focused = self.get_cached_bool_opt(element, UIA_HasKeyboardFocusPropertyId);let is_keyboard_focusable =self.get_cached_bool_opt(element, UIA_IsKeyboardFocusablePropertyId);+ let help_text = self.get_cached_string(element, UIA_HelpTextPropertyId);+ let is_password = self.get_cached_bool_opt(element, UIA_IsPasswordPropertyId);+ let accelerator_key = self.get_cached_string(element, UIA_AcceleratorKeyPropertyId);+ let access_key = self.get_cached_string(element, UIA_AccessKeyPropertyId);+ let localized_control_type =+ self.get_cached_string(element, UIA_LocalizedControlTypePropertyId);let mut children = Vec::new();if *count < max_elements {@@ -290,6 +321,13 @@ impl UiaContext {is_enabled,is_focused,is_keyboard_focusable,+ help_text,+ is_password,+ is_selected: None,+ is_expanded: None,+ accelerator_key,+ access_key,+ localized_control_type,children,}}@@ -915,6 +953,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![],};let node2 = AccessibilityNode {@@ -927,6 +972,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![],};assert_ne!(compute_tree_hash(&node1), compute_tree_hash(&node2));@@ -949,6 +1001,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![AccessibilityNode {control_type: "Button".to_string(),name: Some("OK".to_string()),@@ -959,6 +1018,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![],}],};@@ -979,6 +1045,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![AccessibilityNode {control_type: "Button".to_string(),@@ -1002,6 +1075,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![AccessibilityNode {control_type: "Text".to_string(),name: Some("C".to_string()),@@ -1012,6 +1092,13 @@ mod tests {is_enabled: true,is_focused: None,is_keyboard_focusable: None,+ help_text: None,+ is_password: None,+ is_selected: None,+ is_expanded: None,+ accelerator_key: None,+ access_key: None,+ localized_control_type: None,children: vec![],}],},diff --git a/crates/screenpipe-a11y/src/tree/linux.rs b/crates/screenpipe-a11y/src/tree/linux.rsindex 5cc046a10..4f442dc56 100644--- a/crates/screenpipe-a11y/src/tree/linux.rs+++ b/crates/screenpipe-a11y/src/tree/linux.rs@@ -123,7 +123,11 @@ fn role_name(role: u32) -> &'static str {// ---------------------------------------------------------------------------const STATE_ACTIVE: u32 = 1;+const STATE_ENABLED: u32 = 7;+const STATE_EXPANDED: u32 = 9;+const STATE_FOCUSABLE: u32 = 10;const STATE_FOCUSED: u32 = 12;+const STATE_SELECTED: u32 = 18;fn has_state(state_set: &[u32], bit: u32) -> bool {let word = (bit / 32) as usize;@@ -553,6 +557,23 @@ fn walk_accessible(conn: &Connection, aref: &AccessibleRef, depth: usize, state:}}+/// Fill automation state properties from AT-SPI state set (single D-Bus call).+fn fill_atspi_state(node: &mut AccessibilityTreeNode, conn: &Connection, aref: &AccessibleRef) {+ let state_set = get_accessible_state(conn, aref);+ if !state_set.is_empty() {+ node.is_enabled = Some(has_state(&state_set, STATE_ENABLED));+ node.is_focused = Some(has_state(&state_set, STATE_FOCUSED));+ node.is_selected = Some(has_state(&state_set, STATE_SELECTED));+ node.is_expanded = Some(has_state(&state_set, STATE_EXPANDED));+ node.is_keyboard_focusable = Some(has_state(&state_set, STATE_FOCUSABLE));+ }+ // Description doubles as help_text on Linux+ let desc = get_accessible_description(conn, aref);+ if !desc.is_empty() {+ node.help_text = Some(desc);+ }+}+/// Extract text from a text-bearing accessible element.fn extract_text(conn: &Connection,@@ -570,12 +591,14 @@ fn extract_text(if matches!(role, 79 | 61 | 11) {if let Some(text) = get_text_content(conn, aref) {append_text(&mut state.text_buffer, &text);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: text.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ text.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_atspi_state(&mut node, conn, aref);+ state.nodes.push(node);return;}}@@ -584,12 +607,14 @@ fn extract_text(if matches!(role, 29 | 73 | 116) {if let Some(text) = get_text_content(conn, aref) {append_text(&mut state.text_buffer, &text);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: text.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ text.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_atspi_state(&mut node, conn, aref);+ state.nodes.push(node);return;}}@@ -598,12 +623,14 @@ fn extract_text(let name = get_accessible_name(conn, aref);if !name.is_empty() {append_text(&mut state.text_buffer, &name);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: name.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ name.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_atspi_state(&mut node, conn, aref);+ state.nodes.push(node);return;}@@ -611,12 +638,14 @@ fn extract_text(let desc = get_accessible_description(conn, aref);if !desc.is_empty() {append_text(&mut state.text_buffer, &desc);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: desc.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ desc.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_atspi_state(&mut node, conn, aref);+ state.nodes.push(node);}}diff --git a/crates/screenpipe-a11y/src/tree/macos.rs b/crates/screenpipe-a11y/src/tree/macos.rsindex d71a913de..2e228d73d 100644--- a/crates/screenpipe-a11y/src/tree/macos.rs+++ b/crates/screenpipe-a11y/src/tree/macos.rs@@ -541,12 +541,15 @@ fn extract_text(elem: &ax::UiElement, role_str: &str, depth: usize, state: &mutif let Some(val) = get_string_attr(elem, ax::attr::value()) {if !val.is_empty() {append_text(&mut state.text_buffer, &val);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: val.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ val.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ node.value = Some(val.trim().to_string());+ fill_ax_props(&mut node, elem, role_str);+ state.nodes.push(node);return;}}@@ -557,12 +560,14 @@ fn extract_text(elem: &ax::UiElement, role_str: &str, depth: usize, state: &mutif let Some(val) = get_string_attr(elem, ax::attr::value()) {if !val.is_empty() {append_text(&mut state.text_buffer, &val);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: val.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ val.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_ax_props(&mut node, elem, role_str);+ state.nodes.push(node);return;}}@@ -572,12 +577,14 @@ fn extract_text(elem: &ax::UiElement, role_str: &str, depth: usize, state: &mutif let Some(title) = get_string_attr(elem, ax::attr::title()) {if !title.is_empty() {append_text(&mut state.text_buffer, &title);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: title.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ title.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_ax_props(&mut node, elem, role_str);+ state.nodes.push(node);return;}}@@ -586,12 +593,14 @@ fn extract_text(elem: &ax::UiElement, role_str: &str, depth: usize, state: &mutif let Some(desc) = get_string_attr(elem, ax::attr::desc()) {if !desc.is_empty() {append_text(&mut state.text_buffer, &desc);- state.nodes.push(AccessibilityTreeNode {- role: role_str.to_string(),- text: desc.trim().to_string(),- depth: depth.min(255) as u8,+ let mut node = AccessibilityTreeNode::new(+ role_str.to_string(),+ desc.trim().to_string(),+ depth.min(255) as u8,bounds,- });+ );+ fill_ax_props(&mut node, elem, role_str);+ state.nodes.push(node);}}}@@ -688,6 +697,55 @@ fn get_string_attr(elem: &ax::UiElement, attr: &ax::Attr) -> Option<String> {})}+/// Extract a boolean attribute from an AX element.+fn get_bool_attr(elem: &ax::UiElement, attr: &ax::Attr) -> Option<bool> {+ elem.attr_value(attr).ok().and_then(|v| {+ if v.get_type_id() == cf::Boolean::type_id() {+ let b: &cf::Boolean = unsafe { std::mem::transmute(&*v) };+ Some(b.value())+ } else {+ None+ }+ })+}++/// Whether a role represents an interactive/actionable element (buttons, inputs, etc.).+fn is_interactive_role(role_str: &str) -> bool {+ matches!(+ role_str,+ "AXButton"+ | "AXTextField"+ | "AXTextArea"+ | "AXComboBox"+ | "AXCheckBox"+ | "AXRadioButton"+ | "AXPopUpButton"+ | "AXMenuButton"+ | "AXMenuItem"+ | "AXLink"+ | "AXDisclosureTriangle"+ | "AXTab"+ )+}++/// Fill automation properties on an AccessibilityTreeNode from an AX element.+/// Only fetches bool states for interactive elements to limit IPC overhead.+fn fill_ax_props(node: &mut AccessibilityTreeNode, elem: &ax::UiElement, role_str: &str) {+ node.automation_id = get_string_attr(elem, ax::attr::id());+ node.subrole = get_string_attr(elem, ax::attr::subrole());+ node.role_description = get_string_attr(elem, ax::attr::role_desc());+ node.help_text = get_string_attr(elem, ax::attr::help());+ // Bool states and extra string attrs only for interactive elements (limits IPC calls)+ if is_interactive_role(role_str) {+ node.placeholder = get_string_attr(elem, ax::attr::placeholder_value());+ node.url = get_string_attr(elem, ax::attr::url());+ node.is_enabled = get_bool_attr(elem, ax::attr::enabled());+ node.is_focused = get_bool_attr(elem, ax::attr::focused());+ node.is_selected = get_bool_attr(elem, ax::attr::selected());+ node.is_expanded = get_bool_attr(elem, ax::attr::expanded());+ }+}+#[cfg(test)]mod tests {use super::*;diff --git a/crates/screenpipe-a11y/src/tree/mod.rs b/crates/screenpipe-a11y/src/tree/mod.rsindex 8e3ef0136..ad9a3069e 100644--- a/crates/screenpipe-a11y/src/tree/mod.rs+++ b/crates/screenpipe-a11y/src/tree/mod.rs@@ -35,7 +35,7 @@ pub struct NodeBounds {}/// A single node extracted from the accessibility tree, preserving role and hierarchy.-#[derive(Debug, Clone, Serialize, Deserialize)]+#[derive(Debug, Clone, Default, Serialize, Deserialize)]pub struct AccessibilityTreeNode {pub role: String,pub text: String,@@ -44,6 +44,86 @@ pub struct AccessibilityTreeNode {/// None if the element doesn't expose AXPosition/AXSize.#[serde(skip_serializing_if = "Option::is_none")]pub bounds: Option<NodeBounds>,++ // --- Automation properties (all Optional, filled per-platform) ---++ /// Stable unique identifier for targeting elements.+ /// Windows: UIA AutomationId. macOS: AXIdentifier. Linux: AT-SPI object path.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub automation_id: Option<String>,+ /// Class/type info. Windows: Win32 ClassName. macOS: AXSubrole. Linux: AT-SPI attributes "class".+ #[serde(skip_serializing_if = "Option::is_none")]+ pub class_name: Option<String>,+ /// Current value (distinct from label text). For text fields, sliders, combo boxes.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub value: Option<String>,+ /// Tooltip or help text. Windows: UIA HelpText. macOS: AXHelp. Linux: AT-SPI Description.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub help_text: Option<String>,+ /// Associated URL. macOS: AXURL. Windows/Linux: extracted from value if URL-like.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub url: Option<String>,+ /// Placeholder text for input fields.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub placeholder: Option<String>,+ /// Human-readable role description. macOS: AXRoleDescription. Windows: LocalizedControlType.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub role_description: Option<String>,+ /// Fine-grained role classification. macOS: AXSubrole.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub subrole: Option<String>,+ /// Whether element is interactive/enabled.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_enabled: Option<bool>,+ /// Whether element currently has focus.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_focused: Option<bool>,+ /// Whether element is selected (list items, tabs).+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_selected: Option<bool>,+ /// Whether element is expanded (tree items, disclosure triangles).+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_expanded: Option<bool>,+ /// Whether element is a password field.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_password: Option<bool>,+ /// Whether element can receive keyboard focus.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub is_keyboard_focusable: Option<bool>,+ /// Keyboard shortcut (Windows: AcceleratorKey).+ #[serde(skip_serializing_if = "Option::is_none")]+ pub accelerator_key: Option<String>,+ /// Access key mnemonic (Windows: AccessKey).+ #[serde(skip_serializing_if = "Option::is_none")]+ pub access_key: Option<String>,+}++impl AccessibilityTreeNode {+ /// Create a node with only the core fields; all automation properties default to None.+ pub fn new(role: String, text: String, depth: u8, bounds: Option<NodeBounds>) -> Self {+ Self {+ role,+ text,+ depth,+ bounds,+ automation_id: None,+ class_name: None,+ value: None,+ help_text: None,+ url: None,+ placeholder: None,+ role_description: None,+ subrole: None,+ is_enabled: None,+ is_focused: None,+ is_selected: None,+ is_expanded: None,+ is_password: None,+ is_keyboard_focusable: None,+ accelerator_key: None,+ access_key: None,+ }+ }}/// Why the tree walk stopped early (if it did).diff --git a/crates/screenpipe-a11y/src/tree/windows.rs b/crates/screenpipe-a11y/src/tree/windows.rsindex fba300450..69b78bb12 100644--- a/crates/screenpipe-a11y/src/tree/windows.rs+++ b/crates/screenpipe-a11y/src/tree/windows.rs@@ -357,6 +357,36 @@ fn normalize_bounds(})}+/// Build an AccessibilityTreeNode from a UIA AccessibilityNode, propagating automation properties.+fn make_tree_node(+ uia_node: &AccessibilityNode,+ role: &str,+ text: &str,+ depth: usize,+ bounds: Option<NodeBounds>,+) -> AccessibilityTreeNode {+ let mut n = AccessibilityTreeNode::new(+ role.to_string(),+ text.to_string(),+ depth.min(255) as u8,+ bounds,+ );+ n.automation_id = uia_node.automation_id.clone();+ n.class_name = uia_node.class_name.clone();+ n.value = uia_node.value.clone();+ n.is_enabled = Some(uia_node.is_enabled);+ n.is_focused = uia_node.is_focused;+ n.is_keyboard_focusable = uia_node.is_keyboard_focusable;+ n.help_text = uia_node.help_text.clone();+ n.is_password = uia_node.is_password;+ n.is_selected = uia_node.is_selected;+ n.is_expanded = uia_node.is_expanded;+ n.accelerator_key = uia_node.accelerator_key.clone();+ n.access_key = uia_node.access_key.clone();+ n.role_description = uia_node.localized_control_type.clone();+ n+}+/// Recursively extract text from the accessibility tree./// Mirrors the macOS walker's text extraction strategy.fn extract_text_from_tree(@@ -393,12 +423,7 @@ fn extract_text_from_tree(if let Some(ref val) = node.value {if !val.trim().is_empty() {append_text(buffer, val);- nodes.push(AccessibilityTreeNode {- role: ct.to_string(),- text: val.trim().to_string(),- depth: depth.min(255) as u8,- bounds: norm_bounds.clone(),- });+ nodes.push(make_tree_node(node, ct, val.trim(), depth, norm_bounds.clone()));// Don't recurse into text controls — their children are sub-elements of the same textreturn;}@@ -421,12 +446,7 @@ fn extract_text_from_tree(} else {// Non-URL value — treat as text contentappend_text(buffer, trimmed);- nodes.push(AccessibilityTreeNode {- role: ct.to_string(),- text: trimmed.to_string(),- depth: depth.min(255) as u8,- bounds: norm_bounds.clone(),- });+ nodes.push(make_tree_node(node, ct, trimmed, depth, norm_bounds.clone()));}}}@@ -436,12 +456,7 @@ fn extract_text_from_tree(if let Some(ref name) = node.name {if !name.trim().is_empty() {append_text(buffer, name);- nodes.push(AccessibilityTreeNode {- role: ct.to_string(),- text: name.trim().to_string(),- depth: depth.min(255) as u8,- bounds: norm_bounds.clone(),- });+ nodes.push(make_tree_node(node, ct, name.trim(), depth, norm_bounds.clone()));}}}@@ -454,24 +469,14 @@ fn extract_text_from_tree(if let Some(ref val) = node.value {if !val.trim().is_empty() {append_text(buffer, val);- nodes.push(AccessibilityTreeNode {- role: ct.to_string(),- text: val.trim().to_string(),- depth: depth.min(255) as u8,- bounds: norm_bounds.clone(),- });+ nodes.push(make_tree_node(node, ct, val.trim(), depth, norm_bounds.clone()));}} else if ct.eq_ignore_ascii_case("Custom") {// Custom elements in Electron apps often have namesif let Some(ref name) = node.name {if !name.trim().is_empty() {append_text(buffer, name);- nodes.push(AccessibilityTreeNode {- role: ct.to_string(),- text: name.trim().to_string(),- depth: depth.min(255) as u8,- bounds: norm_bounds,- });+ nodes.push(make_tree_node(node, ct, name.trim(), depth, norm_bounds));}}}diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rsindex d56eb7d75..13f26918c 100644--- a/crates/screenpipe-db/src/db.rs+++ b/crates/screenpipe-db/src/db.rs@@ -1484,15 +1484,48 @@ impl DatabaseManager {frame_id: i64,tree_json: &str,) {- // AccessibilityTreeNode: { role, text, depth, bounds? }- #[derive(serde::Deserialize)]+ // AccessibilityTreeNode: { role, text, depth, bounds?, automation props... }+ #[derive(serde::Deserialize, serde::Serialize)]struct AxNode {role: String,text: String,depth: u8,+ #[serde(skip_serializing_if = "Option::is_none")]bounds: Option<AxBounds>,- }- #[derive(serde::Deserialize)]+ #[serde(skip_serializing_if = "Option::is_none")]+ automation_id: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ class_name: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ value: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ help_text: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ url: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ placeholder: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ role_description: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ subrole: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_enabled: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_focused: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_selected: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_expanded: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_password: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ is_keyboard_focusable: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ accelerator_key: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none")]+ access_key: Option<String>,+ }+ #[derive(serde::Deserialize, serde::Serialize)]struct AxBounds {left: f32,top: f32,@@ -1545,8 +1578,30 @@ impl DatabaseManager {None => (None, None, None, None),};+ // Serialize automation properties as JSON (only non-None fields)+ let properties = {+ let mut props = serde_json::Map::new();+ if let Some(ref v) = node.automation_id { props.insert("automation_id".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.class_name { props.insert("class_name".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.value { props.insert("value".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.help_text { props.insert("help_text".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.url { props.insert("url".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.placeholder { props.insert("placeholder".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.role_description { props.insert("role_description".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.subrole { props.insert("subrole".into(), serde_json::Value::String(v.clone())); }+ if let Some(v) = node.is_enabled { props.insert("is_enabled".into(), serde_json::Value::Bool(v)); }+ if let Some(v) = node.is_focused { props.insert("is_focused".into(), serde_json::Value::Bool(v)); }+ if let Some(v) = node.is_selected { props.insert("is_selected".into(), serde_json::Value::Bool(v)); }+ if let Some(v) = node.is_expanded { props.insert("is_expanded".into(), serde_json::Value::Bool(v)); }+ if let Some(v) = node.is_password { props.insert("is_password".into(), serde_json::Value::Bool(v)); }+ if let Some(v) = node.is_keyboard_focusable { props.insert("is_keyboard_focusable".into(), serde_json::Value::Bool(v)); }+ if let Some(ref v) = node.accelerator_key { props.insert("accelerator_key".into(), serde_json::Value::String(v.clone())); }+ if let Some(ref v) = node.access_key { props.insert("access_key".into(), serde_json::Value::String(v.clone())); }+ if props.is_empty() { None } else { Some(serde_json::Value::Object(props).to_string()) }+ };+let result = sqlx::query_scalar::<_, i64>(- "INSERT INTO elements (frame_id, source, role, text, parent_id, depth, left_bound, top_bound, width_bound, height_bound, confidence, sort_order) VALUES (?1, 'accessibility', ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, NULL, ?10) RETURNING id",+ "INSERT INTO elements (frame_id, source, role, text, parent_id, depth, left_bound, top_bound, width_bound, height_bound, confidence, sort_order, properties) VALUES (?1, 'accessibility', ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, NULL, ?10, ?11) RETURNING id",).bind(frame_id).bind(&node.role)@@ -1558,6 +1613,7 @@ impl DatabaseManager {.bind(width).bind(height).bind(sort_order)+ .bind(&properties).fetch_one(&mut **tx).await;diff --git a/crates/screenpipe-db/src/migrations/20260317000000_add_elements_automation_props.sql b/crates/screenpipe-db/src/migrations/20260317000000_add_elements_automation_props.sqlnew file mode 100644index 000000000..21f6ba16e--- /dev/null+++ b/crates/screenpipe-db/src/migrations/20260317000000_add_elements_automation_props.sql@@ -0,0 +1,3 @@+-- Add automation properties to elements table for UI automation use cases.+-- Stored as a single JSON column to avoid sparse column bloat.+ALTER TABLE elements ADD COLUMN properties TEXT;diff --git a/crates/screenpipe-engine/src/paired_capture.rs b/crates/screenpipe-engine/src/paired_capture.rsindex c96754bf7..e1a2a3565 100644--- a/crates/screenpipe-engine/src/paired_capture.rs+++ b/crates/screenpipe-engine/src/paired_capture.rs@@ -594,6 +594,7 @@ mod tests {text: "Hello World - Example Page".to_string(),depth: 0,bounds: None,+ ..Default::default()}],browser_url: Some("https://example.com".to_string()),timestamp: now,@@ -777,6 +778,7 @@ mod tests {text: "Lots of real content here that is very long and should normally be fine".into(),depth: 0,bounds: None,+ ..Default::default()}]);// Google Docs in window title → always thin regardless of contentassert!(a11y_content_is_thin(@@ -797,9 +799,9 @@ mod tests {fn test_not_thin_normal_webpage() {// Normal webpage: mostly AXStaticText contentlet snap = make_snap(vec![- AccessibilityTreeNode { role: "AXButton".into(), text: "Menu".into(), depth: 0, bounds: None },- AccessibilityTreeNode { role: "AXStaticText".into(), text: "This is a long article about dogs. Dogs are domesticated descendants of wolves. They were the first species to be domesticated over 14,000 years ago.".into(), depth: 1, bounds: None },- AccessibilityTreeNode { role: "AXLink".into(), text: "Read more about canine history".into(), depth: 1, bounds: None },+ AccessibilityTreeNode { role: "AXButton".into(), text: "Menu".into(), depth: 0, bounds: None, ..Default::default() },+ AccessibilityTreeNode { role: "AXStaticText".into(), text: "This is a long article about dogs. Dogs are domesticated descendants of wolves. They were the first species to be domesticated over 14,000 years ago.".into(), depth: 1, bounds: None, ..Default::default() },+ AccessibilityTreeNode { role: "AXLink".into(), text: "Read more about canine history".into(), depth: 1, bounds: None, ..Default::default() },]);assert!(!a11y_content_is_thin(&snap, Some("Dog - Wikipedia"), None, None));}@@ -813,90 +815,105 @@ mod tests {text: "File".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "Edit".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "View".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "Insert".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "Format".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "Tools".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXButton".into(),text: "Help".into(),depth: 0,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Undo".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Redo".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Cut".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Copy".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Paste".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Select All".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXMenuItem".into(),text: "Find and Replace".into(),depth: 1,bounds: None,+ ..Default::default()},AccessibilityTreeNode {role: "AXStaticText".into(),text: "Untitled".into(),depth: 0,bounds: None,+ ..Default::default()},]);// >70% chrome text@@ -910,6 +927,7 @@ mod tests {text: "Loading...".into(),depth: 0,bounds: None,+ ..Default::default()}]);// < 100 chars totalassert!(a11y_content_is_thin(&snap, Some("Some App"), None, None));@@ -919,9 +937,9 @@ mod tests {fn test_not_thin_vscode() {// VS Code: lots of AXStaticText from editor contentlet snap = make_snap(vec![- AccessibilityTreeNode { role: "AXButton".into(), text: "Explorer".into(), depth: 0, bounds: None },- AccessibilityTreeNode { role: "AXButton".into(), text: "Search".into(), depth: 0, bounds: None },- AccessibilityTreeNode { role: "AXStaticText".into(), text: "fn main() { println!(\"hello world\"); } // This is a Rust program with many lines of code that form a substantial amount of content text in the editor buffer area".into(), depth: 1, bounds: None },+ AccessibilityTreeNode { role: "AXButton".into(), text: "Explorer".into(), depth: 0, bounds: None, ..Default::default() },+ AccessibilityTreeNode { role: "AXButton".into(), text: "Search".into(), depth: 0, bounds: None, ..Default::default() },+ AccessibilityTreeNode { role: "AXStaticText".into(), text: "fn main() { println!(\"hello world\"); } // This is a Rust program with many lines of code that form a substantial amount of content text in the editor buffer area".into(), depth: 1, bounds: None, ..Default::default() },]);assert!(!a11y_content_is_thin(&snap,@@ -936,7 +954,7 @@ mod tests {// When inside a Google Doc, window title is the doc name, not "Google Docs".// Use enough content text so the heuristic alone wouldn't flag it as thin.let snap = make_snap(vec![- AccessibilityTreeNode { role: "AXStaticText".into(), text: "Docs home Star Add shortcut to Drive Document status Saved to Drive Request edit access Share Anyone with the link Join a call here or present".into(), depth: 0, bounds: None },+ AccessibilityTreeNode { role: "AXStaticText".into(), text: "Docs home Star Add shortcut to Drive Document status Saved to Drive Request edit access Share Anyone with the link Join a call here or present".into(), depth: 0, bounds: None, ..Default::default() },]);// Window title is doc name, but URL reveals it's Google Docs → thinassert!(a11y_content_is_thin(diff --git a/crates/screenpipe-engine/src/routes/frames.rs b/crates/screenpipe-engine/src/routes/frames.rsindex d2954e6a5..3dee5752c 100644--- a/crates/screenpipe-engine/src/routes/frames.rs+++ b/crates/screenpipe-engine/src/routes/frames.rs@@ -492,6 +492,9 @@ pub struct AccessibilityNode {pub depth: u32,#[serde(skip_serializing_if = "Option::is_none")]pub bounds: Option<AccessibilityNodeBounds>,+ /// Automation properties (stable ID, class, state, etc.) — present for newer captures.+ #[serde(skip_serializing_if = "Option::is_none")]+ pub properties: Option<serde_json::Value>,}/// Response type for frame context endpoint (accessibility-first, OCR fallback)@@ -558,11 +561,30 @@ pub async fn get_frame_context(})});+ // Collect automation properties if present+ let properties = {+ let mut props = serde_json::Map::new();+ for key in &[+ "automation_id", "class_name", "value", "help_text",+ "url", "placeholder", "role_description", "subrole",+ "is_enabled", "is_focused", "is_selected", "is_expanded",+ "is_password", "is_keyboard_focusable", "accelerator_key", "access_key",+ ] {+ if let Some(v) = node_val.get(*key) {+ if !v.is_null() {+ props.insert((*key).to_string(), v.clone());+ }+ }+ }+ if props.is_empty() { None } else { Some(serde_json::Value::Object(props)) }+ };+nodes.push(AccessibilityNode {role: role.clone(),text: text.clone(),depth,bounds,+ properties,});// Extract URLs from link rolesdiff --git a/crates/screenpipe-screen/Cargo.toml b/crates/screenpipe-screen/Cargo.tomlindex 96cf4bc39..ed65a2564 100644--- a/crates/screenpipe-screen/Cargo.toml+++ b/crates/screenpipe-screen/Cargo.toml@@ -86,7 +86,7 @@ core-foundation = "0.10"core-graphics = "0.24"[target.'cfg(target_os = "windows")'.dependencies]-xcap = "0.8.1"+xcap = { version = "0.8.1", features = ["wgc"] }uiautomation = { version = "0.16.1" }windows = { version = "0.58", features = ["Graphics_Imaging",