This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-09 15:23:00 +09:00
1 parent aa51ce482c
commit 46ff3abbb8
1 file changed
+18 -2
+18 -2
View File
@@ -312,6 +312,14 @@
} }
}; };
/** Check whether a terminal ID references an available system or direct terminal. */
const isTerminalAvailable = (tid: string): boolean => {
return (
($terminalServers ?? []).some((t) => t.id && t.id === tid) ||
($settings?.terminalServers ?? []).some((s) => s.url === tid)
);
};
const setDefaults = async () => { const setDefaults = async () => {
if (!$tools) { if (!$tools) {
tools.set(await getTools(localStorage.token)); tools.set(await getTools(localStorage.token));
@@ -390,9 +398,12 @@
} }
} }
// Set Default Terminal // Set Default Terminal — only if the referenced terminal actually exists
if (model?.info?.meta?.terminalId) { if (model?.info?.meta?.terminalId) {
selectedTerminalId.set(model.info.meta.terminalId); const tid = model.info.meta.terminalId;
if (isTerminalAvailable(tid)) {
selectedTerminalId.set(tid);
}
} }
} }
}; };
@@ -730,6 +741,11 @@
}); });
} }
// Clear stale selectedTerminalId if the referenced terminal no longer exists
if ($selectedTerminalId && !isTerminalAvailable($selectedTerminalId)) {
selectedTerminalId.set(null);
}
const pageSubscribe = page.subscribe(async (p) => { const pageSubscribe = page.subscribe(async (p) => {
if (p.url.pathname === '/') { if (p.url.pathname === '/') {
await tick(); await tick();