Let dictation use hold-to-talk, hands-free and paste-last shortcuts at the same time

GA
7h ago
+803-158

Summary

Context: Dictation has one shortcut, and the "Hands-free dictation" switch decides whether it records while held or toggles. Someone who wants a quick hold-to-talk key and a separate key for longer hands-free dictation has to keep flipping the switch, and the last dictation can only be copied back from Settings.

Intention: Each mode should have its own shortcuts, armed together, plus a shortcut that pastes the last dictation again.

Direction:

  • New settings: dictation_hold_shortcuts and dictation_handsfree_shortcuts (JSON string arrays) and dictation_paste_last_shortcut. Until either list is saved, the existing dictation_shortcut belongs to the list its dictation_hands_free switch chose, so current setups keep working with no migration.
  • The first hold-to-talk shortcut (else the first hands-free one) keeps the existing registration path unchanged, including the Wayland portal binding and the macOS Fn / Right Command tap. The other shortcuts are registered alongside it on native backends (Shortcuts::set_extra, routed as ShortcutEvent::ExtraPressed/ExtraReleased). Each run keeps the mode that started it (Controller::press_as), so a hold key also finishes a hands-free run and a hands-free key does not end a hold run.
  • Paste last dictation inserts the transcript kept in memory into the field focused now, on key release, through the same insertion as a finished dictation. Nothing is kept beyond what "Copy last dictation" already keeps.
  • Settings → Dictation replaces the single recorder and the hands-free switch with three rows (Hold to talk, Hands-free, Paste last dictation): key chips with a remove button and a recorder per row. A shortcut used by another row is refused, and the last hold or hands-free shortcut cannot be removed. Fn / Globe and Right Command become the first hold-to-talk shortcut.

Known limit: on the Wayland portal only the main shortcut is bound; extra and paste-last shortcuts are native-backend only for now.

Demo

Screenshots to be attached by the author before review.

Verification

  • New tests: extra_shortcuts_follow_the_primary_one_and_route_with_their_action (legacy resolution, de-duplication, routing), hold_and_hands_free_shortcuts_armed_together_keep_each_runs_own_mode (controller), paste_last_shortcut_is_armed_and_reinserts_the_last_dictation (armed extras and paste-last through the Dictation state machine).
  • On an Apple Silicon Mac with Xcode, from apps/desktop-gpui: cargo fmt --check ok; cargo clippy --locked --all-targets --no-deps -- -D warnings ok; cargo test --locked --lib 985 passed, 0 failed; cargo test --locked --test a11y 23 passed. dprint check on the changed files ok.
  • Not tested by hand in this pass: registering several global shortcuts at once on macOS/Windows/X11, and the Settings rows on a real display.

šŸ¤– Generated with Claude Code


Summary by cubic

Dictation can now use hold-to-talk, hands-free, and paste-last shortcuts at the same time, so you no longer have to flip the Hands-free switch or copy the last transcript out of Settings. A paste-last shortcut re-inserts the last transcript into the focused field.

What changed

  • New dictation_hold_shortcuts, dictation_handsfree_shortcuts, and dictation_paste_last_shortcut settings arm all three shortcuts together.
  • Runs keep the mode that started them: a hold key also finishes a hands-free run, and a hands-free key doesn't end a hold run.
  • Settings → Dictation now has three shortcut rows with key chips, a remove button, and a recorder each; shortcuts already used by another row are refused.

Compatibility

  • No migration: until either new list is saved, dictation_shortcut stays in the mode the Hands-free switch chose.
  • The first hold or hands-free shortcut keeps the existing registration path, including the Wayland portal and macOS Fn / Globe / Right Command; extra and paste-last shortcuts are native-backend only for now.