perf(ui): non-blocking model and tool server loading for unreachable connections (#26289)

- Move setModels() and setToolServers() out of the loaded gate in
  +layout.svelte so the page renders immediately instead of blocking
  behind slow/unreachable connection timeouts
- Track failed Ollama backend URLs from /api/tags and skip them in the
  subsequent /api/ps fan-out, eliminating a redundant second timeout
- Silence the autocomplete toast that fires during the transient empty
  model state
This commit is contained in:
G30
2026-06-29 12:34:00 -05:00
committed by GitHub
parent 91aea7fe8c
commit c584a4270c
3 changed files with 29 additions and 16 deletions
+1 -1
View File
@@ -1545,7 +1545,7 @@
($settings?.promptAutocomplete ?? false)}
generateAutoCompletion={async (text) => {
if (selectedModelIds.length === 0 || !selectedModelIds.at(0)) {
toast.error($i18n.t('Please select a model first.'));
return null;
}
const res = await generateAutoCompletion(
+8 -7
View File
@@ -87,7 +87,7 @@
}
};
const setUserSettings = async (cb: () => Promise<void>) => {
const setUserSettings = async (cb?: () => Promise<void>) => {
let userSettings = await getUserSettings(localStorage.token).catch((error) => {
console.error(error);
return null;
@@ -209,14 +209,15 @@
checkLocalDBChats(),
setBanners().catch((e) => console.error('Failed to load banners:', e)),
setTools().catch((e) => console.error('Failed to load tools:', e)),
setUserSettings(async () => {
await Promise.all([
setModels().catch((e) => console.error('Failed to load models:', e)),
setToolServers().catch((e) => console.error('Failed to load tool servers:', e))
]);
}).catch((e) => console.error('Failed to load user settings:', e))
setUserSettings().catch((e) => console.error('Failed to load user settings:', e))
]);
// Load models and tool servers in the background — don't block page render.
// These contact external services (Ollama, OpenAI, tool servers, terminal
// servers) that may be slow or unreachable.
setModels().catch((e) => console.error('Failed to load models:', e));
setToolServers().catch((e) => console.error('Failed to load tool servers:', e));
// Helper function to check if the pressed keys match the shortcut definition
const isShortcutMatch = (event: KeyboardEvent, shortcut): boolean => {
const keys = shortcut?.keys || [];