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(macos): don't restore previous app on Space switch
Louis Beaumontf3edcaf34296
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs b/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rsindex 5251fa7a8..7a5165d89 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs@@ -36,7 +36,10 @@ pub fn setup_space_listener(app: AppHandle) {// Create the block that will be called when space changeslet block = block::ConcreteBlock::new(move |_notification: id| {debug!("macOS Space changed, hiding overlay");- crate::window_api::restore_frontmost_app();+ // Do NOT restore_frontmost_app here — the user intentionally+ // switched Spaces, so re-activating the previous app would+ // pull them back. Just clear the saved app and hide.+ crate::window_api::clear_frontmost_app();hide_main_window(&app_for_block);});let block = block.copy();diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rsindex 43577d5e0..ffb378f18 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs@@ -74,6 +74,27 @@ pub fn restore_frontmost_app() {}}+/// Clear the saved frontmost app without re-activating it.+/// Used when the user intentionally switches Spaces — we don't want to+/// pull them back by re-activating the previous app.+#[cfg(target_os = "macos")]+pub fn clear_frontmost_app() {+ use objc::{msg_send, sel, sel_impl};+ let ptr = {+ let mut prev = PREVIOUS_FRONTMOST_APP.lock().unwrap();+ let p = *prev;+ *prev = 0;+ p+ };+ if ptr != 0 {+ use tauri_nspanel::cocoa::base::id;+ unsafe {+ let app: id = ptr as id;+ let _: () = msg_send![app, release];+ }+ }+}+/// Tracks which overlay mode the current Main window was created for./// When the mode changes, show() hides the old panel and creates a fresh one/// under a different label to avoid NSPanel reconfiguration crashes.