diff --git a/src/lib/components/admin/Settings/Apps.svelte b/src/lib/components/admin/Settings/Apps.svelte index 44f5d3a4b8..680d14d460 100644 --- a/src/lib/components/admin/Settings/Apps.svelte +++ b/src/lib/components/admin/Settings/Apps.svelte @@ -7,13 +7,15 @@ import AppModal from './Apps/AppModal.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; import Switch from '$lib/components/common/Switch.svelte'; - import Spinner from '$lib/components/common/Spinner.svelte'; import ExperimentalBadge from '$lib/components/common/ExperimentalBadge.svelte'; import Plus from '$lib/components/icons/Plus.svelte'; import Cog6 from '$lib/components/icons/Cog6.svelte'; import Grid from '$lib/components/icons/Grid.svelte'; const i18n = getContext('i18n'); - let apps: App[] | null = null; + // The page shows its own spinner until the first load finishes. + export let loaded = false; + + let apps: App[] = []; let selected: App | null = null; let show = false; let busy = ''; @@ -23,9 +25,9 @@ } catch (error) { if (!silent) { toast.error(String(error)); - apps = []; } } + loaded = true; } function configure(app: App | null) { selected = app; @@ -81,70 +83,65 @@ > - {#if apps === null}
- -
- {:else}
- {#each apps as app (app.id)} -
-
+ {#each apps as app (app.id)} +
+
+ {#if app.data.manifest.profile_image_url} + + {:else}{/if} + - {#if app.data.manifest.profile_image_url} - - {:else}{/if} - -
- {#if app.is_active} - {app.connection_status === 'connected' - ? $i18n.t('Connected') - : app.connection_status === 'connecting' - ? $i18n.t('Connecting') - : $i18n.t('Disconnected')} - {/if} -
- - - {#key `${app.is_active}-${show}-${busy}`} toggle(app)} - />{/key} - -
- {:else}

- {$i18n.t('No apps connected.')} -

{/each} -
{/if} + {#if app.is_active} + {app.connection_status === 'connected' + ? $i18n.t('Connected') + : app.connection_status === 'connecting' + ? $i18n.t('Connecting') + : $i18n.t('Disconnected')} + {/if} +
+ + + {#key `${app.is_active}-${show}-${busy}`} toggle(app)} + />{/key} + +
+
+ {:else}

+ {$i18n.t('No apps connected.')} +

{/each} +
diff --git a/src/lib/components/admin/Settings/ExternalKnowledge.svelte b/src/lib/components/admin/Settings/ExternalKnowledge.svelte index a0fc2a0e7a..7885bc2339 100644 --- a/src/lib/components/admin/Settings/ExternalKnowledge.svelte +++ b/src/lib/components/admin/Settings/ExternalKnowledge.svelte @@ -62,7 +62,9 @@ const TEXT_SEARCH_PROVIDERS = ['openai']; const DEFAULT_PROVIDER = 'openai'; - let loading = false; + // The page shows its own spinner until the first load finishes. + export let loaded = false; + let testing = false; let verifying = false; // Stores the connection can search, offered as suggestions for the Vector Store ID. @@ -231,7 +233,6 @@ }; const refresh = async () => { - loading = true; const [connectionRes, knowledgeRes] = await Promise.all([ getExternalKnowledgeConnections(localStorage.token).catch((error) => { toast.error(`${error}`); @@ -242,12 +243,17 @@ return null; }) ]); - connections = connectionRes?.items ?? []; - // Stores a connection lists are managed through that connection's row. - items = (knowledgeRes?.items ?? []).filter( - (item: ExternalKnowledgeItem) => !hasStoreIds(connectionForItem(item)) - ); - loading = false; + // A failed refresh keeps the rows already shown. + if (connectionRes) { + connections = connectionRes.items ?? []; + } + if (knowledgeRes) { + // Stores a connection lists are managed through that connection's row. + items = (knowledgeRes.items ?? []).filter( + (item: ExternalKnowledgeItem) => !hasStoreIds(connectionForItem(item)) + ); + } + loaded = true; }; const endpointPlaceholder = () => { @@ -1263,11 +1269,7 @@ {/each} - {#if loading} -
- -
- {:else if items.length === 0 && !connections.some(hasStoreIds)} + {#if items.length === 0 && !connections.some(hasStoreIds)}
{$i18n.t('No external knowledge sources configured.')}
diff --git a/src/lib/components/admin/Settings/Integrations.svelte b/src/lib/components/admin/Settings/Integrations.svelte index a6b7fa8452..c573ad37dc 100644 --- a/src/lib/components/admin/Settings/Integrations.svelte +++ b/src/lib/components/admin/Settings/Integrations.svelte @@ -52,10 +52,18 @@ let showConnectionModal = false; // Machine admin connections - let machineConnections: MachineConnection[] = []; + let machineConnections: MachineConnection[] | null = null; let showAddMachineModal = false; let editMachineIdx: number | null = null; + // Every section loads in parallel behind one spinner. + let connectionsLoaded = false; + let knowledgeLoaded = false; + let appsLoaded = false; + + $: loaded = + connectionsLoaded && knowledgeLoaded && (appsLoaded || !$config?.features?.enable_apps); + const addConnectionHandler = async (server: ToolServerConnection) => { servers = [...(servers ?? []), server]; await updateHandler(); @@ -105,7 +113,7 @@ // Reload the list, then apply the rest of the form (name, access, options) to it. const res = await getMachineConnections(localStorage.token).catch(() => null); machineConnections = (res?.MACHINE_CONNECTIONS ?? machineConnections) as MachineConnection[]; - machineConnections = machineConnections.map((c) => + machineConnections = (machineConnections ?? []).map((c) => c.id === server.id ? { ...c, @@ -121,35 +129,42 @@ await saveMachines(); return; } - machineConnections = [...machineConnections, { ...server, id: server.id ?? uuidv4() }]; + machineConnections = [...(machineConnections ?? []), { ...server, id: server.id ?? uuidv4() }]; saveMachines(); }; const updateMachineConnection = (idx: number, updated: MachineConnection) => { - machineConnections = machineConnections.map((c, i) => + machineConnections = (machineConnections ?? []).map((c, i) => i === idx ? { ...c, ...updated, id: updated.id ?? c.id } : c ); saveMachines(); }; const removeMachineConnection = (idx: number) => { - machineConnections = machineConnections.filter((_, i) => i !== idx); + machineConnections = (machineConnections ?? []).filter((_, i) => i !== idx); saveMachines(); }; onMount(async () => { - const res = await getToolServerConnections(localStorage.token); - servers = res.TOOL_SERVER_CONNECTIONS as ToolServerConnection[]; - - try { - const machineRes = await getMachineConnections(localStorage.token); - if (machineRes?.MACHINE_CONNECTIONS) { - machineConnections = machineRes.MACHINE_CONNECTIONS as MachineConnection[]; - } - } catch { - // Not configured yet - } $socket?.on('events', machinesChanged); + + const [serverRes, machineRes] = await Promise.all([ + getToolServerConnections(localStorage.token).catch(() => null), + getMachineConnections(localStorage.token).catch(() => null) + ]); + + // A list that failed to load stays null, so saving can't overwrite what is stored. + if (serverRes) { + servers = (serverRes.TOOL_SERVER_CONNECTIONS ?? []) as ToolServerConnection[]; + } else { + toast.error($i18n.t('Failed to load connections')); + } + if (machineRes) { + machineConnections = (machineRes.MACHINE_CONNECTIONS ?? []) as MachineConnection[]; + } else { + toast.error($i18n.t('Failed to load machines')); + } + connectionsLoaded = true; }); // An SSH install or upgrade finished (here or in another tab): show the machine's new state. @@ -169,8 +184,8 @@ c.local)} + connection={editMachineIdx !== null ? (machineConnections?.[editMachineIdx] ?? null) : null} + allowLocal={!(machineConnections ?? []).some((c) => c.local)} onSubmit={(c: MachineConnection) => { if (editMachineIdx !== null) { updateMachineConnection(editMachineIdx, c); @@ -198,7 +213,16 @@
- {#if servers !== null} + {#if !loaded} +
+
+ +
+
+ {/if} + + +
@@ -289,7 +316,8 @@
- {#each machineConnections as connection, idx} + {#each machineConnections ?? [] as connection, idx}
@@ -359,7 +387,7 @@ state={connection?.enabled !== false} ariaLabel={`${$i18n.t('Enabled')}: ${connection.name || (connection.local ? $i18n.t('Local') : connection.url) || $i18n.t('New Machine')}`} on:change={() => { - machineConnections = machineConnections.map((c, i) => + machineConnections = (machineConnections ?? []).map((c, i) => i === idx ? { ...c, enabled: !(c?.enabled !== false) } : c ); saveMachines(); @@ -371,9 +399,11 @@ {/each}
- {#if machineConnections.length === 0} + {#if (machineConnections ?? []).length === 0}
- {$i18n.t('No machines configured.')} + {machineConnections === null + ? $i18n.t('Failed to load machines') + : $i18n.t('No machines configured.')}
{/if}
@@ -381,25 +411,20 @@ - + {#if $config?.features?.enable_apps} - + {/if} - {:else} -
-
- -
-
- {/if} +