Skip to content

fix: fall back to default microphone after disconnect - #1874

Open
Naam wants to merge 1 commit into
cjpais:mainfrom
Naam:fix/microphone-disconnect-fallback
Open

fix: fall back to default microphone after disconnect#1874
Naam wants to merge 1 commit into
cjpais:mainfrom
Naam:fix/microphone-disconnect-fallback

Conversation

@Naam

@Naam Naam commented Aug 7, 2026

Copy link
Copy Markdown

Before Submitting This PR

  • I have searched existing issues and pull requests (including closed ones) to ensure this isn't a duplicate
  • I have read CONTRIBUTING.md

Human Written Description

Handy completely freezes on macOS when the selected microphone is unplugged. I switch between a desk microphone and my laptop microphone a lot at work, so I need Handy to fall back to an available source and let me keep working.

Related Issues/Discussions

Fixes #1743

PR #1838 recovers when the capture worker exits. On macOS, CoreAudio can report that the device is unavailable while leaving the worker and sample channel alive, so that recovery path does not run.

Community Feedback

Issue #1743 tracks the same failure and includes reports from macOS users.

If this is a feature or change that was previously closed/rejected: Not applicable. This is a bug fix for open issue #1743.

Testing

  • cargo test (179 passed)
  • cargo clippy --lib --tests (passed with existing warnings)
  • bun run check:translations
  • bun run lint
  • bun run format:check
  • bun run build
  • bun run test:playwright (2 passed)
  • Regenerated bun.nix and confirmed it matches the committed file
  • Built and tested the macOS arm64 app locally

Manual test on macOS with a CalDigit TS4 Audio Rear input:

  1. Select the external microphone and record.
  2. Unplug it while Handy still has the stream open.
  3. Start another recording without changing settings.

Handy now closes the stalled stream, selects the system default microphone, updates the dropdown to Default, and records from the MacBook microphone. The app stayed responsive throughout.

Nix flake evaluation was not run locally because Nix is not installed. The PR CI runner will cover it.

Screenshots/Videos (if applicable)

The microphone dropdown was observed changing from CalDigit TS4 Audio - Rear to Default after disconnect. No manual refresh was needed.

AI Assistance

  • No AI was used in this PR
  • AI was used (please describe below)

If AI was used:

  • Tools used: OpenAI Codex
  • How extensively: Codex helped diagnose the hang from logs and a process sample, wrote and reviewed the patch, and ran the local checks. I reproduced the bug and validated each version of the fix on macOS.

@Naam

Naam commented Aug 7, 2026

Copy link
Copy Markdown
Author

Some additional context from testing this on macOS:

Before this change, Handy could keep an unavailable microphone selected after it was unplugged. CoreAudio stopped delivering samples, but the stream still looked open to Handy. A recording would produce no transcription, and canceling it and changing the microphone could leave the entire app frozen until I force quit it.

With this change, Handy detects the failed stream, closes it, clears the unavailable selection, and falls back to the system default microphone. The microphone dropdown also updates to Default. I tested this with a CalDigit TS4 rear input: I recorded through it, unplugged it, and the next recording used the MacBook microphone without a restart or any manual settings change.

This makes a common laptop workflow seamless. I can move away from my desk microphone and keep dictating through the laptop microphone instead of discovering the problem through a silent recording and restarting Handy.

@cjpais

cjpais commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Okay, thank you for the report on this and also the PR. I will try to take a look soon. Probably I'll get to it either tomorrow or the next day and merge it if I can replicate. I think I do have an external mic I can plug into my Mac and try to replicate and also see if the fix works as expected

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.

[BUG] Microphone disconnection leaves audio stream stuck, causing silent failures and preventing new recordings

2 participants