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(macos): move open chat to active space (#6894)

Ezra Ellettef04a0c8071ee
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs b/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs
index 36268ddbc..64eb3e28a 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs
@@ -350,7 +350,12 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),
{
use tauri_nspanel::ManagerExt;
if let Ok(panel) = app.get_webview_panel("chat") {
- if panel.is_visible() {
+ // A panel on another Space is also "visible". Only toggle
+ // it closed when it is on the Space the user is viewing;
+ // otherwise the shared show path moves it to this Space.
+ if panel.is_visible()
+ && crate::window::panel_is_on_active_space(&*panel)
+ {
panel.order_out(None);
return;
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs
index 684247f0e..40a92901d 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs
@@ -164,6 +164,17 @@ pub(crate) fn make_panel_key_if_allowed(panel: &tauri_nspanel::raw_nspanel::RawN
}
}
+/// Whether a visible panel belongs to the user's currently active macOS Space.
+///
+/// `isVisible` remains true for windows pinned to a different Space, so callers
+/// must use this when deciding whether an invocation should hide the panel or
+/// move it to the Space the user is currently viewing.
+#[cfg(target_os = "macos")]
+pub(crate) fn panel_is_on_active_space(panel: &tauri_nspanel::raw_nspanel::RawNSPanel) -> bool {
+ use objc::{msg_send, sel, sel_impl};
+ unsafe { msg_send![panel, isOnActiveSpace] }
+}
+
/// `[NSApp activateIgnoringOtherApps:YES]`, unless an e2e run is non-activating.
///
/// This is the single call that yanks a developer out of their fullscreen Space,
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs
index bab2a0fc3..68bdec9f8 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs
@@ -742,6 +742,14 @@ impl ShowRewindWindow {
if let Ok(panel) = app_clone.get_webview_panel(RewindWindowId::Chat.label())
{
+ // A panel pinned to another Space still reports itself as
+ // visible. Order it out first so MoveToActiveSpace is applied
+ // when it is ordered front again on the current Space.
+ if panel.is_visible()
+ && !crate::window::panel_is_on_active_space(&*panel)
+ {
+ panel.order_out(None);
+ }
apply_chat_panel_on_top(&*panel, chat_on_top);
let _: () =
unsafe { msg_send![&*panel, setMovableByWindowBackground: true] };