Repository navigation
Description
Describe the bug
If the lid is closed while a dictation is still recording, everything recorded so far is thrown away. macOS removes the built-in microphone when the lid closes, route recovery finds no working replacement, and the failure path stops the session without transcribing it. Nothing reaches History and nothing is typed. I lost a 75-minute recording this way (log below).
Reproduction steps
- Use a MacBook with no external microphone connected (built-in microphone selected). A virtual input such as "Microsoft Teams Audio" may be present; it does not deliver audio.
- Start a dictation with the hotkey in toggle mode and speak for a few seconds.
- Close the lid without stopping the dictation.
- Wait a few seconds and open the lid.
Expected behavior
The audio captured before the microphone disappeared is transcribed and kept, for example saved to History the way cancelling with Escape already does.
Actual behavior
The recording is discarded. There is no History entry and no text. The failure path presents "Recording Stopped: The microphone could not recover after the audio device changed. No remaining microphone is available."
In the code, finishAudioRouteRecoveryFailure calls stopWithoutTranscription(finishingRecovery: true), which clears audioBuffer.
App Version
1.6.13 (34)
macOS Version
macOS 27.2.1 (26B131)
Architecture
Apple Silicon
Logs or crash report
Recording started at 11:33:03 and ran until the lid closed at 12:48:23. Fingerprint details trimmed.
[11:33:03.872] [INFO] [ASRService] ✅ START() completed successfully
[12:48:23.695] [INFO] [AudioHardwareObserver] MacBook clamshell state changed (closed=true)
[12:48:23.696] [INFO] [ASRService] Clamshell closed; refreshing microphone availability
[12:48:23.696] [WARN] [ASRService] Audio route changed during capture; waiting for topology quiet (clamshell closed, generation=1, isStarting=false, isRunning=true)
[12:48:23.696] [INFO] [MicrophonePreferenceCoordinator] Selected microphone changed from 'MacBook Pro Microphone' to 'Microsoft Teams Audio' before capture confirmation
[12:48:23.986] [INFO] [ASRService] Recovering audio route after clamshell closed (generation=1)
[12:48:23.986] [INFO] [DirectCoreAudioLifecycle] Direct capture stop begin generation=1 reason=active_route_recovery retainPrepared=false
[12:48:24.046] [INFO] [DirectCoreAudioLifecycle] Direct capture start begin generation=2 device='Microsoft Teams Audio' validationMs=1
[12:48:26.142] [INFO] [DirectCoreAudioLifecycle] Direct capture stop begin generation=2 reason=active_route_recovery_readiness_retry retainPrepared=false
[12:48:26.152] [ERROR] [ASRService] Direct Core Audio capture failed: No remaining microphone is available.
[12:48:26.154] [ERROR] [ASRService] Audio route recovery failed: Error Domain=ASRService Code=-4 "No remaining microphone is available."
[12:48:26.154] [INFO] [ASRService] 🛑 Stopping recording - releasing audio devices
[12:51:07.023] [INFO] [AudioHardwareObserver] MacBook clamshell state changed (closed=false)
Screenshots or screen recording
No response
Proposed fix
I have a small fix ready and can open a PR. When route recovery fails for a running dictation that still holds audio, the session is finished through the existing history-only stop (the same path Escape uses) instead of stopWithoutTranscription. The text goes to History only; it is not typed or pasted. Afterwards the app shows a notice: "Recording Saved: The microphone became unavailable, so recording stopped. Your dictation up to that point was transcribed and saved to History."
Command and Edit recordings, dictionary training, and sessions with History turned off keep today's behavior.
I have been running a local build with this change. On a real lid close, a 70-minute dictation was saved to History 2.8 seconds after the lid closed, before the Mac slept.
Since this adds a user-facing notice, please say if you want different wording or scope before I open the PR.
This report was drafted with Claude Code from my app logs. I reproduced the bug and ran the lid-close tests on my own Mac.
Activity