From 17c6b27bfe3a8c3c4756562c7ddc3bd34dc961d7 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 20 May 2026 11:18:25 -0700 Subject: [PATCH] fix(window): hide chat window on close instead of destroying it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intercept WindowEvent::CloseRequested on the 'chat' window and call window.hide() + api.prevent_close(). Without this, clicking the X destroys the window — get_webview_window("chat") then returns None and subsequent tray clicks do nothing. --- src-tauri/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index a18910f..ecd33b2 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -76,6 +76,20 @@ pub fn run() { .map(|pf| pf.log_paths.clone()) .unwrap_or_default(); + // Intercept the chat window's close button so it hides rather than + // destroys the window. Without this, closing once makes the window + // unreachable — get_webview_window("chat") returns None and the tray + // click does nothing. + if let Some(chat_win) = app.get_webview_window("chat") { + let win = chat_win.clone(); + chat_win.on_window_event(move |event| { + if let tauri::WindowEvent::CloseRequested { api, .. } = event { + let _ = win.hide(); + api.prevent_close(); + } + }); + } + let rx = watcher::spawn(log_paths); let pf = Arc::new(pattern_file); let app_handle = app.handle().clone();