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: retry search navigation emit to handle webview mount race

Louis Beaumont2015137a1a89
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
index d453ddab7..8f5bda2eb 100644
--- a/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/timeline.tsx
@@ -898,8 +898,12 @@ export default function Timeline({ embedded = false }: { embedded?: boolean }) {
// (order_out) so frames could be stale/empty. navigateDirectToDate does
// a fresh fetch and uses pendingNavigationRef to jump once frames arrive.
useEffect(() => {
+ let lastHandledTs = "";
const unlisten = listen<{ timestamp: string }>("search-navigate-to-timestamp", (event) => {
const timestamp = event.payload.timestamp;
+ // Deduplicate — Rust emits multiple times to survive mount race
+ if (timestamp === lastHandledTs) return;
+ lastHandledTs = timestamp;
const targetDate = new Date(timestamp);
setSeekingTimestamp(timestamp);
setSearchNavFrame(true);
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index 1bf89936e..e8a320c81 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -546,11 +546,15 @@ pub async fn search_navigate_to_timeline(
// Show the Main timeline
ShowRewindWindow::Main.show(&app_handle).map_err(|e| e.to_string())?;
- // Small delay for the Main webview to restore focus and process events
+ // Emit the navigation event multiple times — the Main webview may take
+ // varying time to restore from order_out and mount the event listener.
+ // The JS side deduplicates via a seekingTimestamp ref.
let app = app_handle.clone();
tokio::spawn(async move {
- tokio::time::sleep(tokio::time::Duration::from_millis(300)).await;
- let _ = app.emit("search-navigate-to-timestamp", serde_json::json!({ "timestamp": timestamp }));
+ for i in 0..5 {
+ tokio::time::sleep(tokio::time::Duration::from_millis(if i == 0 { 200 } else { 200 })).await;
+ let _ = app.emit("search-navigate-to-timestamp", serde_json::json!({ "timestamp": timestamp }));
+ }
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
let _ = ShowRewindWindow::Search { query: None }.close(&app);
});