From 1e6c7aa738fc4e253ff65ba9bbb4c10e085dea88 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:33:27 +0000 Subject: [PATCH] fix(speech): count any engine answer as progress while a dictation finishes --- src/main/speech/stt-worker-stop.ts | 12 ++++++------ src/shared/dictation-finish-deadlines.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/speech/stt-worker-stop.ts b/src/main/speech/stt-worker-stop.ts index 08d03da98d2..79b93ea5766 100644 --- a/src/main/speech/stt-worker-stop.ts +++ b/src/main/speech/stt-worker-stop.ts @@ -47,16 +47,16 @@ export function waitForSttWorkerStop(args: { resolve() } const onStopped = (message: SttWorkerEvent): void => { - if (message.streamId !== args.streamId) { - return - } - if (message.type === 'stopped') { + if (message.type === 'stopped' && message.streamId === args.streamId) { receivedStopped = true finish('stopped') return } - // Text for this stream means the engine is still working through it, however long its backlog is. - timeout?.refresh() + // Sessions share one queue, so any answer means the engine is still working toward this stream, not hung. + // A cancel keeps its short deadline. + if (!args.discard) { + timeout?.refresh() + } } const onError = (error: Error): void => finish('error', error) const onExit = (): void => finish('exit') diff --git a/src/shared/dictation-finish-deadlines.ts b/src/shared/dictation-finish-deadlines.ts index e8b7201630d..fb9216b4294 100644 --- a/src/shared/dictation-finish-deadlines.ts +++ b/src/shared/dictation-finish-deadlines.ts @@ -6,7 +6,7 @@ const WAV_HEADER_BYTES = 44 const CLOUD_RESPONSE_ALLOWANCE_MS = 30_000 const UPLOAD_BYTES_PER_MS = 125 -// A finishing on-device dictation fails once the engine goes this long without text for it. +// A finishing on-device dictation fails once the engine goes this long without answering. export const LOCAL_DICTATION_STOP_TIMEOUT_MS = 60_000 // How long an on-device model may take to load before its dictation fails. export const START_DICTATION_TIMEOUT_MS = 60_000