From 1dcfbf25a2548c3dd0d7062cec2f13ec339b641b Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Mon, 6 Jul 2026 13:45:19 +0100 Subject: [PATCH] fix(dictation): handle transcription failed events OpenAI emits conversation.item.input_audio_transcription.failed when an item cannot be transcribed (e.g. audio_unintelligible). Previously this event was dropped by the type filter, leaving isTranscribing stuck true with no user feedback after a preceding buffer commit. Now the failed event is treated as terminal: clears the transcribing indicator and surfaces the error message via toast. --- .../src/features/dictation/hooks/useRealtimeDictation.ts | 8 ++++++++ desktop/src/features/dictation/lib/realtimeAudio.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/desktop/src/features/dictation/hooks/useRealtimeDictation.ts b/desktop/src/features/dictation/hooks/useRealtimeDictation.ts index 9e965a05b..07518e26a 100644 --- a/desktop/src/features/dictation/hooks/useRealtimeDictation.ts +++ b/desktop/src/features/dictation/hooks/useRealtimeDictation.ts @@ -8,6 +8,7 @@ import { BUFFER_COMMITTED_EVENT, TRANSCRIPT_COMPLETED_EVENT, TRANSCRIPT_DELTA_EVENT, + TRANSCRIPT_FAILED_EVENT, commitAudioBuffer, connectPeerConnection, createAudioBufferCapture, @@ -185,6 +186,13 @@ export function useRealtimeDictation({ return; } + if (event.type === TRANSCRIPT_FAILED_EVENT) { + console.warn("OpenAI transcription failed for item", event); + setIsTranscribing(false); + toast.error(event.error?.message ?? "Transcription failed"); + return; + } + if ( event.type !== TRANSCRIPT_DELTA_EVENT && event.type !== TRANSCRIPT_COMPLETED_EVENT && diff --git a/desktop/src/features/dictation/lib/realtimeAudio.ts b/desktop/src/features/dictation/lib/realtimeAudio.ts index 904134632..1ce20b0dd 100644 --- a/desktop/src/features/dictation/lib/realtimeAudio.ts +++ b/desktop/src/features/dictation/lib/realtimeAudio.ts @@ -8,6 +8,8 @@ export const TRANSCRIPT_DELTA_EVENT = "conversation.item.input_audio_transcription.delta"; export const TRANSCRIPT_COMPLETED_EVENT = "conversation.item.input_audio_transcription.completed"; +export const TRANSCRIPT_FAILED_EVENT = + "conversation.item.input_audio_transcription.failed"; export const BUFFER_COMMITTED_EVENT = "input_audio_buffer.committed"; const MAX_BUFFER_CHUNKS = 500; // ~10s at 20ms per chunk