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(updater): apply tray restart-to-update in backend, dedupe restarts (#5193)
Divanshuf069edaa12c7
diff --git a/apps/screenpipe-app-tauri/components/update-banner.tsx b/apps/screenpipe-app-tauri/components/update-banner.tsxindex 69af9431b..cd5d5b956 100644--- a/apps/screenpipe-app-tauri/components/update-banner.tsx+++ b/apps/screenpipe-app-tauri/components/update-banner.tsx@@ -331,11 +331,10 @@ interface PendingUpdateSnapshot {// state from Rust so it can recover if the event fired before this hook// registered (boot-time webview race).export function useUpdateListener() {- const { setIsVisible, setUpdateInfo, setAuthRequired, resetDismissed } = useUpdateBanner();+ const { setIsVisible, setUpdateInfo, setAuthRequired } = useUpdateBanner();useEffect(() => {let unlistenAvailable: (() => void) | undefined;- let unlistenClick: (() => void) | undefined;let unlistenAuth: (() => void) | undefined;// Rust re-emits update-available on every periodic check, and providers@@ -361,13 +360,6 @@ export function useUpdateListener() {showIfNotDismissed(event.payload);});- // Tray click is an explicit user request — clear any prior dismissal- // so the banner reappears even if they X'd it earlier this session.- unlistenClick = await listen("update-now-clicked", () => {- resetDismissed();- setIsVisible(true);- });-// Listen for auth-required (user needs to sign in to download update)unlistenAuth = await listen<AuthRequiredInfo>("update-auth-required", (event) => {showAuthIfNotDismissed(event.payload);@@ -394,8 +386,7 @@ export function useUpdateListener() {return () => {unlistenAvailable?.();- unlistenClick?.();unlistenAuth?.();};- }, [setIsVisible, setUpdateInfo, setAuthRequired, resetDismissed]);+ }, [setIsVisible, setUpdateInfo, setAuthRequired]);}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rsindex 0fe7c793e..0d271cd1c 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs@@ -1566,7 +1566,12 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {tauri::async_runtime::spawn(async move {let state = app.state::<std::sync::Arc<crate::updates::UpdatesManager>>();if state.has_update_installed().await {- let _ = app.emit("update-now-clicked", ());+ // apply via the same backend path as the banner instead+ // of round-tripping through the frontend.+ if let Err(e) = crate::updates::restart_for_update(app.clone(), None).await+ {+ tracing::error!("tray menu: restart for update failed: {}", e);+ }} else if let Err(e) = state.check_for_updates(true, true).await {tracing::error!("tray menu: check for updates failed: {}", e);}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rsindex 783033137..9ed3994c1 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -290,6 +290,10 @@ pub async fn await_safe_restart(timeout_secs: Option<u64>) -> String {}}+/// True once a surface has committed to applying a staged update; keeps a+/// second trigger from starting a parallel teardown+relaunch.+static UPDATE_RESTART_STARTED: AtomicBool = AtomicBool::new(false);+/// Banner-click restart. Mirror the auto-update path: gate, stop server, then/// spawn the replacement app and `_exit` the old process so C/C++ atexit/// handlers cannot abort during restart. See 2026-06-10 and 2026-07-02 reports.@@ -305,6 +309,12 @@ pub async fn restart_for_update(return Ok(gate.as_str().to_string());}+ // Only the first trigger applies; later ones ride the in-flight restart.+ if UPDATE_RESTART_STARTED.swap(true, Ordering::SeqCst) {+ info!("banner restart: update-restart already in progress, ignoring");+ return Ok("proceed".to_string());+ }+info!("banner restart: gate passed, shutting down for update");// Non-fatal AND time-bounded: a wedged capture/audio teardown must not@@ -941,6 +951,12 @@ impl UpdatesManager {return Result::Ok(true);}+ // Only the first trigger applies; defer to an in-flight restart.+ if UPDATE_RESTART_STARTED.swap(true, Ordering::SeqCst) {+ info!("auto-update: update-restart already in progress, deferring");+ return Result::Ok(true);+ }+let _ = self.app.emit("update-restarting",serde_json::json!({