This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-27 03:18:12 -04:00
1 parent 71511ccd5a
commit f59d86a10c
2 files changed
+40 -42

No files matched your search

+3 -4
View File
@@ -847,7 +847,6 @@
// ── Lifecycle ──────────────────────────────────────────────────────── // ── Lifecycle ────────────────────────────────────────────────────────
onMount(async () => { onMount(async () => {
const terminal = getTerminal(); const terminal = getTerminal();
if (!terminal) return;
let handledDisplayFile = false; let handledDisplayFile = false;
@@ -902,7 +901,7 @@
} }
}); });
if (!handledDisplayFile) { if (!handledDisplayFile && terminal) {
loading = true; loading = true;
// Discover server features on initial mount // Discover server features on initial mount
@@ -1383,7 +1382,7 @@
<Spinner className="size-4" /> <Spinner className="size-4" />
{$i18n.t('Uploading...')} {$i18n.t('Uploading...')}
</div> </div>
{:else if loading} {:else if loading || ($selectedTerminalId && $terminalServers === null)}
<div class="flex justify-center pt-8"><Spinner className="size-4" /></div> <div class="flex justify-center pt-8"><Spinner className="size-4" /></div>
{:else if error} {:else if error}
<div class="p-4 text-xs">{error}</div> <div class="p-4 text-xs">{error}</div>
@@ -1399,7 +1398,7 @@
</div> </div>
{/if} {/if}
{#if !loading && !error && !uploading} {#if !loading && !error && !uploading && !($selectedTerminalId && $terminalServers === null)}
{#if creatingFolder} {#if creatingFolder}
<div class="flex items-center gap-2 px-3 py-1.5"> <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" /> <Folder className="size-4 shrink-0 text-blue-400 dark:text-blue-300" />
+37 -38
View File
@@ -141,51 +141,49 @@
toolServers.set(toolServersData); toolServers.set(toolServersData);
// Inject enabled terminal servers as always-on tool servers // Inject enabled terminal servers as always-on tool servers
const enabledTerminals = ($settings?.terminalServers ?? []).filter((s) => s.enabled); const enabledTerminals = (($settings as any)?.terminalServers ?? []).filter(
if (enabledTerminals.length > 0) { (s: any) => s.enabled || s.url === $selectedTerminalId
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([]);
}
// Fetch terminal servers the user has access to (for FileNav + terminal_id) // Fetch terminal servers the user has access to (for FileNav + terminal_id)
const systemTerminals = await getTerminalServers(localStorage.token); 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 // Store with proxy URL and session key for FileNav file browsing
const terminalEntries = systemTerminals.map((t) => ({ ...systemTerminals.map((t) => ({
id: t.id, id: t.id,
url: `${WEBUI_API_BASE_URL}/terminals/${t.id}`, url: `${WEBUI_API_BASE_URL}/terminals/${t.id}`,
name: t.name, name: t.name,
key: localStorage.token key: localStorage.token
})); }))
terminalServers.update((existing) => [...(existing ?? []), ...terminalEntries]); ]);
}
}; };
const setBanners = async () => { const setBanners = async () => {
@@ -264,6 +262,8 @@
}).catch((e) => console.error('Failed to load user settings:', e)) }).catch((e) => console.error('Failed to load user settings:', e))
]); ]);
selectedTerminalId.set(localStorage.selectedTerminalId ?? null);
const loadToolServers = setToolServers().catch((e) => { const loadToolServers = setToolServers().catch((e) => {
console.error('Failed to load tool servers:', e); console.error('Failed to load tool servers:', e);
terminalServers.set([]); terminalServers.set([]);
@@ -402,7 +402,6 @@
}); });
// Persist selectedTerminalId across page loads // Persist selectedTerminalId across page loads
selectedTerminalId.set(localStorage.selectedTerminalId ?? null);
selectedTerminalId.subscribe((value) => { selectedTerminalId.subscribe((value) => {
if (value === null) { if (value === null) {
delete localStorage.selectedTerminalId; delete localStorage.selectedTerminalId;