Repository navigation
refactor: make transcription and capture context-owned per run - #4674
Merged
Merged
Conversation
Capturer.Run now owns its C-side state and cgo.Handle per call instead of a global queue, and Transcriber.Run owns the websocket connection, cancellation, and worker joining for a single transcription run. The TUI drives this through a speechRun that owns readiness/completion and scopes handlers to the tab/editor that started it. Assisted-By: docker-agent
Flush any native tail audio before disposing the capture queue so the last chunk isn't dropped. Distinguish finish from abort during dictation finalization and keep pending text/error state around instead of discarding it, fixing VAD and completion handling to match. Adds finish_test.go and extends transcribe/tui speak tests accordingly. Assisted-By: docker-agent
rumpl
approved these changes
Oct 20, 2026
rumpl
left a comment
Member
There was a problem hiding this comment.
I forgot that we have this feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The old transcription/capture code relied on a global capture queue and
ad-hoc cleanup, making ordering and error handling around dictation
finalization easy to get wrong (e.g. dropped tail audio, lost transcripts
on finish vs abort).
What
Capturer.RunandTranscriber.Runare now configuration-only and owntheir per-run state (native C/cgo.Handle, WebSocket connection) instead
of a global queue. Context cancellation aborts the run; a separate finish
channel stops capture, flushes the tail, drains audio, commits and awaits
ordered final transcripts with a ten-second network timeout.
lossless pending text, a shared error-aware completion path, origin-tab
scoped submission, and cancellation on replacement/shutdown.
blocked I/O/callbacks, finalization timeout, pending text vs
Stop,cancellation, and tab routing.
Testing
task build/task test/task lintpass.go test -race ./pkg/audio/... ./pkg/tuipasses, with the new finalization/race-sensitivetests repeated 10x.
no_audiobuild tag, Linux/Windows, and CGO-disabledbuilds all pass. Live microphone/OpenAI transcription was not
exercised — only unit/race tests.