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(notifications): click Open now actually brings the window forward on macOS
Louis Beaumont3e86cebb00c2
diff --git a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx b/apps/screenpipe-app-tauri/app/notification-panel/page.tsxindex 782d9eb94..e4e1be5dd 100644--- a/apps/screenpipe-app-tauri/app/notification-panel/page.tsx+++ b/apps/screenpipe-app-tauri/app/notification-panel/page.tsx@@ -161,16 +161,27 @@ export default function NotificationPanelPage() {case "deeplink": {if (actionObj.url) {if (actionObj.url.startsWith("screenpipe://")) {- // Emit to main window's DeeplinkHandler which knows how to- // route screenpipe:// URLs (timeline, frame, settings, etc.)+ // Show the Main window FIRST — its DeeplinkHandler only+ // routes events once mounted, and on macOS the window+ // won't actually come to the foreground unless we activate+ // the app (see show_window_activated for the rationale).+ // Then give React ~150ms to mount the listener before+ // emitting. Without this ordering, the emit fires into a+ // handler that hasn't subscribed yet and the click silently+ // does nothing.+ await invoke("show_window_activated", { window: "Main" });+ await new Promise((r) => setTimeout(r, 150));await emit("deep-link-received", actionObj.url);} else {// External URL — open in system browsertry {const { open } = await import("@tauri-apps/plugin-shell");await open(actionObj.url);- } catch {- // shell plugin not available in this window+ } catch (e) {+ console.error(+ "notification open: shell plugin unavailable",+ e+ );}}}@@ -183,11 +194,16 @@ export default function NotificationPanelPage() {return;}- // Legacy string-based action handlers+ // Legacy string-based action handlers. The notification panel is a+ // NonActivating NSPanel on macOS, so regular `show_window` completes+ // successfully without actually bringing the target window to the+ // foreground — use `show_window_activated` so explicit user clicks+ // from the notification panel always surface the window above other+ // apps, regardless of overlay_mode.if (actionStr === "open_timeline") {- await invoke("show_window", { window: "Main" });+ await invoke("show_window_activated", { window: "Main" });} else if (actionStr === "open_chat") {- await invoke("show_window", { window: "Chat" });+ await invoke("show_window_activated", { window: "Chat" });} else if (actionStr === "open_pipe_suggestions") {await showChatWithPrefill({context: PIPE_SUGGESTION_PROMPT,@@ -244,8 +260,24 @@ export default function NotificationPanelPage() {}return; // don't auto-hide on error so user sees the message}- } catch {- // ignore+ } catch (e) {+ // Log loudly instead of swallowing silently — this is the place a+ // bug like "click Open does nothing" used to vanish. We still hide+ // the panel so the user isn't left with a stuck UI, but the failure+ // now shows up in DevTools + ~/.screenpipe/logs (via tracing from+ // any Tauri command that errored) + PostHog as a distinct event.+ console.error(+ "notification action failed",+ { action: actionStr, type: actionObj?.type },+ e+ );+ posthog.capture("notification_action_error", {+ type: payload?.type,+ id: payload?.id,+ action: actionStr,+ actionType: actionObj?.type,+ error: String(e),+ });}await hide(false);diff --git a/apps/screenpipe-app-tauri/components/notification-handler.tsx b/apps/screenpipe-app-tauri/components/notification-handler.tsxindex 89961a9ab..d3696cac6 100644--- a/apps/screenpipe-app-tauri/components/notification-handler.tsx+++ b/apps/screenpipe-app-tauri/components/notification-handler.tsx@@ -182,6 +182,12 @@ const NotificationHandler: React.FC = () => {if (action.type === "deeplink" && action.url) {if (action.url.startsWith("screenpipe://")) {+ // Activate + show the Main window first so the DeeplinkHandler+ // is mounted and ready before the event fires. See the matching+ // block in app/notification-panel/page.tsx for the full rationale.+ const { invoke } = await import("@tauri-apps/api/core");+ await invoke("show_window_activated", { window: "Main" });+ await new Promise((r) => setTimeout(r, 150));const { emit } = await import("@tauri-apps/api/event");await emit("deep-link-received", action.url);} else {@@ -191,12 +197,15 @@ const NotificationHandler: React.FC = () => {return;}- // Legacy string actions+ // Legacy string actions. Use `show_window_activated` rather than+ // `show_window` — notifications can be clicked from outside the app's+ // active space, and the NonActivating panel style prevents NSApp+ // activation otherwise.const { invoke } = await import("@tauri-apps/api/core");if (action.action === "open_timeline") {- await invoke("show_window", { window: "Main" });+ await invoke("show_window_activated", { window: "Main" });} else if (action.action === "open_chat") {- await invoke("show_window", { window: "Chat" });+ await invoke("show_window_activated", { window: "Chat" });} else if (action.action === "open_pipe_suggestions") {await showChatWithPrefill({context: PIPE_SUGGESTION_PROMPT,diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 4f6ce6744..87483992d 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9726,7 +9726,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.25"+version = "2.4.34"dependencies = ["anyhow","arboard",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex c1500ca31..e5436ad13 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.4.34"+version = "2.4.35"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex d59b80851..438d9a6c0 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -780,6 +780,43 @@ pub async fn show_window(Ok(())}+/// Like `show_window` but forces macOS app activation first, so the target+/// window actually comes to the foreground when the caller is a+/// `NSNonactivatingPanelMask` panel (notifications, tray, etc.).+///+/// Without this, clicking "Open" in the notification panel on macOS often+/// appears to do nothing: the non-activating panel style prevents the app+/// from becoming active, and overlay/fullscreen main modes rely on an+/// activate-aware `show_panel_visible(activate_app=true)` path that only+/// fires for `overlay_mode == "window"`. The window technically shows but+/// stays behind whatever app the user was in.+///+/// Callers that represent explicit user intent (clicking Open on a+/// notification) should use this variant. Passive show-surface callers+/// should keep using `show_window` to avoid stealing focus unnecessarily.+#[tauri::command]+#[specta::specta]+pub async fn show_window_activated(+ app_handle: tauri::AppHandle,+ window: ShowRewindWindow,+) -> Result<(), String> {+ #[cfg(target_os = "macos")]+ {+ app_handle+ .run_on_main_thread(|| {+ use objc::{msg_send, sel, sel_impl};+ use tauri_nspanel::cocoa::base::id;+ unsafe {+ let ns_app: id =+ msg_send![objc::class!(NSApplication), sharedApplication];+ let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];+ }+ })+ .map_err(|e| format!("failed to activate app: {}", e))?;+ }+ show_window(app_handle, window).await+}+/// Re-assert the WKWebView as first responder for the current key panel./// Called from JS on pointer enter / window focus to ensure trackpad pinch/// gestures (magnifyWithEvent:) reach the WKWebView for zoom handling.diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex c6200c003..3f799016f 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -609,6 +609,7 @@ async fn main() {commands::open_pipe_window,commands::update_show_screenpipe_shortcut,commands::show_window,+ commands::show_window_activated,commands::open_login_window,commands::open_google_calendar_auth_window,commands::ensure_webview_focus,@@ -880,6 +881,7 @@ async fn main() {commands::delete_cache_files,commands::open_pipe_window,commands::show_window,+ commands::show_window_activated,commands::open_login_window,commands::ensure_webview_focus,commands::close_window,