fix: window close hanging — replace onCloseRequested with auto-save
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m50s

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) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-26 15:46:23 -04:00
parent be76a61119
commit 5d472a6e53

View File

@ -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 {
// 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 }));
await Promise.race([
invoke("save_workspace", { tabs }),
new Promise(resolve => setTimeout(resolve, 2000)),
]);
} catch {}
});
} catch {}
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")