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: preserve the existing Quit flow when retaining search
Ezra Ellette25fef7207ed1
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/headless.rs b/apps/screenpipe-app-tauri/src-tauri/src/headless.rsindex eb903eba1..88e1fea38 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/headless.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/headless.rs@@ -155,6 +155,7 @@ fn mark_dormant(app: &AppHandle) {}fn enter_on_main_thread(app: &AppHandle) -> Result<(), String> {+ crate::tray::sync_search_visibility(app).map_err(|error| error.to_string())?;if let Err(error) = app.global_shortcut().unregister_all() {warn!("headless: failed to unregister global shortcuts: {error}");}@@ -250,6 +251,10 @@ pub fn wake_from_tray(app: &AppHandle) -> bool {return false;}+ if let Err(error) = crate::tray::sync_search_visibility(app) {+ warn!("headless: failed to restore tray visibility: {error}");+ }+#[cfg(target_os = "macos")]crate::window::reset_to_regular_and_refresh_tray(app);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs b/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rsindex 0f12ac12b..7261189dd 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/process_exit.rs@@ -573,7 +573,7 @@ fn hide_app_to_tray(app: &AppHandle) {////// Only user-initiated quit paths (app menu Cmd+Q, tray Quit, dock Quit via/// `ExitRequested`) go through here — programmatic paths (updater restart,-/// relaunch) call [`request_app_quit`] / [`request_app_relaunch`] directly so+/// relaunch) call [`request_full_app_quit`] / [`request_app_relaunch`] directly so/// they never block on a dialog.#[cfg(target_os = "macos")]pub fn confirm_and_request_app_quit(app: AppHandle) {@@ -593,7 +593,7 @@ pub fn confirm_and_request_app_quit(app: AppHandle) {.unwrap_or(false);if !recording_active {info!("Quit requested with no active recording — skipping confirmation");- request_user_quit(app);+ request_app_quit(app);return;}@@ -709,7 +709,7 @@ fn show_quit_alert(app: &AppHandle, show_minimize: bool, message: &str) {QUIT_CONFIRM_SHOWING.store(false, Ordering::SeqCst);match response {- FIRST_BUTTON => request_user_quit(app.clone()),+ FIRST_BUTTON => request_app_quit(app.clone()),SECOND_BUTTON if show_minimize => {info!("Quit dialog: minimizing to tray instead");hide_app_to_tray(app);@@ -721,21 +721,21 @@ fn show_quit_alert(app: &AppHandle, show_minimize: bool, message: &str) {#[cfg(not(target_os = "macos"))]pub fn confirm_and_request_app_quit(app: AppHandle) {- request_user_quit(app);+ request_app_quit(app);}/// User Quit may retain search. Programmatic exit, OS logout, and updater/// handoffs continue through the existing full-exit path.-pub(crate) fn request_user_quit(app: AppHandle) {+pub fn request_app_quit(app: AppHandle) {if crate::search_only::keep_after_quit(&app) {crate::search_only::request_enter(app);} else {- request_app_quit(app);+ request_full_app_quit(app);}}-/// Shared quit entry point for tray menu, app menu (Cmd+Q), etc.-pub fn request_app_quit(app: AppHandle) {+/// Full exit for confirmed opt-out Quit, updater handoffs, and failed teardown.+pub(crate) fn request_full_app_quit(app: AppHandle) {if crate::db_recovery_notifications::recovery_active() {info!("Quit ignored while protected database recovery is active");crate::db_recovery_notifications::notify_recovery_quit_blocked();diff --git a/apps/screenpipe-app-tauri/src-tauri/src/search_only.rs b/apps/screenpipe-app-tauri/src-tauri/src/search_only.rsindex 7bb2198d0..48dc7db47 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/search_only.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/search_only.rs@@ -243,7 +243,7 @@ pub fn request_enter(app: AppHandle) {"search_only_stop_slow","cause=quit_transition_timeout; outcome=full_exit",);- crate::process_exit::request_app_quit(app);+ crate::process_exit::request_full_app_quit(app);return;}};@@ -272,7 +272,7 @@ pub fn request_enter(app: AppHandle) {&format!("cause={error}; outcome=full_exit"),);// Quit must stop capture even if retaining search fails.- crate::process_exit::request_app_quit(app);+ crate::process_exit::request_full_app_quit(app);return;}}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/apps/screenpipe-app-tauri/src-tauri/src/server.rsindex 64a3ec6a6..a1e92d627 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/server.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/server.rs@@ -681,7 +681,7 @@ async fn e2e_search_only_state(State(state): State<ServerState>) -> impl IntoRes#[cfg(feature = "e2e")]async fn e2e_search_only_quit(State(state): State<ServerState>) -> impl IntoResponse {// The same action chosen by the native Quit confirmation's first button.- crate::process_exit::request_user_quit(state.app_handle);+ crate::process_exit::request_app_quit(state.app_handle);Json(serde_json::json!({"accepted": true}))}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rsindex be70ef99a..f6526952d 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs@@ -395,9 +395,6 @@ async fn run_tray_recording_action(let state = app.state::<RecordingState>();match action {TrayRecordingAction::Start => {- if crate::search_only::is_active() {- crate::headless::wake_from_tray(app);- }let data_dir = crate::db_recovery_notifications::effective_recovery_data_dir(app)?;let database_path = data_dir.join("db.sqlite");match tray_start_route_with(|| database_has_confirmed_damage(&database_path))? {@@ -1070,6 +1067,16 @@ pub fn setup_tray(app: &AppHandle, update_item: Option<&tauri::menu::MenuItem<Wr// poller or the startup "Starting…" menu is never rebuilt.setup_tray_menu_updater(app.clone(), update_item);}+ sync_search_visibility(app)?;+ Ok(())+}++/// Confirmed Quit leaves no tray UI. Reopening restores the same tray item.+/// Call on the main thread, including after a search-only updater relaunch.+pub(crate) fn sync_search_visibility(app: &AppHandle) -> Result<()> {+ if let Some(tray) = app.tray_by_id("screenpipe_main") {+ tray.set_visible(!crate::search_only::is_active())?;+ }Ok(())}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs b/apps/screenpipe-app-tauri/src-tauri/src/updates.rsindex c7fc36c66..a26681e64 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/updates.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/updates.rs@@ -635,7 +635,7 @@ pub async fn restart_for_update(// Keep the reservation until process exit, including that IPC delay.std::mem::forget(restart);if persistent_version.is_some() {- crate::process_exit::request_app_quit(app.clone());+ crate::process_exit::request_full_app_quit(app.clone());} else {crate::process_exit::request_prepared_app_relaunch(app.clone(),@@ -1761,7 +1761,7 @@ impl UpdatesManager {}std::mem::forget(restart);if persistent_update {- crate::process_exit::request_app_quit(self.app.clone());+ crate::process_exit::request_full_app_quit(self.app.clone());} else {crate::process_exit::request_prepared_app_relaunch(self.app.clone(),diff --git a/docs/TESTING.md b/docs/TESTING.mdindex c8c30a19f..082d46c81 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -298,7 +298,7 @@ commits: `d9d43d31`, `620c89a5`, `14acf6f0`commits: `94531265`, `d794176a`, `9070639c`, `0378cab1`, `4a3313d3`, `7ffdd4f1`, `1b36f62d`-- [ ] **Quit keeps search available (default On)** — tray, dock, and Cmd+Q stop screen/audio/UI capture and destroy webviews. A saved-history request still succeeds through the same API; attempts to start capture or workflows fail. Reopen into the same PID with capture paused, then explicitly resume. Repeat after sleep/wake and an update restart. Check idle CPU/memory and that recording devices and child agents are released.+- [ ] **Quit keeps search available (default On)** — preserve the existing recording-aware Quit / Minimize to Tray / Cancel dialog for tray, dock, and Cmd+Q. Cancel changes nothing; Minimize retains recording and the tray. Confirmed Quit stops screen/audio/UI capture, destroys webviews, and hides the tray and dock. A saved-history request still succeeds through the same API; attempts to start capture or workflows fail. Reopen into the same PID with capture paused and the tray restored, then explicitly resume. Repeat after sleep/wake and an update restart. Check idle CPU/memory and that recording devices and child agents are released.- [ ] **clean quit via tray (Keep search available after quitting Off)** — right-click tray → Quit. all processes terminate. no orphaned ffmpeg/bun processes. Explicit Off survives restart; OS logout/shutdown exits regardless of the setting.- [ ] **clean quit via dock** — right-click dock → Quit. same as above.- [ ] **clean quit via Cmd+Q** — same verification.