Repository navigation
Fail dictations whose request the system dropped, not wedge them - #425
Merged
Merged
Conversation
Four catch sites asked "is this error a cancellation?" four ways. The AssemblyAI module now answers it once, on Error: - isCancellationShaped: CancellationError or URLError.cancelled, whoever tore the request down. - isAbandonment: cancellation-shaped and the current task was cancelled. The same error on a task nobody cancelled is a request the system dropped (network switch, sleep), which is a failure. Each site now states which rule it means: - SelectionSpeechRouter's command and rewrite/compose paths use isAbandonment, as dcc9d48 (#342) made them; the private isCancellation helper is gone. A command step stopped by a dropped request now records its error in the step log too, matching the command's own failure record. - DictationSession.awaitUpload treats only Task.isCancelled as a cancel. Its only mid-flight teardown, cancel(), cancels pipelineTask before setPhase(.cancelled) abandons the upload, in the same actor turn, so a cancellation-shaped error with the task not cancelled can only be a system drop. #326 had swallowed that, leaving the phase on .transcribing, which performPress refuses: the dictation key stayed dead until relaunch. It now ends as .failed(.sttFailed(URLError.cancelled)). The test that asserted only "not failed" (and so passed on the wedge) now asserts the failure and that the next press records. - AssemblyAISpeechSynthesizer maps URLError.cancelled to CancellationError only on abandonment. A stop cancels the synthesis task, so stops still read as stops; a read the system cut short now fails (the router beeps and logs it) instead of ending silently. - AsyncTranscriptionClient.isTransient excludes cancellation by shape, as its URL-code set already did: no change in what it retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
swift-format writes a catch with no pattern before `where` with two spaces (`catch where`), as main already does; the lint job's [Spacing] findings on the two clauses this PR rewrote. 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
… CI run Recent multi-commit PRs (#410, #413, #414, #416, #420, #422, #423, #425, #426) mostly spent their extra ~37-minute runs on things nothing caught before CI: - scripts/check-swift-lint-lite.sh: a toolchain-free text match for the opt-in SwiftLint/swift-format rules it can see (modifier_order, no_empty_block, NoBlockComments, swift-format's `catch where`). Run by check.sh (so --portable and --lint-only) and the swift-budgets edit hook; would have flagged the pre-fix files of #414, #422 and #425. - .claude/hooks/push-gate.sh: a PreToolUse hook that runs `check.sh --portable` (~20 s) before any `git push` and blocks a red one — jscpd clones (#420, #422) and post-merge size overruns (#363, #378) were pushes that skipped the documented portable run. - AGENTS.md / CLAUDE.md: a "Rules only CI catches" list for the rest (variable_shadowing, one_declaration_per_file, type_contents_order, multiline_function_chains, MemberImportVisibility, one argument per line), and the new hook and script in the hooks table and permissions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1UDUZXyuF6g7GUmmNu
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 25, 2026
alexkroman
enabled auto-merge
November 25, 2026 21:44
#398 made BlurtEngine provider-neutral: it imports neither the AssemblyAI SDK nor BlurtAssemblyAI. This PR had put the shared cancellation rule in the SDK and imported it into the engine's router, so: - isCancellationShaped and isAbandonment move into BlurtEngine, as an internal extension (Error+Cancellation.swift). The router and the dictation pipeline, the PR's behaviour change, use them unchanged. Internal, so nothing that imports both modules (the tests, BlurtAssemblyAI) sees two definitions. - The SDK states the one rule it needs in place: #398 moved the TTS request into SpeechClient, whose catch now reads a URLError.cancelled as a stop only when its task was cancelled, as this PR's synthesizer change did. AsyncTranscriptionClient and the SDK README are main's again: this PR never changed what it retries. - ARCHITECTURE.md: main's text, with this PR's note that a dropped read fails. 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
Four places asked "is this error a cancellation?" four different ways. The engine now answers it once, as two internal properties on
Error(Sources/BlurtEngine/Error+Cancellation.swift):isCancellationShaped: the error is aCancellationErroror aURLError.cancelled, whoever tore the request down.isAbandonment: the error is cancellation-shaped and the current task was cancelled. A cancellation-shaped error on a task nobody cancelled is a request the system dropped (a network switch, sleep and wake), and that is a failure. This is the rule dcc9d48 (Electron selection read permanently breaks after one voice command, and SelectionSpeechRouter.paste() wedges .working on un-cancelled URLError.cancelled #342) gave the router.They're internal to
BlurtEngine: since #398 the engine imports no provider SDK, and the AssemblyAI SDK states the one rule it needs where it needs it.What the history showed for the dictation pipeline: the shape-only rule came from #326 (fixing #324). But
cancel()is the only thing that tears down the in-flight request, and it callspipelineTask?.cancel()beforesetPhase(.cancelled)in the same actor turn. So the only case #326 changed is a system drop. There the pipeline returned nil and left the phase on.transcribing;performPressonly starts from a terminal phase, so the dictation key stayed dead until relaunch. The existing test only checkedphase != .failed(...), so it passed while the key was dead.SelectionSpeechRouter(execute,perform,paste)isAbandonmentisCancellationhelper is removed.DictationSession.awaitUploadTask.isCancelledonlyTask.isCancelledalone, rather thanisAbandonment, so any error arriving after a real cancel still leaves.cancelledin place.SpeechClient(SDK, TTS)URLError.cancelledandTask.isCancelled, inlinespeech(for:)'sonTermination), so stops still read as stops.AsyncTranscriptionClient.isTransient(SDK)Behaviour change:
URLError.cancelled, no cancel), the dictation now ends.failed(.sttFailed(URLError.cancelled)), with a red pill and anerrors.jsonlentry. Before, the pill stayed on "Transcribing…" and every later press was refused until relaunch. A user's cancel still ends.cancelled, silently.AsyncTranscriptionClientretries.How it was tested
Written in a Linux sandbox with no Swift toolchain:
scripts/check.sh --portable(jscpd included),check-swift-size.shandcheck-test-clock.shpass. CI on macOS verifies the build, swiftlint, swift-format, periphery and every test.CancelRaceTests.systemDroppedRequestFailsreplaces the old "ignored" test. A system-dropped request ends.failed(.sttFailed(URLError(.cancelled))), nothing is pasted, and the next press reaches.recording.SpeechTransportTests.systemDroppedIsFailure:URLError.cancelledwith no stop comes out of the synthesizer asURLError, notCancellationError, both before and during the body.CancellationTests: unit tests for both properties, inside and outside a cancelled task.SelectionSpeechRouter.swiftis at 396/400 lines.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 with Claude Code
https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC