fix: workspace restore crash — defer to setTimeout, wrap all imports
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m17s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 3m17s
Workspace restore was running synchronously in onMounted which could crash if saved connection IDs were stale. The import of @tauri-apps/api/window for onCloseRequested could also fail in certain contexts. Fix: defer restore to setTimeout(500ms) so the app renders first, wrap each reconnect in individual try/catch, wrap the window close listener setup in try/catch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1b74527a62
commit
10e0a6b196
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user