[BUG] macOS: cancel shortcut (Escape) stays registered after a very short recording, swallowing Esc system-wide
Bug Description
After a very short recording, the cancel shortcut (plain Escape) can stay registered after the recording ends. From then on Handy swallows every Escape keypress system-wide: no other app receives Esc until Handy is quit. It persisted for over a day here, until I quit Handy.
The log shows the cancel shortcut being registered, the recording stopping with 0 samples, and no matching Unregistered line. Every Escape press afterwards is captured as binding=cancel:
[2026-09-27][14:13:36][handy_app_lib::managers::audio][DEBUG] Recording started for binding transcribe_with_post_process
[2026-09-27][14:13:36][handy_app_lib::actions][DEBUG] Recording started in 122.023459ms
[2026-09-27][14:13:36][handy_app_lib::shortcut::handy_keys][DEBUG] Registered handy-keys shortcut: cancel -> Hotkey { modifiers: Modifiers(0x0), key: Some(Escape) }
[2026-09-27][14:13:36][handy_app_lib::actions][DEBUG] Recording stopped and samples retrieved in 60.04475ms, sample count: 0
... (no "Unregistered handy-keys shortcut: cancel")
[2026-09-27][14:24:11][handy_app_lib::shortcut::handy_keys][DEBUG] handy-keys event: binding=cancel, hotkey=escape, state=Pressed
... continues through 2026-09-28 until Handy was quitFor comparison, a normal recording logs Registered ... cancel then Unregistered handy-keys shortcut: cancel.
Likely cause (still present on v0.9.7)
In src-tauri/src/shortcut/handy_keys.rs, both register_cancel_shortcut and unregister_cancel_shortcut do their work inside a separate tauri::async_runtime::spawn, and nothing orders the two tasks. TranscribeAction::start calls register, and stop calls unregister. On a very fast start→stop, the unregister task can run before the register task:
- The unregister task runs first. There is nothing to unregister yet, and the error is discarded (
let _ = state.unregister(&cancel_binding);). - The register task then runs and registers Escape.
- The recording is already over, so nothing unregisters it again. Escape stays grabbed.
Possible fixes: run register/unregister on one ordered queue, or synchronously; or have the register task check a recording generation/flag and skip registration if the recording has already stopped.
Repro
Tap the transcribe shortcut (here the post-process binding) quickly enough that the recording stops almost immediately (0 samples). Occasionally Escape then stays captured. Check with /bin/cat -v in a terminal: Esc prints nothing until Handy is quit.
System Information
App Version: 0.9.0 (the race is still in the v0.9.7 source)
Operating System: macOS 26.6
CPU: Apple M4 Pro
GPU: Apple M4 Pro GPU
Keyboard implementation: handy_keys
Source: cjpais/Handy