Skip to content

Fall back to most recently used mic when no default is marked - #1604

Closed
vinicioslc wants to merge 7 commits into
thewh1teagle:mainfrom
vinicioslc:fix/default-mic-recent-fallback
Closed

vinicioslc wants to merge 7 commits into
thewh1teagle:mainfrom
vinicioslc:fix/default-mic-recent-fallback

Conversation

@vinicioslc

Copy link
Copy Markdown

Problem

On Linux (ALSA via PipeWire), cpal's default_input_device() often returns a synthetic name that never appears in the enumerated device list. No device is marked isDefault, so callers that only check isDefault throw "No default microphone is available" even when mics are present:

  • hotkey.tsx (dictation indicator)
  • recording-shortcut.tsx (global recording shortcut)
  • use-recording.ts (recording tab — saved id only, no fallback)

Solution

Shared findInputDevice() with a universal fallback chain:

  1. Saved id (if that input is still present)
  2. Device marked default
  3. Most recently used input (recording.recentInputDeviceActivity, stamped on every successful start_record)
  4. First available input

Applied to all three call sites. Explicit None (savedInputDeviceId === '') in the recording tab is preserved.

Tests

  • 7 new unit tests for findInputDevice in audio.test.ts
  • Full suite: 138 passed
  • tsc --noEmit: clean

Closes thewh1teagle#1596

- Create indicator window hidden; show only after page_ready
- Call set_ignore_cursor_events after show to avoid panic on hidden window
- Show overlay on hotkey key-down before start_record
- Fallback mic selection when no ALSA isDefault device matches
- Denylist dictation-indicator in window-state (stale 280x200 restore)
- Listen for indicator events before ready signal
Keep only universal dictation-indicator changes (hidden first paint,
page_ready gate, window-state denylist, hotkey overlay on key-down).
Revert ALSA/PipeWire default selection and recording-shortcut fallbacks.

Refs thewh1teagle#1596
On hosts where default_input_device() never matches the enumerated
list (common with ALSA via PipeWire), callers only checked isDefault
and threw "No default microphone" even though inputs existed.

findInputDevice now prefers: saved id → marked default → most recent
activity → first input. Successful starts stamp activity so the next
fallback prefers the mic that last worked. Applied to dictation
hotkey, recording shortcut, and the recording tab.
@vinicioslc vinicioslc closed this Sep 25, 2026
@vinicioslc
vinicioslc deleted the fix/default-mic-recent-fallback branch September 25, 2026 23:34
@vinicioslc
vinicioslc restored the fix/default-mic-recent-fallback branch October 2, 2026 02:09
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.

1 participant