fix: play completion sound in chat (#466)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user