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:
@@ -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(
|
||||
|
||||
@@ -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 || [];
|
||||
|
||||
Reference in New Issue
Block a user