From 94a3a276524f8ef40557764f5af92008c4e3f404 Mon Sep 17 00:00:00 2001 From: Aniket Shukla Date: Fri, 31 Jul 2026 18:56:23 +0530 Subject: [PATCH] fix(macos): restore the hidden window on Dock-icon click (#248) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close-to-tray hides the main window instead of quitting (on_window_event's CloseRequested handler), but the RunEvent handler only dealt with Exit. macOS fires RunEvent::Reopen when the Dock icon is clicked, and Tauri does nothing with it by default — so the app activates (menu bar switches) but no window appears, and the user has no way to get it back short of relaunching. Handle RunEvent::Reopen by reshowing the main window via the existing show_main helper (unminimize + show + set_focus) — the same path the tray "Open" item already uses. Reopen is macOS-only, so the arm is #[cfg(target_os = "macos")]. Verified against the pinned tauri 2.11.5 source: RunEvent::Reopen is a macOS-gated non_exhaustive struct variant emitted for applicationShouldHandleReopen (the Dock-icon click). --- surfaces/gui/src-tauri/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/surfaces/gui/src-tauri/src/lib.rs b/surfaces/gui/src-tauri/src/lib.rs index 460021b4..ce3d6044 100644 --- a/surfaces/gui/src-tauri/src/lib.rs +++ b/surfaces/gui/src-tauri/src/lib.rs @@ -755,6 +755,16 @@ pub fn run() { .build(tauri::generate_context!()) .expect("error while building the OpenWorker desktop app") .run(|app, event| { + // macOS: clicking the Dock icon fires Reopen. Close-to-tray only HIDES the main + // window (see on_window_event above), and Tauri does nothing on Reopen by default, + // so the app activates (menu bar switches) but no window appears (#248). Reshow it — + // same path as the tray "Open" item. + #[cfg(target_os = "macos")] + { + if let RunEvent::Reopen { .. } = &event { + show_main(app); + } + } // Also on Exit: belt-and-suspenders in case a quit path reaches teardown without // a preceding ExitRequested (observed with macOS Cmd+Q under the tray setup). if matches!(event, RunEvent::ExitRequested { .. } | RunEvent::Exit) {