fix(tauri): hide instead of destroy main window on Windows close (OPENHUMAN-TAURI-2X) (#1548)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
This commit is contained in:
oxoxDev
2026-05-12 19:51:31 -07:00
committed by GitHub
co-authored by Claude Opus 4.7 Steven Enamakel
parent 54a9396f88
commit 3bfe53aaa9
+11 -2
View File
@@ -31,7 +31,7 @@ mod webview_apis;
mod whatsapp_scanner;
mod window_state;
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "windows"))]
use tauri::WindowEvent;
#[cfg(not(target_os = "linux"))]
use tauri::{
@@ -2078,7 +2078,16 @@ pub fn run() {
);
}
}
#[cfg(target_os = "macos")]
// Intercept the main window's close request on macOS AND Windows
// so the user can re-open the app from the tray icon. Letting the
// OS destroy the webview makes `get_webview_window("main")` return
// None on the next tray-click and surfaces as
// `[tray] failed to show main window from tray click: main window
// not found` (OPENHUMAN-TAURI-2X — 21 events, Windows only).
// Linux is left out: `setup_tray` early-returns on Linux because
// tray creation panics inside GTK during packaged runs, so the
// hide-on-close behavior would strand the user with no way back.
#[cfg(any(target_os = "macos", target_os = "windows"))]
RunEvent::WindowEvent {
label,
event: WindowEvent::CloseRequested { api, .. },