From f4de3b4c45f2ab595bae6ad02314520f71d177db Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 19 Apr 2025 23:13:19 -0700 Subject: [PATCH] enh: notificationSoundAlways option --- .github/pull_request_template.md | 2 +- .../components/chat/Settings/Interface.svelte | 34 ++++++++++++++++++- src/routes/+layout.svelte | 13 ++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9e3b712a2..7f603cb10 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -73,4 +73,4 @@ ### Contributor License Agreement -By submitting this pull request, I confirm that I have read and fully agree to the [CONTRIBUTOR_LICENSE_AGREEMENT](CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. +By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. diff --git a/src/lib/components/chat/Settings/Interface.svelte b/src/lib/components/chat/Settings/Interface.svelte index 45399e616..58e764fb2 100644 --- a/src/lib/components/chat/Settings/Interface.svelte +++ b/src/lib/components/chat/Settings/Interface.svelte @@ -30,7 +30,9 @@ // Interface let defaultModelId = ''; let showUsername = false; + let notificationSound = true; + let notificationSoundAlways = false; let detectArtifacts = true; @@ -117,6 +119,11 @@ saveSettings({ notificationSound: notificationSound }); }; + const toggleNotificationSoundAlways = async () => { + notificationSoundAlways = !notificationSoundAlways; + saveSettings({ notificationSoundAlways: notificationSoundAlways }); + }; + const toggleShowChangelog = async () => { showChangelog = !showChangelog; saveSettings({ showChangelog: showChangelog }); @@ -294,7 +301,8 @@ chatDirection = $settings.chatDirection ?? 'auto'; userLocation = $settings.userLocation ?? false; - notificationSound = $settings.notificationSound ?? true; + notificationSound = $settings?.notificationSound ?? true; + notificationSoundAlways = $settings?.notificationSoundAlways ?? false; hapticFeedback = $settings.hapticFeedback ?? false; ctrlEnterToSend = $settings.ctrlEnterToSend ?? false; @@ -477,6 +485,30 @@ + {#if notificationSound} +
+
+
+ {$i18n.t('Always Play Notification Sound')} +
+ + +
+
+ {/if} + {#if $user?.role === 'admin'}
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a908fe20d..97976955d 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -26,7 +26,8 @@ isLastActiveTab, isApp, appInfo, - toolServers + toolServers, + playingNotificationSound } from '$lib/stores'; import { goto } from '$app/navigation'; import { page } from '$app/stores'; @@ -259,6 +260,16 @@ const { done, content, title } = data; if (done) { + if ($settings?.notificationSoundAlways ?? false) { + playingNotificationSound.set(true); + + const audio = new Audio(`/audio/notification.mp3`); + audio.play().finally(() => { + // Ensure the global state is reset after the sound finishes + playingNotificationSound.set(false); + }); + } + if ($isLastActiveTab) { if ($settings?.notificationEnabled ?? false) { new Notification(`${title} | Open WebUI`, {