Let dictation use hold-to-talk, hands-free and paste-last shortcuts at the same time
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_shortcutsanddictation_handsfree_shortcuts(JSON string arrays) anddictation_paste_last_shortcut. Until either list is saved, the existingdictation_shortcutbelongs to the list itsdictation_hands_freeswitch 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 asShortcutEvent::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 --checkok;cargo clippy --locked --all-targets --no-deps -- -D warningsok;cargo test --locked --lib985 passed, 0 failed;cargo test --locked --test a11y23 passed.dprint checkon 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, anddictation_paste_last_shortcutsettings 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_shortcutstays 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.