mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-20 15:19:51 -05:00
refac
This commit is contained in:
@@ -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 () => {
|
||||
if (!$tools) {
|
||||
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) {
|
||||
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) => {
|
||||
if (p.url.pathname === '/') {
|
||||
await tick();
|
||||
|
||||
Reference in New Issue
Block a user