fix: window close hanging + add confirmation prompt
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m53s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m53s
The onCloseRequested async handler was blocking window close when save_workspace invoke hung or threw. Fixed with: 1. Confirmation dialog: "Are you sure you want to close Wraith?" (only shown if sessions are active, cancel prevents close) 2. Workspace save wrapped in Promise.race with 2s timeout so a stuck invoke can never block the close indefinitely Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d39c0d38ed
commit
beac33614a
@ -450,15 +450,28 @@ onMounted(async () => {
|
||||
} catch {}
|
||||
}, 500);
|
||||
|
||||
// Save workspace on window close (non-fatal)
|
||||
// Confirm close + save workspace on window close
|
||||
try {
|
||||
const { getCurrentWindow } = await import("@tauri-apps/api/window");
|
||||
const appWindow = getCurrentWindow();
|
||||
appWindow.onCloseRequested(async () => {
|
||||
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 invoke("save_workspace", { tabs }).catch(() => {});
|
||||
await Promise.race([
|
||||
invoke("save_workspace", { tabs }),
|
||||
new Promise(resolve => setTimeout(resolve, 2000)),
|
||||
]);
|
||||
} catch {}
|
||||
});
|
||||
} catch {}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user