diff --git a/src/lib/components/chat/Tabs.svelte b/src/lib/components/chat/Tabs.svelte index d72a20f0ba..eed1f28216 100644 --- a/src/lib/components/chat/Tabs.svelte +++ b/src/lib/components/chat/Tabs.svelte @@ -2077,7 +2077,10 @@ $: mainChatActive = fullWidth && visibleTabIds.has(mainChatTabId); $: if (isMounted && viewReady && !chatLoading) { const active = tabs.tabs.find((tab) => tab.id === tabs.activeId); - const main = active?.id === mainChatTabId || (active?.kind === 'chat' && isSavedChatId(chatId)); + // A chat tab beside the main chat keeps its address; one covering it has its own. + const main = + active?.id === mainChatTabId || + (active?.kind === 'chat' && isSavedChatId(chatId) && mainChatActive); const href = active?.kind === 'page' ? active.href diff --git a/src/lib/components/chat/Tabs/Page.svelte b/src/lib/components/chat/Tabs/Page.svelte index fdf771c7e0..5184ad592d 100644 --- a/src/lib/components/chat/Tabs/Page.svelte +++ b/src/lib/components/chat/Tabs/Page.svelte @@ -2,7 +2,6 @@ import { getContext, setContext, type ComponentType, type SvelteComponent } from 'svelte'; import { writable } from 'svelte/store'; import { goto } from '$app/navigation'; - import { updated } from '$app/state'; import { config, user, WEBUI_NAME } from '$lib/stores'; import { type PageContext } from '$lib/utils/page'; import { pageTabKey } from './tabs'; @@ -112,12 +111,7 @@ ['knowledge', 'prompts'].includes(parts[2]) ? { showCreateOnMount: true, createModalCloseHref: `/workspace/${parts[2]}` } : {}; - $: component = - key && - pages[route as keyof typeof pages]?.().catch(async (error) => { - if (await updated.check()) location.reload(); - throw error; - }); + $: component = key && pages[route as keyof typeof pages]?.(); $: allowed = (parts[1] !== 'notes' || ($config?.features?.enable_notes && diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index caa5463e8b..6d5ce56930 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -104,6 +104,14 @@ } }); + // a lazily loaded chunk from the old build is gone after an update (https://vite.dev/guide/build#load-error-handling) + window.addEventListener('vite:preloadError', async () => { + if (!mfaManagement && (await updated.check())) { + await unregisterServiceWorkers(); + location.reload(); + } + }); + setContext('i18n', i18n); /** @type {import('$lib/components/auth/MfaManagement.svelte').MfaManagementFlow | null} */ let mfaManagement = null;