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(tray): quit menu item now actually quits the app
Louis Beaumontba546a70ab33
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex a3617d3bf..c068f222a 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1570,11 +1570,16 @@ async fn main() {});}tauri::RunEvent::ExitRequested { api, .. } => {- // Always prevent auto-exit — the app should stay alive in the- // tray even when all windows are closed / destroyed.- // Only the explicit "Quit screenpipe" menu item calls app.exit().- info!("ExitRequested event — preventing (app stays in tray)");- api.prevent_exit();+ // When the user clicks "quit screenpipe" in the tray menu,+ // QUIT_REQUESTED is set to true — let the exit proceed.+ // Otherwise, prevent auto-exit so the app stays alive in the+ // tray when all windows are closed / destroyed.+ if tray::QUIT_REQUESTED.load(std::sync::atomic::Ordering::SeqCst) {+ info!("ExitRequested event — quit was requested, allowing exit");+ } else {+ info!("ExitRequested event — preventing (app stays in tray)");+ api.prevent_exit();+ }}tauri::RunEvent::Exit => {diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rsindex 614329005..637ae6269 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs@@ -7,6 +7,7 @@ use crate::window_api::ShowRewindWindow;use anyhow::Result;use once_cell::sync::Lazy;use std::collections::HashMap;+use std::sync::atomic::{AtomicBool, Ordering};use std::sync::Mutex;use tauri::tray::{TrayIcon, TrayIconBuilder};use tauri::Emitter;@@ -19,6 +20,10 @@ use tauri_plugin_opener::OpenerExt;use tracing::{debug, error, info};+/// Flag set by the "quit screenpipe" menu item so that the ExitRequested+/// handler in main.rs knows this is an intentional quit (not just a window close).+pub static QUIT_REQUESTED: AtomicBool = AtomicBool::new(false);+/// Global storage for the update menu item so we can recreate the tray/// without needing to pass the update_item through every call chain.static UPDATE_MENU_ITEM: Lazy<Mutex<Option<MenuItem<Wry>>>> = Lazy::new(|| Mutex::new(None));@@ -338,6 +343,10 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {"quit" => {debug!("Quit requested");+ // Signal that this is an intentional quit so the ExitRequested+ // handler in main.rs won't prevent it.+ QUIT_REQUESTED.store(true, Ordering::SeqCst);+// Stop recording before exitinglet app_handle_clone = app_handle.clone();tauri::async_runtime::spawn(async move {