Repository navigation
Make finishing a phase of the realtime transcriber - #421
Merged
Merged
Conversation
…n it RealtimeTranscriber described one lifecycle with three variables: `phase` (idle/open/closed), an `isFinishing` flag that was really a fourth phase, and a `task` whose nil-ness repeated `phase` — the kind of split state 2c7e640 had to fix a race in. `Phase` now has `finishing`, and the WebSocket task lives in the `open` and `finishing` cases, so it can't be set without the phase that owns it or outlive `close`. `send`, `finish` and `waitForTermination` switch on the phase; `isFinishing` and `task` are gone. Every transition maps 1:1 onto the old one: no behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
2 of 3 tasks
One conflict: #410 made RealtimeTranscriber conform to LiveTranscriptionSession on the same line this PR documents Phase under. Kept both; this PR's API is unchanged, so the conformance still holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
alexkroman
enabled auto-merge
November 25, 2026 21:11
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
#421 landed as a squash of the commits this branch was built on, so git saw its RealtimeTranscriber, LiveTranscriptionSession and tests changed twice. main's copies of those three files are exactly #421's, and this branch's are #421's plus this PR's change, so they are kept from here; a plain merge would have left two start() functions in the transcriber. #398's import and TextReader lines come in unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
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.
What & why
RealtimeTranscriberused three variables for one lifecycle:phase(idle/open/closed)isFinishingflag that was really a fourth phasetaskwhose nil-ness repeatedphaseThat is the kind of split state 2c7e640 had to fix a race in.
Phasenow has four cases:idle,open(socket),finishing(socket)andclosed. The WebSocket task lives inside theopenandfinishingcases, so it can't exist without the phase that owns it, and it can't outliveclose.isFinishingand the storedtaskare gone.send,finishandwaitForTerminationswitch on the phase;transmit,receiveandcloseread the socket from it. Every old transition maps 1:1 onto a new one.Behaviour change: none.
How it was tested
Written in a Linux sandbox with no Swift toolchain:
scripts/check.sh --portablepasses, as doescheck-swift-size.shon the file, and no line exceeds 120 columns.CI on macOS verifies the build, swiftlint, swift-format, periphery and the existing
RealtimeTranscriberTests. No tests changed, since behaviour is unchanged.scripts/check.shpasses (or CI will, if I'm not on a Mac)I read AGENTS.md and this doesn't reintroduce anything
deliberately removed
Docs updated if behavior changed
Generated by Claude Code