Skip to content

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

Open
gabrielvaz wants to merge 2 commits into
fastrepl:mainfrom
gabrielvaz:pr/e3-dictation-shortcut-modes
Open

gabrielvaz wants to merge 2 commits into
fastrepl:mainfrom
gabrielvaz:pr/e3-dictation-shortcut-modes

Conversation

@gabrielvaz

@gabrielvaz gabrielvaz commented Dec 1, 2026 •

Copy link
Copy Markdown

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.

Written for commit 641202f. Summary will update on new commits.

View guided diff

gabrielvaz and others added 2 commits November 30, 2026 21:11
…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>
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: d0810ef3-b483-4fba-b48a-e196330789f0
Commits

Reviewing files that changed from the base of the PR and between 3e61b2c and 641202f.

Files selected for processing: 6

  • apps/desktop-gpui/src/dictation/controller.rs
  • apps/desktop-gpui/src/dictation/mod.rs
  • apps/desktop-gpui/src/dictation/shortcut.rs
  • apps/desktop-gpui/src/product/pages.rs
  • apps/desktop-gpui/src/product/preferences_view.rs
  • apps/desktop-gpui/src/product/settings-schema.json

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.

Share

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 6 potential issues.

Devin Review

Comment on lines +507 to +509
if shortcut.is_some() {
all.extend(extra_bindings(&self.extra));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +152 to +155
for (shortcut, action) in self.slots().skip(skip) {
if native_only(shortcut)
|| parse(shortcut).is_err()
|| seen.iter().any(|other| same(other, shortcut))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +935 to +939
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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +507 to +509
if shortcut.is_some() {
all.extend(extra_bindings(&self.extra));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +2428 to +2429
let has_shortcut = action == ShortcutAction::PasteLast && settings.paste_last.is_some();
control = control.child(self.shortcut_recorder(action, has_shortcut, colors, cx));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +2361 to +2375
/// 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,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

This branch has not been deployed

No deployments
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