From d59de004bb292ee43b9b4858963db73763da45bd Mon Sep 17 00:00:00 2001
From: Classic298 <27028174+Classic298@users.noreply.github.com>
Date: Mon, 23 Nov 2026 13:16:26 +0100
Subject: [PATCH] perf: show the Admin Settings > Models list sooner (#34873)
The Models tab in Admin Settings loaded the models config, the workspace models and the model list one after another, then loaded the provider model list, and after showing the list loaded the model list again. Every one of those waits costs a network round trip, so admins on a remote instance waited noticeably longer than needed. The first three now load together and the model list is only loaded once. The provider model list still loads after the model list, so the provider is still asked only once per visit.
| Time until the list shows, provider answering in 500 ms, median of 7 | Before | After |
| no added latency (localhost) | 619 ms | 620 ms |
| 40 ms latency | 730 ms | 654 ms |
| 100 ms latency | 911 ms | 710 ms |
Fixes #34872
---
.../components/admin/Settings/Models.svelte | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/lib/components/admin/Settings/Models.svelte b/src/lib/components/admin/Settings/Models.svelte
index ff5ae79163..9efb5ebc91 100644
--- a/src/lib/components/admin/Settings/Models.svelte
+++ b/src/lib/components/admin/Settings/Models.svelte
@@ -280,25 +280,28 @@
const init = async () => {
models = null;
- modelsConfig = await getModelsConfig(localStorage.token);
+ [modelsConfig, savedModels, allModels] = await Promise.all([
+ getModelsConfig(localStorage.token),
+ getAllModels(localStorage.token),
+ getModels(localStorage.token)
+ ]);
+ _models.set(allModels);
+
modelOrderList = modelsConfig?.MODEL_ORDER_LIST ?? [];
defaultModelIds = (modelsConfig?.DEFAULT_MODELS ?? '').split(',').filter((id) => id);
defaultPinnedModelIds = (modelsConfig?.DEFAULT_PINNED_MODELS ?? '')
.split(',')
.filter((id) => id);
- savedModels = (await getAllModels(localStorage.token)).filter(
- (model: ModelListItem) => !model.id.startsWith('agent:')
- );
+ savedModels = savedModels.filter((model: ModelListItem) => !model.id.startsWith('agent:'));
tags = [...new Set(savedModels.flatMap(modelTags))].sort();
if (selectedTag && !tags.includes(selectedTag)) {
selectedTag = '';
}
- allModels = (await getModels(localStorage.token)).filter(
- (model: ModelListItem) => !isMachine(model.owned_by)
- );
+ allModels = allModels.filter((model: ModelListItem) => !isMachine(model.owned_by));
+ // run after /api/models to reuse its cached provider response
const providerModels = await getModels(localStorage.token, true);
const allModelIds = new Set(allModels.map((model: ModelListItem) => model.id));
allModels = [
@@ -335,8 +338,6 @@
.sort((a, b) => a.localeCompare(b))
];
modelOrderDirty = false;
-
- _models.set(await getModels(localStorage.token));
};
const saveModelOrder = async (orderedModelIds: string[]) => {