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 chatEventHandler = async (event, cb) => {
|
||||||
const chat = $page.url.pathname.includes(`/c/${event.chat_id}`);
|
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';
|
let isFocused = document.visibilityState !== 'visible';
|
||||||
if (window.electronAPI) {
|
if (window.electronAPI) {
|
||||||
const res = await window.electronAPI.send({
|
const res = await window.electronAPI.send({
|
||||||
@@ -346,6 +354,7 @@
|
|||||||
if ((event.chat_id !== $chatId && !$temporaryChatEnabled) || isFocused) {
|
if ((event.chat_id !== $chatId && !$temporaryChatEnabled) || isFocused) {
|
||||||
if (type === 'chat:completion') {
|
if (type === 'chat:completion') {
|
||||||
const { done, content, title } = data;
|
const { done, content, title } = data;
|
||||||
|
const displayTitle = title || $i18n.t('New Chat');
|
||||||
|
|
||||||
if (done) {
|
if (done) {
|
||||||
if ($settings?.notificationSoundAlways ?? false) {
|
if ($settings?.notificationSoundAlways ?? false) {
|
||||||
@@ -360,7 +369,7 @@
|
|||||||
|
|
||||||
if ($isLastActiveTab) {
|
if ($isLastActiveTab) {
|
||||||
if ($settings?.notificationEnabled ?? false) {
|
if ($settings?.notificationEnabled ?? false) {
|
||||||
new Notification(`${title} • Open WebUI`, {
|
new Notification(`${displayTitle} • Open WebUI`, {
|
||||||
body: content,
|
body: content,
|
||||||
icon: `${WEBUI_BASE_URL}/static/favicon.png`
|
icon: `${WEBUI_BASE_URL}/static/favicon.png`
|
||||||
});
|
});
|
||||||
@@ -373,7 +382,7 @@
|
|||||||
goto(`/c/${event.chat_id}`);
|
goto(`/c/${event.chat_id}`);
|
||||||
},
|
},
|
||||||
content: content,
|
content: content,
|
||||||
title: title
|
title: displayTitle
|
||||||
},
|
},
|
||||||
duration: 15000,
|
duration: 15000,
|
||||||
unstyled: true
|
unstyled: true
|
||||||
|
|||||||
Reference in New Issue
Block a user