Repository navigation
fix(desktop): await physical mic teardown - #11031
Conversation
Replace the settings restart timer with the existing physical-stop boundary, wait for on-device STT shutdown, and fence stale restarts with the recording generation. Verification: Swift parse, diff-scoped portable manifest checks, desktop test-quality, E2E coverage, changelog validation, and swift-format 603 no-diff cross-check passed. Full Xcode compile/tests and pinned 602 formatting were unavailable because this machine has Command Line Tools only. Failure-Class: none
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Advance the existing recording generation for stop decisions and exercise the cancellation through the production stop path in the regression test.\n\nVerification:\n- Swift frontend parse passed for changed extension and test files\n- swift-format 603 cross-check produced no diff\n- desktop test-quality check passed\n- desktop E2E flow coverage passed (3/3)\n- desktop changelog validation passed\n\nThe repository-pinned formatter and XCTest remain unavailable without full Xcode on this machine.\n\nFailure-Class: none
|
@/tmp/tmp2xigj0jj.md by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Confirmed still broken on main: restartTranscriptionIfNeeded() guesses CoreAudio teardown finishes in 1.0s via asyncAfter. Awaiting waitForPhysicalStop() plus the recordingGeneration fence is the right shape, and TranscriptionSettingsRestartTests covers it. Holding the merge until the Desktop Swift lane finishes — first CI run for this author, and the PR body notes Swift compilation was not verified locally.
|
Good fix and well-structured. Confirming the technical review on the current head (
One thing worth a human maintainer's eye before merge: Leaving a positive signal; formal merge sign-off stays with the human maintainer track given this is the author's first contribution and it touches the live microphone lifecycle. by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Confirmed the 1.0s asyncAfter guess is still on main (SettingsContentView+Transcription.swift:325) — awaiting waitForPhysicalStop plus the recordingGeneration fencing is the right fix for a CoreAudio teardown race. Desktop bug fix — merging (owner-override).
What changed and why
Fixes the live microphone-switch teardown race tracked in #10921.
Settings previously stopped transcription and guessed that CoreAudio teardown would finish within one second.
AudioCaptureService.stopCapture()deliberately performsAudioDeviceStopand IOProc destruction asynchronously, so a slow Bluetooth teardown could still own the device when the replacement capture opened.waitForPhysicalStop()before reopening capture.recordingGenerationfor both start and stop decisions, preventing an older settings restart from overriding a newer user action.No new capture owner, dependency, compatibility path, or polling loop is introduced.
Product invariants affected
none
How it was verified
xcrun swiftc -frontend -parse <changed Swift files>— passed.swift-format 603.0.0 format --configuration desktop/macos/Desktop/.swift-formatover all changed Swift files — no diff. This is a cross-check only; CI remains authoritative for the repository-pinned 602.0.0 formatter.python3 .github/scripts/run_checks.py --lane local --base origin/main --head HEAD --skip-pr-body-checks— all checks throughdesktop-main-actor-xctest-hookspassed; the runner then stopped atdesktop-swift-format-lintbecause this machine has Command Line Tools only andxcrun --sdk macosx --show-sdk-platform-pathcannot resolve a full Xcode platform SDK.python3 desktop/macos/scripts/check_desktop_test_quality.py— passed.python3 desktop/macos/scripts/check-e2e-flow-coverage.py --strict --base origin/main— 3/3 changed production Swift files covered.python3 .github/scripts/desktop-changelog.py validate— passed.Not locally verified: Swift compilation, XCTest execution, pinned Swift formatting/SwiftLint, named-bundle launch, or physical Bluetooth microphone switching. This PR is draft until the macOS CI lanes pass and the live hardware path is exercised.
Tests
TranscriptionSettingsRestartTestsdrives the production restart boundary through a suspended fake physical stop on the default on-device STT path. It proves the replacement cannot start before teardown completes and, through a real secondstopTranscription()call, that a user stop during teardown cancels the stale restart.Failure class (fixes)
Failure-Class: none
New guards
No repository check or ratchet is added. The focused behavioral regression test would have caught this instance.