feat: add cancel recording hotkey (Escape by default, configurable)#391
Open
N0amG wants to merge 1 commit intoOpenWhispr:mainfrom
Open
feat: add cancel recording hotkey (Escape by default, configurable)#391N0amG wants to merge 1 commit intoOpenWhispr:mainfrom
N0amG wants to merge 1 commit intoOpenWhispr:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Cancel recording hotkey (Escape by default, fully configurable)
Summary
As describe in the issue #290
Pressing a configurable key (default: Escape) during an active recording cancels it without transcribing. Outside of a recording, the key behaves normally system-wide.
How it works
The cancel hotkey is registered as a
globalShortcutonly while recording is active, then immediately unregistered on stop, cancel, or unexpected disconnect. Zero system-wide footprint at rest.Changes
src/helpers/ipcHandlers.jsregister-cancel-hotkey— callshotkeyManager.registerSlot("cancel", key, cb)(reuses existing slot system)unregister-cancel-hotkey— callshotkeyManager.unregisterSlot("cancel")preload.jsregisterCancelHotkey,unregisterCancelHotkey,onCancelHotkeyPressedto the renderer via the existingregisterListenerpatternsrc/hooks/useAudioRecording.jsperformStartRecording()— registers the cancel hotkey on successful startperformStopRecording()— unregisters it before stoppingcancelRecording()— unregisters it before cancellingonStateChange— bug fix: unregisters ifisRecordingdrops tofalseunexpectedly (e.g. streaming server disconnect), preventing a permanent Escape interceptsrc/App.jsxonCancelHotkeyPressedand callscancelRecording()(guarded byisRecording)src/stores/settingsStore.tscancelKey— persisted tolocalStorage, default"Escape", no IPC side-effects (key is read at recording start, not at boot)src/hooks/useSettings.tscancelKey/setCancelKeythroughSettingsContextsrc/components/SettingsPage.tsxHotkeyInputfor the cancel key under Settings → Shortcuts"Escape"src/components/ui/HotkeyInput.tsxskipListeningMode— whentrue, focusing the input does not suspend/resume the dictation hotkey (used for the cancel key input to avoid interference)data-capturingattribute while capturing, used bySidebarModalbelowsrc/components/ui/SidebarModal.tsxonEscapeKeyDownonDialogPrimitive.Content— prevents Radix from closing the modal when Escape is being captured by aHotkeyInputsrc/locales/*/translation.json(10 languages)Architecture note
The cancel key deliberately uses
globalShortcut(same as the dictation key) rather than a DOMkeydownlistener, so it works even when OpenWhispr is in the background. It reuses the existinghotkeyManagerslot system — no new infrastructure was needed.Testing checklist