This commit is contained in:
Timothy Jaeryang Baek
2026-07-27 03:18:12 -04:00
parent 71511ccd5a
commit f59d86a10c
2 changed files with 40 additions and 42 deletions
+3 -4
View File
@@ -847,7 +847,6 @@
// ── Lifecycle ────────────────────────────────────────────────────────
onMount(async () => {
const terminal = getTerminal();
if (!terminal) return;
let handledDisplayFile = false;
@@ -902,7 +901,7 @@
}
});
if (!handledDisplayFile) {
if (!handledDisplayFile && terminal) {
loading = true;
// Discover server features on initial mount
@@ -1383,7 +1382,7 @@
<Spinner className="size-4" />
{$i18n.t('Uploading...')}
</div>
{:else if loading}
{:else if loading || ($selectedTerminalId && $terminalServers === null)}
<div class="flex justify-center pt-8"><Spinner className="size-4" /></div>
{:else if error}
<div class="p-4 text-xs">{error}</div>
@@ -1399,7 +1398,7 @@
</div>
{/if}
{#if !loading && !error && !uploading}
{#if !loading && !error && !uploading && !($selectedTerminalId && $terminalServers === null)}
{#if creatingFolder}
<div class="flex items-center gap-2 px-3 py-1.5">
<Folder className="size-4 shrink-0 text-blue-400 dark:text-blue-300" />
+37 -38
View File
@@ -141,51 +141,49 @@
toolServers.set(toolServersData);
// Inject enabled terminal servers as always-on tool servers
const enabledTerminals = ($settings?.terminalServers ?? []).filter((s) => s.enabled);
if (enabledTerminals.length > 0) {
let terminalServersData = await getToolServersData(
enabledTerminals.map((t) => ({
url: t.url,
auth_type: t.auth_type ?? 'bearer',
key: t.key ?? '',
path: t.path ?? '/openapi.json',
config: { enable: true }
}))
);
terminalServersData = terminalServersData
.filter((data) => {
if (!data || data.error) {
toast.error(
$i18n.t(`Failed to connect to {{URL}} terminal server`, {
URL: data?.url
})
);
return false;
}
return true;
})
.map((data, i) => ({
...data,
key: enabledTerminals[i]?.key ?? ''
}));
terminalServers.set(terminalServersData);
} else {
terminalServers.set([]);
}
const enabledTerminals = (($settings as any)?.terminalServers ?? []).filter(
(s: any) => s.enabled || s.url === $selectedTerminalId
);
// Fetch terminal servers the user has access to (for FileNav + terminal_id)
const systemTerminals = await getTerminalServers(localStorage.token);
if (systemTerminals.length > 0) {
terminalServers.set([
...(enabledTerminals.length > 0
? (
await getToolServersData(
enabledTerminals.map((t: any) => ({
url: t.url,
auth_type: t.auth_type ?? 'bearer',
key: t.key ?? '',
path: t.path ?? '/openapi.json',
config: { enable: true }
}))
)
)
.filter((data) => {
if (!data || data.error) {
toast.error(
$i18n.t(`Failed to connect to {{URL}} terminal server`, {
URL: data?.url
})
);
return false;
}
return true;
})
.map((data, i) => ({
...data,
key: enabledTerminals[i]?.key ?? ''
}))
: []),
// Store with proxy URL and session key for FileNav file browsing
const terminalEntries = systemTerminals.map((t) => ({
...systemTerminals.map((t) => ({
id: t.id,
url: `${WEBUI_API_BASE_URL}/terminals/${t.id}`,
name: t.name,
key: localStorage.token
}));
terminalServers.update((existing) => [...(existing ?? []), ...terminalEntries]);
}
}))
]);
};
const setBanners = async () => {
@@ -264,6 +262,8 @@
}).catch((e) => console.error('Failed to load user settings:', e))
]);
selectedTerminalId.set(localStorage.selectedTerminalId ?? null);
const loadToolServers = setToolServers().catch((e) => {
console.error('Failed to load tool servers:', e);
terminalServers.set([]);
@@ -402,7 +402,6 @@
});
// Persist selectedTerminalId across page loads
selectedTerminalId.set(localStorage.selectedTerminalId ?? null);
selectedTerminalId.subscribe((value) => {
if (value === null) {
delete localStorage.selectedTerminalId;