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: ensure notifications always dismiss, especially on Windows

Louis Beaumontb8431bfca181
diff --git a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
index 48bfc5967..97b4f7054 100644
--- a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
+++ b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx
@@ -275,6 +275,13 @@ export default function NotificationPanelPage() {
let elapsedBeforePause = 0;
let resumedAt = Date.now();
let wasHovered = false;
+ let dismissed = false;
+
+ const doHide = () => {
+ if (dismissed) return;
+ dismissed = true;
+ hide(true);
+ };
intervalRef.current = setInterval(() => {
if (hoveredRef.current) {
@@ -295,15 +302,25 @@ export default function NotificationPanelPage() {
setProgress(remaining);
if (remaining <= 0) {
- hide(true);
+ doHide();
}
}, 50);
+ // Safety fallback: setTimeout is more reliable than setInterval on
+ // Windows where unfocused webview timers can be throttled to ~1s.
+ // This ensures the notification always dismisses even if setInterval stalls.
+ const safetyTimeout = setTimeout(() => {
+ if (!hoveredRef.current) {
+ doHide();
+ }
+ }, totalMs + 2000);
+
return () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
+ clearTimeout(safetyTimeout);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, hide, notificationEpoch]);
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index 509c84caf..5b0dd3b4d 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -1294,6 +1294,12 @@ pub async fn show_notification_panel(
}
};
+ // Parse autoDismissMs from payload for the server-side safety timeout
+ let auto_dismiss_ms: u64 = serde_json::from_str::<serde_json::Value>(&payload)
+ .ok()
+ .and_then(|v| v.get("autoDismissMs")?.as_u64())
+ .unwrap_or(20000);
+
// If window exists, reposition to current screen and show
if let Some(window) = app_handle.get_webview_window(label) {
info!("notification-panel window exists, repositioning and showing");
@@ -1331,6 +1337,21 @@ pub async fn show_notification_panel(
}
});
}
+
+ // Server-side safety timeout: force-hide the notification if the JS
+ // auto-dismiss timer fails (e.g. webview timer throttled on Windows).
+ // Adds 5s buffer so JS normally handles it first.
+ let app_safety = app_handle.clone();
+ tokio::spawn(async move {
+ tokio::time::sleep(std::time::Duration::from_millis(auto_dismiss_ms + 5000)).await;
+ if let Some(w) = app_safety.get_webview_window("notification-panel") {
+ if w.is_visible().unwrap_or(false) {
+ info!("Safety timeout: force-hiding notification panel");
+ let _ = w.hide();
+ }
+ }
+ });
+
return Ok(());
}
@@ -1427,6 +1448,19 @@ pub async fn show_notification_panel(
);
});
+ // Server-side safety timeout for newly created windows too
+ let app_safety = app_handle.clone();
+ tokio::spawn(async move {
+ // 2s wait for mount + autoDismissMs + 5s buffer
+ tokio::time::sleep(std::time::Duration::from_millis(auto_dismiss_ms + 7000)).await;
+ if let Some(w) = app_safety.get_webview_window("notification-panel") {
+ if w.is_visible().unwrap_or(false) {
+ info!("Safety timeout: force-hiding notification panel (new window)");
+ let _ = w.hide();
+ }
+ }
+ });
+
Ok(())
}