fix(frontend): address CodeRabbit review findings on voice conversation mode

Report STT start and capture failures instead of staying on Listening, treat a failed reading as an error, skip replies with no readable text, stop auto-play replaying a reply voice mode already read, focus the text box after Edit in text box, and strip think blocks before text reaches TTS.
This commit is contained in:
Chris Scott committed 2026-10-22 20:36:01 -04:00
1 parent 5d8b2c9445
commit 73af7aec89
8 files changed
+292 -45

No files matched your search

@@ -298,6 +298,26 @@ describe('PromptInput voice conversation', () => {
expect(promptInput()).toHaveValue('draft dictated words')
})
it('focuses the text box with the cursor after the transcript once the conversation closes', async () => {
const view = renderComponent({ onVoiceConversationActiveChange: vi.fn() })
fireEvent.change(promptInput(), { target: { value: 'draft' } })
setVoiceController({ isActive: true, phase: 'listening', canEditInTextBox: true }, 'dictated words')
view.rerenderWith({ messages: [] })
fireEvent.click(screen.getByRole('button', { name: 'Edit in text box' }))
setVoiceController()
view.rerenderWith({ messages: [] })
await waitFor(() => {
const input = promptInput() as HTMLTextAreaElement
expect(input).toHaveFocus()
expect(input.selectionStart).toBe('draft dictated words'.length)
expect(input.selectionEnd).toBe('draft dictated words'.length)
})
})
})
describe('sending a voice turn', () => {
@@ -1112,9 +1112,11 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
const handleVoiceEditInTextBox = useCallback((text: string) => {
const dictated = text.trim()
if (!dictated) return
setPrompt((current) => (current.trim() ? `${current} ${dictated}` : dictated))
textareaRef.current?.focus()
}, [])
const current = promptRef.current
const next = current.trim() ? `${current} ${dictated}` : dictated
setPrompt(next)
focusPromptAt(next.length)
}, [focusPromptAt])
const voiceConversation = useVoiceConversation({
sessionID,