Skip to content

Commit 5eb4701

Browse files
committed
chore: dispose voice chat agent
1 parent ed45e82 commit 5eb4701

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/components/chat-bot-voice.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
OPENAI_VOICE,
88
useOpenAIVoiceChat as OpenAIVoiceChat,
99
} from "lib/ai/speech/open-ai/use-voice-chat.openai";
10-
import { cn, groupBy } from "lib/utils";
10+
import { cn, groupBy, isNull } from "lib/utils";
1111
import {
1212
CheckIcon,
1313
Loader,
@@ -245,6 +245,17 @@ export function ChatBotVoice() {
245245
}
246246
}, [voiceChat.isOpen]);
247247

248+
useEffect(() => {
249+
if (!voiceChat.isOpen && !isNull(voiceChat.agentId)) {
250+
appStoreMutate((prev) => ({
251+
voiceChat: {
252+
...prev.voiceChat,
253+
agentId: undefined,
254+
},
255+
}));
256+
}
257+
}, [voiceChat.isOpen]);
258+
248259
useEffect(() => {
249260
if (error && isActive) {
250261
toast.error(error.message);
@@ -254,6 +265,7 @@ export function ChatBotVoice() {
254265

255266
useEffect(() => {
256267
if (voiceChat.isOpen) return;
268+
257269
const handleKeyDown = (e: KeyboardEvent) => {
258270
const isVoiceChatEvent = isShortcutEvent(e, Shortcuts.toggleVoiceChat);
259271
if (isVoiceChatEvent) {

0 commit comments

Comments
 (0)