fix: play completion sound in chat (#466)

This commit is contained in:
Zhicheng Han
2026-05-06 08:23:12 +02:00
committed by GitHub
parent 1011c950be
commit f338aeea18
4 changed files with 177 additions and 3 deletions
+20 -1
View File
@@ -5,6 +5,8 @@ import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { useAppStore } from './app'
import { useProfilesStore } from './profiles'
import { useSettingsStore } from './settings'
import { primeCompletionSound, playCompletionSound } from '@/utils/completion-sound'
import { detectThinkingBoundary } from '@/utils/thinking-parser'
// Re-export ContentBlock for convenience
@@ -581,9 +583,23 @@ export const useChatStore = defineStore('chat', () => {
target.updatedAt = Date.now()
}
function primeCompletionBellIfEnabled() {
if (useSettingsStore().display.bell_on_complete) {
primeCompletionSound()
}
}
function playCompletionBellIfEnabled() {
if (useSettingsStore().display.bell_on_complete) {
void playCompletionSound()
}
}
async function sendMessage(content: string, attachments?: Attachment[]) {
if ((!content.trim() && !(attachments && attachments.length > 0)) || isStreaming.value) return
primeCompletionBellIfEnabled()
if (!activeSession.value) {
const session = createSession()
switchSession(session.id)
@@ -904,6 +920,8 @@ export const useChatStore = defineStore('chat', () => {
content: 'Error: Agent returned no output. The model call may have failed (e.g. invalid API key, model not supported by provider, or context exceeded). Check the hermes-agent logs for details.',
timestamp: Date.now(),
})
} else {
playCompletionBellIfEnabled()
}
// 自动播放语音
@@ -1236,9 +1254,10 @@ export const useChatStore = defineStore('chat', () => {
content: 'Error: Agent returned no output. The model call may have failed (e.g. invalid API key, model not supported by provider, or context exceeded). Check the hermes-agent logs for details.',
timestamp: Date.now(),
})
} else {
playCompletionBellIfEnabled()
}
cleanup()
updateSessionTitle(sid)
break