diff --git a/app/src-tauri/src/lib.rs b/app/src-tauri/src/lib.rs index 319049275..4981a162a 100644 --- a/app/src-tauri/src/lib.rs +++ b/app/src-tauri/src/lib.rs @@ -2797,15 +2797,23 @@ pub fn run() { // window from tray click: main window not found` // (OPENHUMAN-TAURI-2X — 21 events, Windows only). // - // macOS uses `window.hide()` because the vendored CEF runtime - // routes that through `set_application_visibility(false)` at the - // NSApplication level (`tauri-runtime-cef/src/lib.rs:588`), which - // hides the CEF browser surface together with the host window. - // Windows is handled in the separate arm below — see issue #1607. + // macOS: hide the whole application on close instead of + // destroying the window. `AppHandle::hide()` calls + // `[NSApp hide:]` via `set_application_visibility(false)`, + // the standard macOS mechanism that reliably hides all + // windows. The vendored CEF runtime's per-window + // `WebviewWindow::hide()` sends `WindowMessage::Hide` → + // `cef::Window::hide()`, which does NOT propagate to the + // visible NSWindow frame and leaves the window on screen + // (issue #2049). Dock-click fires `RunEvent::Reopen` which + // calls `show_main_window()` to restore. // - // 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. + // Windows is handled in the separate arm below — see #1607. + // + // Linux is left out: `setup_tray` early-returns on Linux + // because tray creation panics inside GTK during packaged + // runs, so hide-on-close would strand the user with no way + // back. #[cfg(target_os = "macos")] RunEvent::WindowEvent { label, @@ -2813,11 +2821,13 @@ pub fn run() { .. } if label == "main" => { log::info!( - "[window] close requested on main window — hiding instead of destroying" + "[window] close requested on main window — hiding app" ); api.prevent_close(); - if let Some(window) = app_handle.get_webview_window("main") { - let _ = window.hide(); + if let Err(err) = app_handle.hide() { + log::warn!( + "[window] app_handle.hide() failed on close request: {err}" + ); } } // Windows: full hide-to-tray.