From 83b17e2ac8b2bb09594f54d76242454007b94bc7 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 27 Feb 2026 17:04:09 -0600 Subject: [PATCH] refac --- .../admin/Settings/Integrations.svelte | 16 +++++++++++++++- src/routes/(app)/+layout.svelte | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/lib/components/admin/Settings/Integrations.svelte b/src/lib/components/admin/Settings/Integrations.svelte index 9e7529f4c..4d7204eb3 100644 --- a/src/lib/components/admin/Settings/Integrations.svelte +++ b/src/lib/components/admin/Settings/Integrations.svelte @@ -7,7 +7,9 @@ const dispatch = createEventDispatcher(); const i18n = getContext('i18n'); - import { models, settings, user } from '$lib/stores'; + import { models, settings, user, terminalServers } from '$lib/stores'; + import { getTerminalServers } from '$lib/apis/terminal'; + import { WEBUI_API_BASE_URL } from '$lib/constants'; import Switch from '$lib/components/common/Switch.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; @@ -69,6 +71,18 @@ if (res) { toast.success($i18n.t('Terminal servers saved')); + + // Refresh the terminalServers store so changes are reflected immediately + // Preserve user direct terminals, refresh system terminals from backend + const existingDirectTerminals = ($terminalServers ?? []).filter((t) => !t.id); + const systemTerminals = await getTerminalServers(localStorage.token); + const systemEntries = systemTerminals.map((t) => ({ + id: t.id, + url: `${WEBUI_API_BASE_URL}/terminals/${t.id}`, + name: t.name, + key: localStorage.token + })); + terminalServers.set([...existingDirectTerminals, ...systemEntries]); } }; diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 7bb221e16..87e2a25b9 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -168,10 +168,10 @@ } // Fetch terminal servers the user has access to (for FileNav + terminal_id) - const backendTerminals = await getTerminalServers(localStorage.token); - if (backendTerminals.length > 0) { + const systemTerminals = await getTerminalServers(localStorage.token); + if (systemTerminals.length > 0) { // Store with proxy URL and session key for FileNav file browsing - const terminalEntries = backendTerminals.map((t) => ({ + const terminalEntries = systemTerminals.map((t) => ({ id: t.id, url: `${WEBUI_API_BASE_URL}/terminals/${t.id}`, name: t.name,