From e0ef4230ff2c2669505628be133bf2bce0298304 Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 20 Jul 2026 17:51:09 +0800 Subject: [PATCH] fix(tray): make quit action terminate app --- docs/progress.md | 6 ++++++ src-tauri/src/lib.rs | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/progress.md b/docs/progress.md index 3515789..5f44fc2 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -214,3 +214,9 @@ Still not claimed complete: automatic startup activation, real Tauri multi-windo - Added explicit pet-view root sizing and transparent `html`/`body`/`#root` backgrounds so Tauri transparent windows do not fall back to an opaque blank surface. - Validation: TypeScript, ESLint, Vitest (6), Vite build, Rust format, Clippy with warnings denied, Rust workspace tests (66), and NSIS bundle build pass. - The already-running executable must be fully closed and relaunched; the generated installer is at `target/release/bundle/nsis/AstrBot Desktop_0.1.0-alpha.1_x64-setup.exe`. + +## 2026-07-20: tray quit reliability fix + +- Fixed the tray Quit action so it destroys the main, quick-chat, status-bubble, and pet windows before requesting process exit. +- This avoids the global close-to-tray handler intercepting shutdown and leaving the process resident. +- Validation: Rust format, Clippy with warnings denied, Rust workspace tests (66), TypeScript, ESLint, Vitest (6), and NSIS bundle build pass. diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 8676516..ed383b0 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -156,6 +156,15 @@ fn save_quick_window_state(window: &tauri::Window, app: &AppHandle) { let _ = database.save_window_state(QUICK_WINDOW_ID, &state); } +fn exit_application(app: &AppHandle) { + for label in ["main", QUICK_WINDOW_ID, "status-bubble", PET_WINDOW_ID] { + if let Some(window) = app.get_webview_window(label) { + let _ = window.destroy(); + } + } + app.exit(0); +} + #[tauri::command] fn open_main_window(app: AppHandle) -> Result<(), String> { let window = app @@ -261,7 +270,7 @@ pub fn run() { let _ = window.set_focus(); } } - "quit" => app.exit(0), + "quit" => exit_application(app), _ => {} }) .build(app)?;