enh: skip chat notifications on other devices if temporary chat (#21292)
* Merge pull request #20581 from Classic298/fix/db-pool-memory-update (#150) Co-authored-by: Claude <noreply@anthropic.com> Fixes #21290 * Update +layout.svelte --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user