Revert "Fix/mac app closing onclose (#1489)"

This reverts commit 143e382726.
This commit is contained in:
Jan Carbonell
2026-04-19 07:48:10 -07:00
parent d740a91b98
commit 08603fbbb6

View File

@@ -114,6 +114,12 @@ fn show_main_window(app_handle: &AppHandle) {
}
}
fn hide_main_window(app_handle: &AppHandle) {
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.hide();
}
}
fn stop_managed_services(app_handle: &tauri::AppHandle) {
if let Ok(mut engine) = app_handle.state::<EngineManager>().inner.lock() {
EngineManager::stop_locked(&mut engine);
@@ -221,16 +227,14 @@ pub fn run() {
// orchestrator/opencode/openwork-server processes and stale ports.
app.run(|app_handle, event| match event {
RunEvent::ExitRequested { .. } | RunEvent::Exit => stop_managed_services(&app_handle),
// On macOS the default behavior is to keep the process alive after the
// last window closes. We want parity with Windows/Linux: closing the
// main window quits the app.
#[cfg(target_os = "macos")]
RunEvent::WindowEvent {
label,
event: WindowEvent::CloseRequested { .. },
event: WindowEvent::CloseRequested { api, .. },
..
} if label == "main" => {
app_handle.exit(0);
api.prevent_close();
hide_main_window(&app_handle);
}
#[cfg(target_os = "macos")]
RunEvent::Opened { urls } => {
@@ -241,11 +245,14 @@ pub fn run() {
show_main_window(&app_handle);
emit_native_deep_links(&app_handle, urls);
}
// Always raise/refocus the main window on dock-icon clicks, even if
// it's already visible but behind other apps or on another Space.
#[cfg(target_os = "macos")]
RunEvent::Reopen { .. } => {
show_main_window(&app_handle);
RunEvent::Reopen {
has_visible_windows,
..
} => {
if !has_visible_windows {
show_main_window(&app_handle);
}
}
_ => {}
});