Skip to content

Make finishing a phase of the realtime transcriber - #421

Merged
alexkroman merged 2 commits into
mainfrom
claude/realtime-finishing-phase
Nov 25, 2026
Merged

alexkroman merged 2 commits into
mainfrom
claude/realtime-finishing-phase

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

What & why

RealtimeTranscriber used three variables for one lifecycle:

  • phase (idle/open/closed)
  • an isFinishing flag that was really a fourth phase
  • a task whose nil-ness repeated phase

That is the kind of split state 2c7e640 had to fix a race in.

Phase now has four cases: idle, open(socket), finishing(socket) and closed. The WebSocket task lives inside the open and finishing cases, so it can't exist without the phase that owns it, and it can't outlive close. isFinishing and the stored task are gone. send, finish and waitForTermination switch on the phase; transmit, receive and close read 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 --portable passes, as does check-swift-size.sh on 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.sh passes (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

…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
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
alexkroman enabled auto-merge November 25, 2026 21:11
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 9723fa1 Nov 25, 2026
22 checks passed
@alexkroman
alexkroman deleted the claude/realtime-finishing-phase branch November 25, 2026 21:43
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants