diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a1a7adfa8..6c4d0e523 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -329,6 +329,14 @@ const chatEventHandler = async (event, cb) => { const chat = $page.url.pathname.includes(`/c/${event.chat_id}`); + // Skip events from temporary chats that are not the current chat. + // This prevents notifications from being sent to other tabs/devices + // for privacy, since temporary chats are not meant to be persisted or visible elsewhere. + const isTemporaryChat = event.chat_id?.startsWith('local:'); + if (isTemporaryChat && event.chat_id !== $chatId) { + return; + } + let isFocused = document.visibilityState !== 'visible'; if (window.electronAPI) { const res = await window.electronAPI.send({ @@ -346,6 +354,7 @@ if ((event.chat_id !== $chatId && !$temporaryChatEnabled) || isFocused) { if (type === 'chat:completion') { const { done, content, title } = data; + const displayTitle = title || $i18n.t('New Chat'); if (done) { if ($settings?.notificationSoundAlways ?? false) { @@ -360,7 +369,7 @@ if ($isLastActiveTab) { if ($settings?.notificationEnabled ?? false) { - new Notification(`${title} • Open WebUI`, { + new Notification(`${displayTitle} • Open WebUI`, { body: content, icon: `${WEBUI_BASE_URL}/static/favicon.png` }); @@ -373,7 +382,7 @@ goto(`/c/${event.chat_id}`); }, content: content, - title: title + title: displayTitle }, duration: 15000, unstyled: true