Fix: prevent hotkey twitches from cancelling in-progress transcriptions#186
Fix: prevent hotkey twitches from cancelling in-progress transcriptions#186uuuser-name wants to merge 1 commit intokitlangton:mainfrom
Conversation
When using hold-to-record mode (Cmd+Option), releasing the modifier
keys stops recording and begins transcription. However, involuntary
finger twitches — re-pressing one or both modifier keys within
milliseconds of release — would trigger handleHotKeyPressed while
isTranscribing was true. The previous implementation responded by
merging Effect.send(.cancel) with Effect.send(.startRecording),
which killed the active transcription and started a new (empty)
recording. This caused users to lose their entire dictation.
The fix changes handleHotKeyPressed to return .none when
isTranscribing is true, making the hotkey press a no-op during
active transcription. The transcription completes uninterrupted
regardless of any subsequent modifier key activity.
Users can still cancel explicitly via ESC if needed — this change
only prevents the accidental cancel-and-restart path that the
original merge(.cancel, .startRecording) produced.
Before:
func handleHotKeyPressed(isTranscribing: Bool) -> Effect<Action> {
let maybeCancel = isTranscribing ? Effect.send(Action.cancel) : .none
let startRecording = Effect.send(Action.startRecording)
return .merge(maybeCancel, startRecording)
}
After:
func handleHotKeyPressed(isTranscribing: Bool) -> Effect<Action> {
if isTranscribing { return .none }
return .send(.startRecording)
}
Also updates the comment at the .hotKeyPressed case (line 99) to
accurately describe the new behavior ("ignore this press, protects
against finger twitches") instead of the stale "send a cancel first".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughHotkey handling in TranscriptionFeature.swift was adjusted to ignore presses when transcription is already active, preventing cancellation conflicts. The implementation now uses a conditional that returns none if transcribing or starts recording otherwise. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
|
@kitlangton I've had multiple instances where 20 minute dictations got lost just because of this issue. Would love if you could merge this through! |
Problem
When using hold-to-record mode (e.g. Cmd+Option), releasing the modifier keys stops recording and begins transcription. However, involuntary finger twitches — re-pressing one or both modifier keys within milliseconds of release — trigger
handleHotKeyPressedwhileisTranscribingis alreadytrue.The previous implementation responded by merging
Effect.send(.cancel)withEffect.send(.startRecording), which killed the active transcription and started a new (empty) recording. This caused users to lose their entire dictation with no warning.Root Cause
In
TranscriptionFeature.swift,handleHotKeyPressedalways started a new recording, and additionally cancelled any in-progress transcription first:The
.merge(.cancel, .startRecording)path was reachable any time a hotkey press arrived during transcription — including accidental re-presses immediately after releasing the hold-to-record key.Fix
When
isTranscribingistrue, the hotkey press is now a no-op. The transcription completes uninterrupted regardless of any subsequent modifier key activity. Users can still cancel explicitly via ESC.Also updates the inline comment at the
.hotKeyPressedcase to accurately describe the new behavior.Impact
Summary by CodeRabbit