-
-
Notifications
You must be signed in to change notification settings - Fork 17
Allow hotkey to dismiss error overlay and restart dictation #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
02f4309
Plan for issue #52: hotkey should dismiss error overlay
sebsto 3e46271
Move plan to .kiro/refactor
sebsto b17a409
Allow hotkey to dismiss error overlay and restart dictation (#52)
sebsto c248157
Address review: update doc comment, resilient tests, remove unrelated…
sebsto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Issue #52 — Hotkey should dismiss error overlay and restart dictation | ||
|
|
||
| ## Problem | ||
|
|
||
| When the user presses the hotkey and releases too quickly (no speech captured), the app enters `.error("No speech was detected...")` state with a 5-second auto-dismiss timer. During those 5 seconds, pressing the hotkey again is **silently ignored** — the user is blocked from starting a new dictation. | ||
|
|
||
| ## Root Cause | ||
|
|
||
| Two guard conditions in `StateManager.swift` reject hotkey presses unless the app is in `.idle` state: | ||
|
|
||
| 1. **`beginRecording()`** (push-to-talk mode): `guard appState == .idle else { return }` | ||
| 2. **`toggleRecording()`** (hands-free mode): `case .error: break` | ||
|
|
||
| Both silently drop the hotkey event when the app is in `.error` state. | ||
|
|
||
| ## Fix — 2 changes in `StateManager.swift` | ||
|
|
||
| ### 1. `beginRecording()` — handle `.error` state before the guard | ||
|
|
||
| ```swift | ||
| // Before the existing guard: | ||
| if case .error = appState { | ||
| await resetToIdle() | ||
| } | ||
| guard appState == .idle else { ... } | ||
| ``` | ||
|
|
||
| `resetToIdle()` cancels the error dismiss timer, clears the error message, and sets state to `.idle`. The existing guard then passes and recording starts normally. | ||
|
|
||
| ### 2. `toggleRecording()` — separate `.error` from `.loading`/`.processing` | ||
|
|
||
| ```swift | ||
| case .error: | ||
| await resetToIdle() | ||
| await beginRecording() | ||
| case .loading, .processing: | ||
| break | ||
| ``` | ||
|
|
||
| ### No changes needed elsewhere | ||
|
|
||
| - **HotkeyMonitor** — already fires callbacks unconditionally regardless of app state | ||
| - **RecordingOverlayView** — already renders all states correctly (error → recording transition is seamless) | ||
| - **wisprApp overlay visibility** — driven by state, will show/hide automatically | ||
| - **resetToIdle()** — already cancels the error dismiss timer and clears state | ||
|
|
||
| ## Testing | ||
|
|
||
| - [x] Add test: hotkey during `.error` state transitions to `.recording` (push-to-talk) | ||
| - [x] Add test: hotkey during `.error` state transitions to `.recording` (hands-free / toggle) | ||
| - [ ] Add test: error dismiss timer is cancelled when hotkey interrupts error state (not directly testable — `errorDismissTask` is private) | ||
| - [x] Verify existing tests still pass | ||
|
|
||
| ## Implementation Summary | ||
|
|
||
| ### Changes in `StateManager.swift` | ||
|
|
||
| 1. **`beginRecording()`** — added `if case .error = appState { await resetToIdle() }` before the existing guard. Clears the error and lets recording proceed. | ||
| 2. **`toggleRecording()`** — split `.error` out of `case .loading, .processing, .error: break` into its own case that calls `resetToIdle()` then `beginRecording()`. | ||
|
|
||
| ### Tests updated in `StateManagerTests.swift` | ||
|
|
||
| 1. **`testBeginRecordingDismissesError`** — replaced old `testConcurrentRecordingPreventionWhileError` that asserted error stays. Now verifies error is dismissed and `errorMessage` is cleared on hotkey press (push-to-talk). | ||
| 2. **`testToggleRecordingDismissesError`** — new test verifying push-to-talk toggle path dismisses error. | ||
| 3. **`testToggleRecordingDismissesErrorHandsFree`** — replaced old `testToggleRecordingIgnoredWhileError`. Now verifies hands-free toggle dismisses error. | ||
|
|
||
| All StateManager tests pass (0 failures). |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.