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 e2e main window invoke
Louis Beaumont1bc6edde9313
diff --git a/apps/screenpipe-app-tauri/e2e/specs/privacy-api-auth-enforcement.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/privacy-api-auth-enforcement.spec.tsindex 91a0d0335..0e33e6e65 100644--- a/apps/screenpipe-app-tauri/e2e/specs/privacy-api-auth-enforcement.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/privacy-api-auth-enforcement.spec.ts@@ -26,6 +26,8 @@ import {waitForLocalApi,} from "../helpers/api-utils.js";+type LocalApiConfig = Awaited<ReturnType<typeof getLocalApiConfig>>;+type HasGetAttribute = {getAttribute: (name: string) => Promise<string | null>;};@@ -88,19 +90,39 @@ async function clickApplyRestart(): Promise<void> {await first.click();}-async function waitForAuthEnabled(expected: boolean, timeoutMs = t(60_000)): Promise<number> {+async function waitForAuthEnabled(+ expected: boolean,+ timeoutMs = t(60_000),+): Promise<LocalApiConfig> {const deadline = Date.now() + timeoutMs;let lastAuth = "unknown";+ let lastConnections = "unknown";while (Date.now() < deadline) {const cfg = await getLocalApiConfig().catch(() => null);if (cfg) {lastAuth = String(cfg.auth_enabled);const res = await fetchJson(`http://127.0.0.1:${cfg.port}/health`);- if (res.ok && cfg.auth_enabled === expected) return cfg.port;+ if (res.ok && cfg.auth_enabled === expected) {+ const url = `http://127.0.0.1:${cfg.port}/connections`;+ const unauthed = await fetchJson(url);+ if (expected) {+ const authed = cfg.key ? await fetchJson(url, authHeaders(cfg.key)) : null;+ const rejectsUnauthed =+ !unauthed.ok && unauthed.status >= 400 && unauthed.status < 500;+ const acceptsAuthed = !authed || authed.ok;+ if (rejectsUnauthed && acceptsAuthed) return cfg;+ lastConnections = `unauthed=${unauthed.status} authed=${authed?.status ?? "no-key"}`;+ } else {+ if (unauthed.ok) return cfg;+ lastConnections = `unauthed=${unauthed.status}`;+ }+ }}await browser.pause(500);}- throw new Error(`Timed out waiting for auth_enabled=${expected} (last=${lastAuth})`);+ throw new Error(+ `Timed out waiting for auth_enabled=${expected} (last=${lastAuth}, connections=${lastConnections})`,+ );}async function expectConnectionsAuthBehavior(port: number, key: string | null, authEnabled: boolean) {@@ -176,9 +198,9 @@ describe("Privacy: API auth enforcement", function () {}await clickApplyRestart();- const port = await waitForAuthEnabled(flipped, t(90_000));+ const updated = await waitForAuthEnabled(flipped, t(90_000));+ const port = updated.port;- const updated = await getLocalApiConfig();expect(updated.auth_enabled).toBe(flipped);expect(updated.port).toBe(port);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex 6de393231..55c84863f 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -730,12 +730,12 @@ pub fn set_tray_health_icon(app_handle: tauri::AppHandle) {#[tauri::command]#[specta::specta]-pub fn show_main_window(app_handle: &tauri::AppHandle, _overlay: bool) {+pub fn show_main_window(app_handle: tauri::AppHandle) {info!("show_main_window called");set_main_close_in_progress(false);let window_to_show = ShowRewindWindow::Main;- match window_to_show.show(app_handle) {+ match window_to_show.show(&app_handle) {Ok(window) => {info!("show_main_window succeeded, window label: {}",@@ -778,14 +778,14 @@ pub fn show_main_window(app_handle: &tauri::AppHandle, _overlay: bool) {#[tauri::command]#[specta::specta]-pub fn hide_main_window(app_handle: &tauri::AppHandle) {+pub fn hide_main_window(app_handle: tauri::AppHandle) {// NOTE: Window shortcuts (Escape) are unregistered by the focus-loss// handler in window/show.rs. Do NOT also unregister them here — doing// so races with the focus handler and causes duplicate unregister calls.let window_to_close = ShowRewindWindow::Main;- if let Err(e) = window_to_close.close(app_handle) {+ if let Err(e) = window_to_close.close(&app_handle) {error!("failed to close window: {}", e);}}@@ -924,20 +924,20 @@ pub fn update_show_screenpipe_shortcut(// the panel's alpha is 0 (auto-hidden on focus loss), causing// the shortcut to "hide" an already-invisible panel.if MAIN_PANEL_SHOWN.load(std::sync::atomic::Ordering::SeqCst) {- hide_main_window(app_handle);+ hide_main_window(app_handle.clone());} else {- show_main_window(app_handle, true);+ show_main_window(app_handle.clone());}}#[cfg(not(target_os = "macos"))]{if let Some(window) = app_handle.get_webview_window("home") {match window.is_visible() {- Ok(true) => hide_main_window(app_handle),- _ => show_main_window(app_handle, true),+ Ok(true) => hide_main_window(app_handle.clone()),+ _ => show_main_window(app_handle.clone()),}} else {- show_main_window(app_handle, true);+ show_main_window(app_handle.clone());}}},@@ -949,7 +949,7 @@ pub fn update_show_screenpipe_shortcut(let _ = app_handle.global_shortcut().on_shortcut(default_shortcut,move |app_handle, _event, _shortcut| {- show_main_window(app_handle, true);+ show_main_window(app_handle.clone());},);}@@ -1227,7 +1227,7 @@ pub async fn show_window(// Hide Main timeline when opening Search (search is standalone, timeline shows on result pick)if matches!(window_id, RewindWindowId::Search) {- hide_main_window(&app_handle);+ hide_main_window(app_handle.clone());}window.show(&app_handle).map_err(|e| e.to_string())?;diff --git a/apps/screenpipe-app-tauri/src-tauri/src/dock_menu.rs b/apps/screenpipe-app-tauri/src-tauri/src/dock_menu.rsindex 9795325a0..b44f371aa 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/dock_menu.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/dock_menu.rs@@ -34,7 +34,7 @@ pub fn setup_dock_menu(app_handle: AppHandle) {if let Some(app) = DOCK_APP_HANDLE.get() {let app_for_closure = app.clone();let _ = app.run_on_main_thread(move || {- show_main_window(&app_for_closure, false);+ show_main_window(app_for_closure.clone());});}}));diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 53f95cfca..7790cb926 100755--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -744,6 +744,8 @@ async fn main() {commands::update_show_screenpipe_shortcut,commands::show_window,commands::show_window_activated,+ commands::show_main_window,+ commands::hide_main_window,commands::open_login_window,commands::open_google_calendar_auth_window,commands::ensure_webview_focus,@@ -955,7 +957,7 @@ async fn main() {let args_clone = args.clone();let _ = app.run_on_main_thread(move || {// Focus the existing window- show_main_window(&app_for_closure, false);+ show_main_window(app_for_closure.clone());// Forward deep-link URL from argsif let Some(url) = args_clone.iter().find(|a| a.starts_with("screenpipe://")) {@@ -1034,6 +1036,8 @@ async fn main() {commands::open_pipe_window,commands::show_window,commands::show_window_activated,+ commands::show_main_window,+ commands::hide_main_window,commands::open_login_window,commands::ensure_webview_focus,commands::close_window,diff --git a/apps/screenpipe-app-tauri/src-tauri/src/server.rs b/apps/screenpipe-app-tauri/src-tauri/src/server.rsindex a542d3e70..b2e5ea43f 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/server.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/server.rs@@ -107,7 +107,7 @@ async fn handle_focus(if payload.target.as_deref() == Some("browser_pairing") {let _ = (ShowRewindWindow::Home { page: None }).show(&state.app_handle);} else {- show_main_window(&state.app_handle, false);+ show_main_window(state.app_handle.clone());}if let Some(url) = payload.deep_link_url {diff --git a/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs b/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rsindex 837f49559..dac1986fb 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/shortcuts.rs@@ -171,16 +171,16 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),match window.is_visible() {Ok(true) if !is_minimized => {info!("window '{}' is visible (not minimized), hiding it", label);- hide_main_window(app)+ hide_main_window(app.clone())}_ => {info!("window '{}' not visible or minimized, showing it", label);- show_main_window(app, false)+ show_main_window(app.clone())}}} else {info!("main window not found for mode '{}', creating it", mode);- show_main_window(app, false)+ show_main_window(app.clone())}}});@@ -277,7 +277,7 @@ async fn apply_shortcuts(app: &AppHandle, config: &ShortcutConfig) -> Result<(),let _ = app.run_on_main_thread(move || {let app = &app_for_closure;info!("search shortcut triggered");- hide_main_window(app);+ hide_main_window(app.clone());let _ = ShowRewindWindow::Search { query: None }.show(app);});})diff --git a/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs b/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rsindex 1e2393943..954a32a95 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/space_monitor.rs@@ -85,7 +85,7 @@ pub fn setup_space_listener(app: AppHandle) {let _ = app.run_on_main_thread(move || {crate::window::with_autorelease_pool(|| {crate::window::clear_frontmost_app();- hide_main_window(&app_inner);+ hide_main_window(app_inner.clone());});});});diff --git a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs b/apps/screenpipe-app-tauri/src-tauri/src/tray.rsindex b177b596a..caa7fc3e0 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/tray.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/tray.rs@@ -753,7 +753,7 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {"show" => {let app = app_handle.clone();let _ = app_handle.run_on_main_thread(move || {- show_main_window(&app, false);+ show_main_window(app.clone());let _ = app.emit("tray-show-timeline", ());});}@@ -761,7 +761,7 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {// Show floating Search bar only (hide timeline, it reopens when user picks a result)let app = app_handle.clone();let _ = app_handle.run_on_main_thread(move || {- hide_main_window(&app);+ hide_main_window(app.clone());let _ = ShowRewindWindow::Search { query: None }.show(&app);let _ = app.emit("tray-show-search", ());});@@ -997,7 +997,7 @@ fn handle_menu_event(app_handle: &AppHandle, event: tauri::menu::MenuEvent) {let _ = win.close();}// Show the main window- show_main_window(&app, false);+ show_main_window(app.clone());});}"onboarding" => {