Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(speech): adopt the mic stream before context construction — a failed start() must stop its tracks (Task 8 review)

enesf6cebca46484
diff --git a/src/renderer/lib/pcm-capture.ts b/src/renderer/lib/pcm-capture.ts
index 24a875cf8..afdda12a2 100644
--- a/src/renderer/lib/pcm-capture.ts
+++ b/src/renderer/lib/pcm-capture.ts
@@ -78,11 +78,14 @@ export class PcmCapture {
try {
const stream = await this.acquireStream()
- const audioContext = new AudioContext({ sampleRate: CAPTURE_SAMPLE_RATE })
- const sourceNode = audioContext.createMediaStreamSource(stream)
-
+ // Adopt the stream IMMEDIATELY: if AudioContext construction or
+ // createMediaStreamSource throws below, the catch's teardown() must be
+ // able to stop these tracks — a live mic (OS indicator lit) must never
+ // outlive a failed start().
this.stream = stream
+ const audioContext = new AudioContext({ sampleRate: CAPTURE_SAMPLE_RATE })
this.audioContext = audioContext
+ const sourceNode = audioContext.createMediaStreamSource(stream)
this.sourceNode = sourceNode
const onChunk = (chunk: Float32Array): void => {