From 576babe9f166d01ae4a0ad2ed972cd674dc7314e Mon Sep 17 00:00:00 2001 From: marius-kilocode Date: Thu, 14 May 2026 15:46:36 +0200 Subject: [PATCH] fix(vscode): lock speech capture during startup --- .../kilo-vscode/src/speech-to-text/capture.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/kilo-vscode/src/speech-to-text/capture.ts b/packages/kilo-vscode/src/speech-to-text/capture.ts index f81cf3e53fd..3ae3005601b 100644 --- a/packages/kilo-vscode/src/speech-to-text/capture.ts +++ b/packages/kilo-vscode/src/speech-to-text/capture.ts @@ -30,14 +30,20 @@ type Audio = { } let active: Recording | undefined +let starting: string | undefined export async function startSpeechCapture(input: Input): Promise { - if (active) throw new Error("Speech recording is already in progress") + if (active || starting) throw new Error("Speech recording is already in progress") - const bin = await findFFmpeg() - const file = path.join(os.tmpdir(), `kilo-stt-${process.pid}-${Date.now()}.wav`) - const state = await startWithArgs(bin, file, input, await inputArgSets(bin)) - return !state.stopped + starting = input.requestId + try { + const bin = await findFFmpeg() + const file = path.join(os.tmpdir(), `kilo-stt-${process.pid}-${Date.now()}.wav`) + const state = await startWithArgs(bin, file, input, await inputArgSets(bin)) + return !state.stopped + } finally { + if (starting === input.requestId) starting = undefined + } } export async function stopSpeechCapture(requestId: string): Promise