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
test(e2e): make e2e builds non-intrusive on the developer's desktop
Louis Beaumont47b59ce096d3
diff --git a/apps/screenpipe-app-tauri/e2e/specs/window-activation.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/window-activation.spec.tsindex c9e0c4ece..2d7a47ed0 100644--- a/apps/screenpipe-app-tauri/e2e/specs/window-activation.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/window-activation.spec.ts@@ -55,6 +55,16 @@ async function waitForAnyMainHandle(timeoutMs = t(12_000)): Promise<MainLabel> {await waitForAppReady();// Ensure we have a stable Tauri-origin webview for invoke() calls.await openHomeWindow();+ // E2E builds are non-activating so a run never yanks a developer out of+ // their fullscreen Space. This is the one spec whose subject *is*+ // activation, so it opts in for its own duration.+ await invokeOrThrow("plugin:e2e|e2e_set_activation_allowed", { allowed: true });+ });++ after(async () => {+ await invokeOrThrow("plugin:e2e|e2e_set_activation_allowed", {+ allowed: false,+ }).catch(() => {});});afterEach(async () => {diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rsindex 56f2baf40..8da566ea2 100644--- a/apps/screenpipe-app-tauri/src-tauri/build.rs+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs@@ -391,6 +391,7 @@ const E2E_COMMANDS: &[&str] = &["seed_flags","capture_pi_start_error","set_onboarding_completed_ago",+ "e2e_set_activation_allowed",];fn validate_e2e_command_inventory() {diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex 1610cf0d6..3721670b2 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -11,6 +11,8 @@ use crate::{updates::is_enterprise_build,window::{RewindWindowId, ShowRewindWindow},};+#[cfg(target_os = "macos")]+use crate::window::GatedPanelPlacement;use sha2::{Digest, Sha256};use tauri::{Emitter, Manager};#[cfg(not(target_os = "macos"))]@@ -3123,10 +3125,10 @@ pub(crate) async fn show_shortcut_reminder_impl(use tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior;// Re-set level, style mask, and behaviors on every show —// order_out may have cleared the Space association.- panel.set_level(1001);+ panel.set_level_gated(1001);panel.set_style_mask(128); // NonActivatingPanelpanel.set_hides_on_deactivate(false);- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces |NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary@@ -3195,7 +3197,7 @@ pub(crate) async fn show_shortcut_reminder_impl(use objc::{msg_send, sel, sel_impl};// Level 1001 = above CGShieldingWindowLevel, shows over fullscreen- panel.set_level(1001);+ panel.set_level_gated(1001);// NonActivatingPanel (128) so the reminder doesn't activate// the app (which would cause Space switching on fullscreen).// style_mask(0) was wrong — it cleared NonActivatingPanel.@@ -3211,7 +3213,7 @@ pub(crate) async fn show_shortcut_reminder_impl(// CanJoinAllSpaces: visible on ALL Spaces simultaneously// (not MoveToActiveSpace which only follows the active Space)- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces |NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary@@ -3585,10 +3587,10 @@ pub async fn show_notification_panel(if let Ok(panel) = app_clone.get_webview_panel("notification-panel") {use tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior;use objc::{msg_send, sel, sel_impl};- panel.set_level(1001);+ panel.set_level_gated(1001);panel.set_style_mask(128); // NSNonactivatingPanelMaskpanel.set_hides_on_deactivate(false);- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces| NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle| NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary,@@ -3670,7 +3672,7 @@ pub async fn show_notification_panel(if let Ok(panel) = window_clone.to_panel() {use objc::{msg_send, sel, sel_impl};- panel.set_level(1001);+ panel.set_level_gated(1001);panel.set_style_mask(128);panel.set_hides_on_deactivate(false);@@ -3682,7 +3684,7 @@ pub async fn show_notification_panel(// which blocks webview hover events. This re-enables mouse tracking.let _: () = unsafe { msg_send![&*panel, setAcceptsMouseMovedEvents: true] };- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorCanJoinAllSpaces| NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle| NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary,diff --git a/apps/screenpipe-app-tauri/src-tauri/src/e2e/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/e2e/commands.rsindex 4c8ff062e..6ab4d6ac5 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/e2e/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/e2e/commands.rs@@ -607,6 +607,20 @@ async fn capture_pi_start_error(}}+/// E2E helper: allow (or re-suppress) real macOS window activation.+///+/// The suite runs on a developer's desktop, so e2e builds are non-activating by+/// default — otherwise every window show swaps them out of their fullscreen+/// Space. The specs that assert activation itself turn it on for their own+/// duration and hand it back.+#[command]+fn e2e_set_activation_allowed(allowed: bool) {+ #[cfg(target_os = "macos")]+ crate::window::set_window_activation_allowed(allowed);+ #[cfg(not(target_os = "macos"))]+ let _ = allowed;+}+pub(super) fn plugin() -> TauriPlugin<Wry> {Builder::<Wry>::new("e2e")// build.rs verifies this inventory matches the feature-only plugin ACL.@@ -642,6 +656,7 @@ pub(super) fn plugin() -> TauriPlugin<Wry> {seed_flags,capture_pi_start_error,set_onboarding_completed_ago,+ e2e_set_activation_allowed,]).build()}diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 8cab59275..8e6512b89 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1015,6 +1015,16 @@ async fn main() {}let app_handle = app.handle();+ // Go non-activating before the first window exists. Tauri defaults to+ // `Regular`, and a launching Regular app is activated by macOS — which+ // swaps a developer out of their fullscreen Space every time an agent+ // starts the suite. `reset_to_regular_and_refresh_tray` re-applies this+ // later in setup; it has to be set here to beat window creation.+ #[cfg(all(target_os = "macos", feature = "e2e"))]+ if !crate::window::window_activation_allowed() {+ let _ = app_handle.set_activation_policy(tauri::ActivationPolicy::Accessory);+ }+// Create macOS app menu with Settings#[cfg(target_os = "macos")]{diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rsindex 51f410318..f61545d42 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/mod.rs@@ -22,6 +22,123 @@ pub use panel::main_label_for_mode;pub use show::{RewindWindowId, ShowRewindWindow};pub use util::with_autorelease_pool;+/// One app process serves the whole suite, so activation is a runtime switch+/// rather than a launch-time read.+#[cfg(feature = "e2e")]+static E2E_ACTIVATION_ALLOWED: std::sync::atomic::AtomicBool =+ std::sync::atomic::AtomicBool::new(false);++/// Whether the app may pull macOS focus to itself when it shows a window.+///+/// `--features e2e` builds run on a developer's own desktop while an agent+/// drives the suite. Activating an app whose window lives on another Space+/// makes the WindowServer swap the developer out of their fullscreen app, and+/// the suite shows windows dozens of times per run. So e2e builds stay+/// non-activating: no dock icon, no launch activation, no focus steal. Specs+/// that assert real activation opt back in for their own duration via the+/// `e2e_set_activation_allowed` command, or a whole run can opt in with+/// `SCREENPIPE_E2E_ALLOW_ACTIVATION=1`.+///+/// Always true in shipping builds — this never changes what users see.+#[cfg(feature = "e2e")]+pub fn window_activation_allowed() -> bool {+ use std::sync::atomic::Ordering;+ use std::sync::Once;+ static INIT: Once = Once::new();+ INIT.call_once(|| {+ let from_env = matches!(+ std::env::var("SCREENPIPE_E2E_ALLOW_ACTIVATION").as_deref(),+ Ok("1") | Ok("true")+ );+ E2E_ACTIVATION_ALLOWED.store(from_env, Ordering::SeqCst);+ });+ E2E_ACTIVATION_ALLOWED.load(Ordering::SeqCst)+}++/// Let a spec re-enable real activation for the assertions that need it.+#[cfg(feature = "e2e")]+pub fn set_window_activation_allowed(allowed: bool) {+ // Run the env seed first so it cannot clobber this later.+ let _ = window_activation_allowed();+ E2E_ACTIVATION_ALLOWED.store(allowed, std::sync::atomic::Ordering::SeqCst);+}++#[cfg(not(feature = "e2e"))]+pub const fn window_activation_allowed() -> bool {+ true+}++/// `set_focus()`, unless an e2e run has activation suppressed.+///+/// Windows/Linux only: the macOS show paths raise panels and call+/// `activateIgnoringOtherApps` instead, and those are gated at their own+/// callsites. Commands whose entire contract is activation+/// (`show_window_activated`) still call `set_focus` directly, so the regression+/// guard for them exercises the real thing.+#[cfg(not(target_os = "macos"))]+pub fn focus_window(window: &tauri::WebviewWindow) {+ if !window_activation_allowed() {+ return;+ }+ let _ = window.set_focus();+}++/// Panel window level and Space behavior, gated for non-intrusive e2e runs.+///+/// Overlay panels ship at level 1001 with `FullScreenAuxiliary` and+/// `CanJoinAllSpaces`/`MoveToActiveSpace` — that combination is exactly what+/// lets screenpipe draw on top of whatever you are doing, including another+/// app's fullscreen Space. Correct for the product, wrong for a test run on the+/// developer's own desktop, so a non-intrusive e2e run clamps the level to the+/// normal layer and drops the cross-Space bits. The panel then physically+/// cannot appear over a fullscreen app.+#[cfg(target_os = "macos")]+pub(crate) trait GatedPanelPlacement {+ fn set_level_gated(&self, level: i32);+ fn set_collection_behaviour_gated(+ &self,+ behaviour: tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior,+ );+}++#[cfg(target_os = "macos")]+impl GatedPanelPlacement for tauri_nspanel::raw_nspanel::RawNSPanel {+ fn set_level_gated(&self, level: i32) {+ self.set_level(if window_activation_allowed() {+ level+ } else {+ 0+ });+ }++ fn set_collection_behaviour_gated(+ &self,+ behaviour: tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior,+ ) {+ use tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior as Behavior;+ let intrusive = Behavior::NSWindowCollectionBehaviorCanJoinAllSpaces+ | Behavior::NSWindowCollectionBehaviorMoveToActiveSpace+ | Behavior::NSWindowCollectionBehaviorFullScreenAuxiliary;+ self.set_collection_behaviour(if window_activation_allowed() {+ behaviour+ } else {+ behaviour & !intrusive+ });+ }+}++/// macOS panel key-window step, skipped when an e2e run is non-activating.+///+/// `makeKeyWindow` is what actually pulls screenpipe to the foreground (and, for+/// a regular window, drags the developer's Space with it), so it is gated at the+/// same switch as `activateIgnoringOtherApps`.+#[cfg(target_os = "macos")]+pub(crate) fn make_panel_key_if_allowed(panel: &tauri_nspanel::raw_nspanel::RawNSPanel) {+ if window_activation_allowed() {+ panel.make_key_window();+ }+}+/// Finalize a newly created webview window with cross-cutting resilience hooks./// Keep this as the single post-build entrypoint for window creation callsites.pub fn finalize_webview_window(window: tauri::WebviewWindow) -> tauri::WebviewWindow {diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/panel.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/panel.rsindex 0cecaac69..0149095da 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window/panel.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/panel.rs@@ -41,13 +41,13 @@ pub(crate) unsafe fn show_panel_visible(let _: () = msg_send![&*panel, setAlphaValue: 1.0f64];- if activate_app {+ if activate_app && crate::window::window_activation_allowed() {let ns_app: id = msg_send![objc::class!(NSApplication), sharedApplication];let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];}panel.order_front_regardless();- panel.make_key_window();+ crate::window::make_panel_key_if_allowed(&panel);make_webview_first_responder(panel);MAIN_PANEL_SHOWN.store(true, std::sync::atomic::Ordering::SeqCst);@@ -92,6 +92,12 @@ pub fn main_label_for_mode(mode: &str) -> &'static str {/// for causing crashes; setting the policy once on a real event is safe.#[cfg(target_os = "macos")]pub fn reset_to_regular_and_refresh_tray(app: &AppHandle) {+ if !super::window_activation_allowed() {+ info!("Setting activation policy to Accessory (e2e — non-activating test run)");+ let _ = app.set_activation_policy(tauri::ActivationPolicy::Accessory);+ return;+ }+if crate::enterprise_policy::is_app_ui_hidden() {info!("Setting activation policy to Accessory (enterprise hidden UI mode)");let _ = app.set_activation_policy(tauri::ActivationPolicy::Accessory);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rsindex 04c9debfa..b665a73bc 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/window/show.rs@@ -31,6 +31,8 @@ use super::util::screen_aware_size;use tauri::Emitter;#[cfg(target_os = "macos")]+#[cfg(target_os = "macos")]+use super::GatedPanelPlacement;use tauri_nspanel::ManagerExt;#[cfg(target_os = "macos")]use tauri_nspanel::WebviewWindowExt;@@ -47,7 +49,7 @@ use tauri_nspanel::WebviewWindowExt;pub fn apply_chat_panel_on_top(panel: &tauri_nspanel::raw_nspanel::RawNSPanel, on_top: bool) {use objc::{msg_send, sel, sel_impl};if on_top {- panel.set_level(1001);+ panel.set_level_gated(1001);// NonActivatingPanel (128) so clicking doesn't activate appunsafe {let current: i32 = msg_send![panel, styleMask];@@ -55,7 +57,7 @@ pub fn apply_chat_panel_on_top(panel: &tauri_nspanel::raw_nspanel::RawNSPanel, o}} else {// Normal window level — allow it to go behind other windows- panel.set_level(0);+ panel.set_level_gated(0);// Remove NonActivatingPanel bit (128) so it behaves normallyunsafe {let current: i32 = msg_send![panel, styleMask];@@ -309,8 +311,8 @@ impl ShowRewindWindow {if let Ok(panel) = app_clone.get_webview_panel(&lbl) {use objc::{msg_send, sel, sel_impl};use tauri_nspanel::cocoa::appkit::NSWindowCollectionBehavior;- panel.set_level(1001);- panel.set_collection_behaviour(+ panel.set_level_gated(1001);+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);@@ -323,7 +325,7 @@ impl ShowRewindWindow {}// Remove MoveToActiveSpace so panel stays pinned to this Space- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);}@@ -343,7 +345,7 @@ impl ShowRewindWindow {{tracing::warn!("Failed to center window-mode overlay: {}", e);}- window.set_focus().ok();+ crate::window::focus_window(&window);let _ = app.emit("window-focused", true);}} else {@@ -389,7 +391,7 @@ impl ShowRewindWindow {let _: () = msg_send![&*panel, setFrame:frame display:true];}}- panel.set_level(1001);+ panel.set_level_gated(1001);let _: () = unsafe {objc::msg_send![&*panel, setMovableByWindowBackground: false]};@@ -399,7 +401,7 @@ impl ShowRewindWindow {// MoveToActiveSpace so the panel appears on the current Space,// then we remove it after showing so the panel doesn't// follow the user to other Spaces (which caused a blink).- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary@@ -412,7 +414,7 @@ impl ShowRewindWindow {// Remove MoveToActiveSpace now that the panel is shown.// This keeps it pinned to THIS Space so it won't follow// three-finger swipes (no blink on the destination Space).- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);@@ -448,7 +450,7 @@ impl ShowRewindWindow {#[cfg(target_os = "linux")]{window.show().ok();- window.set_focus().ok();+ crate::window::focus_window(&window);let _ = app.emit("window-focused", true);}}@@ -592,7 +594,7 @@ impl ShowRewindWindow {#[cfg(not(target_os = "macos"))]{window.show().ok();- window.set_focus().ok();+ crate::window::focus_window(&window);}return Ok(window);}@@ -631,9 +633,11 @@ impl ShowRewindWindow {if let Ok(ns_win) = window_clone.ns_window() {unsafe {// Activate the app so it comes to the foreground- let ns_app: cocoa_id =- msg_send![objc::class!(NSApplication), sharedApplication];- let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];+ if crate::window::window_activation_allowed() {+ let ns_app: cocoa_id =+ msg_send![objc::class!(NSApplication), sharedApplication];+ let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];+ }// Move the window to the active space (current workspace)// NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1 = 2@@ -664,7 +668,7 @@ impl ShowRewindWindow {if window.is_minimized().unwrap_or(false) {window.unminimize().ok();}- window.set_focus().ok();+ crate::window::focus_window(&window);}return Ok(window);@@ -693,18 +697,18 @@ impl ShowRewindWindow {unsafe { msg_send![&*panel, setMovableByWindowBackground: true] };let sharing: u64 = if capturable { 1 } else { 0 };let _: () = unsafe { msg_send![&*panel, setSharingType: sharing] };- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);panel.order_front_regardless();- panel.make_key_window();+ crate::window::make_panel_key_if_allowed(&panel);// Set WKWebView as first responder AFTER make_key_windowunsafe {make_webview_first_responder(&panel);}// Remove MoveToActiveSpace now that the panel is shown.- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);}@@ -721,7 +725,7 @@ impl ShowRewindWindow {.chat_always_on_top;window.set_always_on_top(chat_on_top).ok();window.show().ok();- window.set_focus().ok();+ crate::window::focus_window(&window);return Ok(window);}}@@ -826,7 +830,7 @@ impl ShowRewindWindow {e);}- win.set_focus().ok();+ crate::window::focus_window(&win);let _ = app_clone.emit("window-focused", true);}});@@ -848,7 +852,7 @@ impl ShowRewindWindow {if let Ok(panel) = window_clone.to_panel() {// Same level as overlay — above fullscreen- panel.set_level(1001);+ panel.set_level_gated(1001);panel.released_when_closed(true);// Do NOT set NSNonactivatingPanelMask (128) for window mode.// That mask prevents the app from activating, which breaks@@ -863,7 +867,7 @@ impl ShowRewindWindow {let sharing: u64 = if capturable { 1 } else { 0 };let _: () =unsafe { msg_send![&*panel, setSharingType: sharing] };- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);@@ -874,7 +878,7 @@ impl ShowRewindWindow {}// Remove MoveToActiveSpace so panel stays pinned to this Space- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);}@@ -978,13 +982,15 @@ impl ShowRewindWindow {// route to the WKWebView (same reason as// show_existing_main — NonActivatingPanel// won't activate the app on its own).- let ns_app: id = msg_send![objc::class!(NSApplication), sharedApplication];- let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];+ if crate::window::window_activation_allowed() {+ let ns_app: id = msg_send![objc::class!(NSApplication), sharedApplication];+ let _: () = msg_send![ns_app, activateIgnoringOtherApps: true];+ }}// Ensure panel is key window before setting first// responder, otherwise magnifyWithEvent: won't// reach the WKWebView (pinch-to-zoom breaks).- panel.make_key_window();+ crate::window::make_panel_key_if_allowed(&panel);unsafe { make_webview_first_responder(&panel); }}MAIN_PANEL_SHOWN.store(true, std::sync::atomic::Ordering::SeqCst);@@ -1199,7 +1205,7 @@ impl ShowRewindWindow {.on_page_load(move |win, payload| {if matches!(payload.event(), tauri::webview::PageLoadEvent::Finished) {win.show().ok();- win.set_focus().ok();+ crate::window::focus_window(&win);let _ = app_clone.emit("window-focused", true);}});@@ -1224,7 +1230,7 @@ impl ShowRewindWindow {// Use a very high window level to appear above fullscreen apps// CGShieldingWindowLevel (1000) + 1 ensures it appears above everything including fullscreen- panel.set_level(1001);+ panel.set_level_gated(1001);panel.released_when_closed(true);@@ -1248,7 +1254,7 @@ impl ShowRewindWindow {// MoveToActiveSpace for first creation so the panel// appears on the current fullscreen Space.// show_existing_main manages this for subsequent shows.- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary@@ -1261,7 +1267,7 @@ impl ShowRewindWindow {// Remove MoveToActiveSpace so the panel stays pinned to// this Space (same as show_existing_main).- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary);@@ -1388,7 +1394,7 @@ impl ShowRewindWindow {// Ensure panel is key window before setting first// responder, otherwise magnifyWithEvent: won't// reach the WKWebView (pinch-to-zoom breaks).- panel.make_key_window();+ crate::window::make_panel_key_if_allowed(&panel);unsafe { make_webview_first_responder(&panel); }}MAIN_PANEL_SHOWN.store(true, std::sync::atomic::Ordering::SeqCst);@@ -1594,7 +1600,7 @@ impl ShowRewindWindow {if chat_on_top {// Level 1001 to appear above fullscreen apps- panel.set_level(1001);+ panel.set_level_gated(1001);// NonActivatingPanel (128) so clicking the chat doesn't// activate the app (which would switch Spaces away from// fullscreen apps). Preserve existing style bits.@@ -1603,7 +1609,7 @@ impl ShowRewindWindow {panel.set_style_mask(current | 128);}} else {- panel.set_level(0);+ panel.set_level_gated(0);}// Don't hide when app deactivates@@ -1625,7 +1631,7 @@ impl ShowRewindWindow {// MoveToActiveSpace so show_existing can pull// it to any Space (including fullscreen).- panel.set_collection_behaviour(+ panel.set_collection_behaviour_gated(NSWindowCollectionBehavior::NSWindowCollectionBehaviorMoveToActiveSpace |NSWindowCollectionBehavior::NSWindowCollectionBehaviorIgnoresCycle |NSWindowCollectionBehavior::NSWindowCollectionBehaviorFullScreenAuxiliary@@ -1805,7 +1811,7 @@ impl ShowRewindWindow {{if focus {let _ = window.show();- window.set_focus().ok();+ crate::window::focus_window(&window);}// Pre-warm (focus=false): leave hidden (visible(false)). The// existing-window branch in show() shows()+focuses on first open.