Repository navigation
Let dictation use hold-to-talk, hands-free and paste-last shortcuts at the same time - #8389
gabrielvaz wants to merge 2 commits into
Conversation
…s together Dictation had one shortcut, and the hands-free switch decided whether it recorded while held or toggled. People who want both behaviors had to flip the switch, and the last dictation could only be copied from Settings. New settings keep a list of hold-to-talk shortcuts, a list of hands-free shortcuts and an optional paste-last shortcut. Until either list is saved, the existing shortcut belongs to the list its hands-free switch chose, so current setups keep working. The first hold-to-talk shortcut (else the first hands-free one) keeps the existing registration, including the Wayland portal binding and the macOS Fn / Right Command tap. The others are registered alongside it on native backends; each run remembers the mode that started it. The paste-last shortcut inserts the kept transcript again into the focused field on release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings → Dictation replaces the single shortcut recorder and the hands-free switch with three rows: Hold to talk, Hands-free and Paste last dictation. Each row lists its shortcuts as key chips with a remove button and records a new one; a shortcut already used by another row is refused. Fn / Globe and Right Command become the first hold-to-talk shortcut, since the macOS event tap follows a single key. The last hold-to-talk or hands-free shortcut cannot be removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
| if shortcut.is_some() { | ||
| all.extend(extra_bindings(&self.extra)); | ||
| } |
There was a problem hiding this comment.
🔴 One conflicting shortcut disables dictation
When users add the meeting-recording chord, apply_native loses every dictation shortcut, including previously working ones. configure clears the old bindings before replace rejects the duplicate. Retrying leaves dictation disabled until the conflict is removed.
Learn more
The settings recorder checks the new chord against dictation rows in save_shortcut, not against the app's built-in meeting shortcut. Native reconfiguration first removes existing dictation bindings in configure. The new registration includes the meeting chord twice, so replace rejects it and sync marks dictation unarmed.
Example: On Windows, add Ctrl+Shift+R to the paste-last row while Ctrl+Alt+Space already works for dictation. The new shortcut is saved, but Ctrl+Alt+Space stops working too.
Recommended fix: Reject conflicts with the canonical base hotkeys before saving, and preserve the last working registrations and armed state if the OS rejects an added shortcut.
Was this helpful? React with 👍 or 👎 to provide feedback.
| for (shortcut, action) in self.slots().skip(skip) { | ||
| if native_only(shortcut) | ||
| || parse(shortcut).is_err() | ||
| || seen.iter().any(|other| same(other, shortcut)) |
There was a problem hiding this comment.
🔴 Existing macOS hands-free shortcut stops working
Adding a hold-to-talk shortcut silently drops an existing Fn or Right Command hands-free shortcut from extra. primary gives the new hold shortcut the only slot that supports those keys. Settings still lists the hands-free shortcut.
Learn more
Before an edit, resolve carries the legacy modifier-only shortcut into the hands-free row. Adding a regular hold chord in save_shortcut saves both rows. primary then chooses the hold chord, and the macOS listener is conditional on the primary shortcut being modifier-only. The modifier-only hands-free shortcut is never registered as an extra.
Example: Upgrade with Fn configured for hands-free, then add Ctrl+Alt+D under Hold to talk. Ctrl+Alt+D works, but Fn does nothing despite still appearing in the Hands-free row.
Recommended fix: On native macOS, keep the existing modifier-only key in the event-tap slot and route ordinary chords as extras with their own actions. Test upgrading a hands-free Fn binding and then adding a hold chord.
Was this helpful? React with 👍 or 👎 to provide feedback.
| ShortcutEvent::ExtraPressed(shortcut::Action::Hold) => self.controller.press_as(false), | ||
| ShortcutEvent::ExtraPressed(shortcut::Action::HandsFree) => { | ||
| self.controller.press_as(true) | ||
| } | ||
| ShortcutEvent::ExtraReleased(shortcut::Action::Hold) => self.controller.release(false), |
There was a problem hiding this comment.
🔴 Unrelated key release truncates dictation
While one hold-to-talk shortcut records, shortcut ends the recording when the user taps a second hold-to-talk shortcut. press ignores the second press, but the release carries no recording owner. Speech after that release is lost, even while the original shortcut stays held.
Learn more
The router tracks physical presses by binding ID in router_with_gates, but forwards only the action for extras. While a hold run is active, press rejects later presses. release finishes the hold run regardless of which chord was released. The same crossed release can latch an early finish while the microphone is opening.
Example: Bind Ctrl+Alt+D and Ctrl+Alt+F to Hold to talk. Hold Ctrl+Alt+D, tap F while keeping D and the modifiers held, then continue speaking. The recording ends as soon as F comes up.
Recommended fix: Carry a stable binding identity through press and release events, store it when a hold run starts, and ignore releases from other bindings. Keep explicit Finish, timeout and hands-free toggle behavior independent of that identity.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if shortcut.is_some() { | ||
| all.extend(extra_bindings(&self.extra)); | ||
| } |
There was a problem hiding this comment.
🟡 Escape misses secondary hold shortcuts
On native backends, apply_native misses Escape while users hold a secondary dictation chord with different modifiers. bindings registers modified Escape only for the primary chord. Releasing the held chord then transcribes instead of discarding the recording.
Learn more
bindings builds plain Escape and at most one modified Escape registration, using the primary accelerator's modifiers. The extra registrations add no matching cancel chord. shortcut treats the subsequent hold release as a normal finish.
Example: On Windows, set Ctrl+Alt+Space as primary and Ctrl+Shift+D as another hold chord. Hold Ctrl+Shift+D, speak, then press Escape without releasing Ctrl or Shift. Ctrl+Shift+Escape is not registered, and releasing the hold chord finishes the dictation.
Recommended fix: Register one cancel chord per distinct modifier set from the native recording bindings, or use the initiating chord's modifier set while its run is active. Route these registrations through the existing cancel path and preserve the plain Escape binding.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let has_shortcut = action == ShortcutAction::PasteLast && settings.paste_last.is_some(); | ||
| control = control.child(self.shortcut_recorder(action, has_shortcut, colors, cx)); |
There was a problem hiding this comment.
🔍 Inactive Wayland shortcuts look usable
shortcut_recorder offers Add or Change for shortcuts the portal backend will not register. The settings page gives users no way to distinguish those saved shortcuts from the active one.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /// Saves all three rows, so a legacy single shortcut moves into its list on the first edit. | ||
| fn save_dictation_shortcuts(&mut self, settings: ShortcutSettings, cx: &mut Context<Self>) { | ||
| let list = | ||
| |list: &[String]| json!(serde_json::to_string(list).unwrap_or_else(|_| "[]".into())); | ||
| self.set(dictation_keys::HOLD_KEY, list(&settings.hold), cx); | ||
| self.set( | ||
| dictation_keys::HANDS_FREE_KEY, | ||
| list(&settings.hands_free), | ||
| cx, | ||
| ); | ||
| self.set( | ||
| dictation_keys::PASTE_LAST_KEY, | ||
| json!(settings.paste_last.unwrap_or_default()), | ||
| cx, | ||
| ); |
There was a problem hiding this comment.
🔍 First-edit shortcut persistence lacks coverage
save_dictation_shortcuts writes three preferences on the first edit. The paste-last test seeds the new keys directly, leaving the legacy-to-saved transition untested.
Was this helpful? React with 👍 or 👎 to provide feedback.
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:
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.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.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
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).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.🤖 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
dictation_hold_shortcuts,dictation_handsfree_shortcuts, anddictation_paste_last_shortcutsettings arm all three shortcuts together.Compatibility
dictation_shortcutstays in the mode the Hands-free switch chose.Written for commit 641202f. Summary will update on new commits.