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: settings window disappearing on macOS workspace swipe

Louis Beaumont4b2977e731fd
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index be36e0092..31eaf3af2 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -1382,6 +1382,16 @@ async fn main() {
tauri::WindowEvent::CloseRequested { api, .. } => {
let _ = window.set_always_on_top(false);
let _ = window.set_visible_on_all_workspaces(false);
+
+ // Settings window on macOS: prevent close but do NOT hide.
+ // macOS sends spurious CloseRequested during workspace swipes
+ // and hiding the window makes it disappear when swiping back.
+ #[cfg(target_os = "macos")]
+ if window.label() == "settings" {
+ api.prevent_close();
+ return;
+ }
+
#[cfg(target_os = "macos")]
crate::window_api::reset_to_regular_and_refresh_tray(window.app_handle());
// On Windows, let the settings window close normally when user
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
index ce139d433..276cd82f5 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/window_api.rs
@@ -230,16 +230,41 @@ fn is_own_app_still_active() -> bool {
/// Conditionally restore or clear the saved frontmost app.
/// If our own app is still active (focus moved to another screenpipe window
/// like Settings), we just clear without restoring — otherwise Settings/Chat
-/// would lose keyboard focus. If the app is no longer active (focus went to
-/// an external app like Chrome), we restore as normal.
+/// would lose keyboard focus. Also skip restoring if any screenpipe window
+/// (like Settings) is still open — during workspace swipes the app
+/// deactivates briefly but we don't want to pull another app to the front.
+/// Conditionally restore or clear the saved frontmost app.
+/// If our own app is still active (focus moved to another screenpipe window
+/// like Settings), we just clear without restoring — otherwise Settings/Chat
+/// would lose keyboard focus. Also skip restoring if any screenpipe window
+/// (like Settings) is still open — during workspace swipes the app
+/// deactivates briefly but we don't want to pull another app to the front.
#[cfg(target_os = "macos")]
-fn restore_frontmost_app_if_external() {
+fn restore_frontmost_app_if_external_with_app(app: Option<&AppHandle>) {
if is_own_app_still_active() {
info!("Focus moved to another screenpipe window, clearing saved app without restoring");
clear_frontmost_app();
- } else {
- restore_frontmost_app();
+ return;
}
+
+ // Check if Settings, Chat, or Search windows exist in Tauri's registry.
+ // These are regular windows (not panels) that may be on another Space —
+ // we don't want to activate a previous app and bury them.
+ if let Some(app) = app {
+ let non_panel_labels = ["settings", "chat", "search"];
+ for label in &non_panel_labels {
+ if app.get_webview_window(label).is_some() {
+ info!(
+ "Screenpipe '{}' window still open, clearing saved app without restoring",
+ label
+ );
+ clear_frontmost_app();
+ return;
+ }
+ }
+ }
+
+ restore_frontmost_app();
}
/// Find the WKWebView inside a regular NSWindow and make it first responder.
@@ -1256,7 +1281,7 @@ impl ShowRewindWindow {
// saved app. Only activate the previous external app
// if our app is no longer active.
#[cfg(target_os = "macos")]
- restore_frontmost_app_if_external();
+ restore_frontmost_app_if_external_with_app(Some(&app));
// order_out removes the invisible panel from
// the screen so it can't receive stray clicks.
#[cfg(target_os = "macos")]
@@ -1581,7 +1606,7 @@ impl ShowRewindWindow {
// saved app. Only activate the previous external app
// if our app is no longer active.
#[cfg(target_os = "macos")]
- restore_frontmost_app_if_external();
+ restore_frontmost_app_if_external_with_app(Some(&app));
// order_out removes the invisible panel so it
// can't receive stray clicks at alpha=0.
#[cfg(target_os = "macos")]