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(windows): deep-link flood, tree-walker panic, UIA recovery
Louis Beaumont7681888661c1
diff --git a/apps/screenpipe-app-tauri/components/deeplink-handler.tsx b/apps/screenpipe-app-tauri/components/deeplink-handler.tsxindex b361a38af..b8c21b681 100644--- a/apps/screenpipe-app-tauri/components/deeplink-handler.tsx+++ b/apps/screenpipe-app-tauri/components/deeplink-handler.tsx@@ -77,9 +77,10 @@ export function DeeplinkHandler() {if (url.includes("onboarding")) {try {await commands.showWindow("Onboarding");- // Forward specific deep link events so onboarding components can react+ // Forward specific deep link events so onboarding components can react.+ // Use a dedicated event name to avoid re-triggering the main deep-link listener.if (url.includes("onboarding-read-complete")) {- await emit("deep-link-received", url);+ await emit("onboarding-read-complete", url);}} catch (error) {console.error("Failed to show onboarding window:", error);diff --git a/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx b/apps/screenpipe-app-tauri/components/onboarding/read-content.tsxindex 1d22d17c4..ec8c378bc 100644--- a/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx+++ b/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx@@ -83,7 +83,7 @@ export default function ReadContent({ handleNextSlide }: ReadContentProps) {// listen for deep link returnuseEffect(() => {let unlisten: (() => void) | undefined;- listen("deep-link-received", async (event) => {+ listen("onboarding-read-complete", async (event) => {const url = String(event.payload);if (url.includes("onboarding-read-complete")) {// restore window before advancingdiff --git a/crates/screenpipe-accessibility/src/platform/windows_uia.rs b/crates/screenpipe-accessibility/src/platform/windows_uia.rsindex 8c922f399..2692e44bb 100644--- a/crates/screenpipe-accessibility/src/platform/windows_uia.rs+++ b/crates/screenpipe-accessibility/src/platform/windows_uia.rs@@ -370,10 +370,23 @@ pub fn run_uia_thread(// Initialize UIA context with retries — COM services may not be ready// immediately after system boot or when resuming from sleep.- let uia = {+ // Outer loop retries every 30s if all 4 quick attempts fail, allowing+ // recovery from prolonged system unavailability (boot, sleep resume).+ let uia = 'outer: loop {+ if stop.load(std::sync::atomic::Ordering::Relaxed) {+ debug!("Stop flag set before UIA init, exiting");+ unsafe { CoUninitialize() };+ return;+ }+let mut last_err = None;let mut ctx = None;for attempt in 0..4 {+ if stop.load(std::sync::atomic::Ordering::Relaxed) {+ debug!("Stop flag set during UIA init attempts, exiting");+ unsafe { CoUninitialize() };+ return;+ }match UiaContext::new() {Ok(c) => {ctx = Some(c);@@ -393,14 +406,21 @@ pub fn run_uia_thread(}}match ctx {- Some(c) => c,+ Some(c) => break 'outer c,None => {- error!(- "Failed to initialize UI Automation after 4 attempts: {:?}",+ warn!(+ "Failed to initialize UI Automation after 4 attempts: {:?}. Will retry in 30s.",last_err);- unsafe { CoUninitialize() };- return;+ // Wait 30s before retrying, checking stop flag periodically+ for _ in 0..30 {+ if stop.load(std::sync::atomic::Ordering::Relaxed) {+ debug!("Stop flag set during UIA retry backoff, exiting");+ unsafe { CoUninitialize() };+ return;+ }+ std::thread::sleep(std::time::Duration::from_secs(1));+ }}}};diff --git a/crates/screenpipe-server/src/ui_recorder.rs b/crates/screenpipe-server/src/ui_recorder.rsindex 79d904f2b..b93d04227 100644--- a/crates/screenpipe-server/src/ui_recorder.rs+++ b/crates/screenpipe-server/src/ui_recorder.rs@@ -393,15 +393,19 @@ pub async fn start_ui_recording(let join_handle = std::thread::Builder::new().name("tree-walker".to_string()).spawn(move || {- run_tree_walker(- tree_db,- tree_stop,- walk_interval,- rt_handle,- tree_wake,- ignored_windows_clone,- included_windows_clone,- );+ if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {+ run_tree_walker(+ tree_db,+ tree_stop,+ walk_interval,+ rt_handle,+ tree_wake,+ ignored_windows_clone,+ included_windows_clone,+ );+ })) {+ error!("tree-walker thread panicked: {:?}", e);+ }}).expect("failed to spawn tree-walker thread");// Wrap in a JoinHandle<()> compatible with the tokio handle used on other platforms@@ -575,6 +579,13 @@ fn run_tree_walker(}if cache.should_store(&snap) {+ // Check stop flag before blocking on the runtime — during shutdown+ // the tokio context may be tearing down, causing a panic in block_on.+ if stop.load(std::sync::atomic::Ordering::Relaxed) {+ debug!("Stop flag set, skipping DB insert for accessibility text");+ break;+ }+metrics.total_text_chars += snap.text_content.len() as u64;match rt_handle.block_on(db.insert_accessibility_text(