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(semantic): truncate per-node class overflow instead of rejecting the tree
Louis Beaumont6c896899d9d0
diff --git a/crates/screenpipe-semantic/src/capture.rs b/crates/screenpipe-semantic/src/capture.rsindex 0417a8fa2..71d07dd1f 100644--- a/crates/screenpipe-semantic/src/capture.rs+++ b/crates/screenpipe-semantic/src/capture.rs@@ -84,6 +84,7 @@ pub struct CaptureAdapterStats {pub class_nodes: usize,pub subrole_nodes: usize,pub value_nodes: usize,+ pub class_overflow_nodes: usize,}/// Result of adapting a captured flat tree into the compact parser arena.@@ -141,9 +142,11 @@ pub fn adapt_captured_accessibility_tree(.filter(|class| !class.is_empty()){if class_count == MAX_CAPTURE_CLASSES_PER_NODE {- return Err(TreeBuildError::TooManyClassesOnNode {- count: class_count + 1,- });+ // Utility-CSS apps (Tailwind through Chromium UIA ClassName)+ // routinely exceed the scratch space; classes are matching+ // hints, so keep the first N rather than rejecting the tree.+ stats.class_overflow_nodes += 1;+ break;}class_buffer[class_count] = class;class_count += 1;diff --git a/crates/screenpipe-semantic/tests/capture_adapter.rs b/crates/screenpipe-semantic/tests/capture_adapter.rsindex a84bd19a2..fd6f264b1 100644--- a/crates/screenpipe-semantic/tests/capture_adapter.rs+++ b/crates/screenpipe-semantic/tests/capture_adapter.rs@@ -189,6 +189,9 @@ fn skips_empty_roles_but_preserves_budget_errors() {#[test]fn bounds_per_node_class_scratch_space() {+ // Utility-CSS apps (Tailwind via Chromium UIA ClassName) exceed the+ // scratch space on real Windows trees; the adapter must truncate and+ // count, never reject the whole tree.let class_name = (0..33).map(|index| format!("class-{index}")).collect::<Vec<_>>()@@ -199,7 +202,13 @@ fn bounds_per_node_class_scratch_space() {..Default::default()}];- assert!(adapt_captured_accessibility_tree(&nodes, TreeBudget::default()).is_err());+ let adapted = adapt_captured_accessibility_tree(&nodes, TreeBudget::default()).unwrap();+ assert_eq!(adapted.stats.class_overflow_nodes, 1);+ let root = adapted.tree.roots().next().unwrap();+ assert_eq!(adapted.tree.classes(root).count(), 32);+ assert!(adapted.tree.has_class(root, "class-0"));+ assert!(adapted.tree.has_class(root, "class-31"));+ assert!(!adapted.tree.has_class(root, "class-32"));}#[test]