diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 73e4759..e535890 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -438,24 +438,29 @@ onMounted(async () => { document.addEventListener("keydown", handleKeydown); await connectionStore.loadAll(); - // Restore workspace — reconnect saved tabs - try { - const workspace = await invoke<{ tabs: { connectionId: number; protocol: string; position: number }[] } | null>("load_workspace"); - if (workspace?.tabs?.length) { - for (const tab of workspace.tabs.sort((a, b) => a.position - b.position)) { - sessionStore.connect(tab.connectionId).catch(() => {}); + // Restore workspace — reconnect saved tabs (non-blocking, non-fatal) + setTimeout(async () => { + try { + const workspace = await invoke<{ tabs: { connectionId: number; protocol: string; position: number }[] } | null>("load_workspace"); + if (workspace?.tabs?.length) { + for (const tab of workspace.tabs.sort((a, b) => a.position - b.position)) { + try { await sessionStore.connect(tab.connectionId); } catch {} + } } - } - } catch {} + } catch {} + }, 500); - // Save workspace on window close - const appWindow = await import("@tauri-apps/api/window").then(m => m.getCurrentWindow()); - appWindow.onCloseRequested(async () => { - 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(() => {}); - }); + // Save workspace on window close (non-fatal) + try { + const { getCurrentWindow } = await import("@tauri-apps/api/window"); + const appWindow = getCurrentWindow(); + appWindow.onCloseRequested(async () => { + 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(() => {}); + }); + } catch {} // Check for updates on startup (non-blocking) invoke<{ currentVersion: string; latestVersion: string; updateAvailable: boolean; downloadUrl: string }>("check_for_updates")