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")