Skip to content

The agent that grows with you

perf(desktop): test the pending reply's parts in place instead of joining the transcript per flush

kshitijk4poor0571c4e887f0
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
index 511ac47926d..4ea061f4036 100644
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-voice.ts
@@ -77,11 +77,11 @@ export function useComposerVoice({
computed($messages, messages => {
const last = messages.findLast(message => message.role === 'assistant' && !message.hidden)
- if (!last?.pending || !chatMessageText(last).trim()) {
- return null
- }
-
- return last.id
+ // Runs on every streamed flush: test the parts in place instead of
+ // joining the whole reply into a string just to check it is non-blank.
+ return last?.pending && last.parts.some(part => part.type === 'text' && /\S/.test(part.text))
+ ? last.id
+ : null
}),
[$messages]
)