From 5d472a6e53fe79d700816fb1a6900fc84e0b3ee3 Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Thu, 26 Mar 2026 15:46:23 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20window=20close=20hanging=20=E2=80=94=20r?= =?UTF-8?q?eplace=20onCloseRequested=20with=20auto-save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit onCloseRequested async handler was permanently blocking window close on Windows, even with the 2s timeout. The confirm() dialog and async invoke chain prevented the close event from completing. Fix: removed onCloseRequested entirely. Workspace now auto-saves every 30 seconds via setInterval. Close button works immediately with no handler blocking it. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/layouts/MainLayout.vue | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index a79f90f..cf35092 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -510,30 +510,16 @@ onMounted(async () => { } catch {} }, 500); - // Confirm close + save workspace on window close - try { - const { getCurrentWindow } = await import("@tauri-apps/api/window"); - const appWindow = getCurrentWindow(); - appWindow.onCloseRequested(async (event) => { - // Ask for confirmation if there are active sessions - if (sessionStore.sessions.length > 0) { - if (!confirm("Are you sure you want to close Wraith?")) { - event.preventDefault(); - return; - } - } - // Save workspace before closing (with timeout to prevent hang) - try { - const tabs = sessionStore.sessions - .filter(s => s.protocol === "ssh" || s.protocol === "rdp") - .map((s, i) => ({ connectionId: s.connectionId, protocol: s.protocol, position: i })); - await Promise.race([ - invoke("save_workspace", { tabs }), - new Promise(resolve => setTimeout(resolve, 2000)), - ]); - } catch {} - }); - } catch {} + // Auto-save workspace every 30 seconds instead of on close + // (onCloseRequested was hanging the window close on Windows) + setInterval(() => { + const tabs = sessionStore.sessions + .filter(s => s.protocol === "ssh" || s.protocol === "rdp") + .map((s, i) => ({ connectionId: s.connectionId, protocol: s.protocol, position: i })); + if (tabs.length > 0) { + invoke("save_workspace", { tabs }).catch(() => {}); + } + }, 30000); // Check for updates on startup via Tauri updater plugin (non-blocking) invoke<{ currentVersion: string; latestVersion: string; updateAvailable: boolean; downloadUrl: string }>("check_for_updates")