Add “scratch that” voice command to delete the last dictation - #10
Merged
Conversation
ScratchCommandMatcher recognizes "scratch that" / "delete that" (and this-variants) only when the entire dictation is the command, tolerating casing and punctuation. Registered in the hand-rolled test runner and in both TEST_RUNNER source lists.
When a whole dictation is a scratch command, skip pasting: select the previously inserted dictation via selectTextImmediatelyBeforeCaret (the wake REPLACE_PREVIOUS safety check) and remove it with a synthesized Delete key press after the shortcut is released. A successful scratch invalidates the tracked previous text so a repeated command cannot double-delete; with nothing eligible the overlay shows "Nothing to scratch". Gated by a new default-on toggle next to the press-enter command (scratch_that_command_enabled).
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.
Saying "scratch that" / "delete that" (whole utterance only) deletes the just-inserted dictation instead of pasting.
ScratchCommandMatcher(unit-tested: casing/punctuation variants pass; mid-sentence mentions like "scratch that itch please" never trigger).selectTextImmediatelyBeforeCaret) and, on success, synthesizes a Delete key press via the same CGEvent pattern as press-enter; runs after shortcut release like the paste path.lastTranscriptkeeps the deleted dictation, so Paste Again works as an undo.scratch_that_command_enabled.Verified on macOS 26.5 (arm64):
make testpasses, full build clean. Manual QA: scratch deletes in a real app; second scratch and moved-caret cases show "Nothing to scratch" without deleting.Conflicts: touches the previous-dictation lookup that #raw-undo refactors — whichever merges second resolves a small conflict.
All eight feature PRs register tests in
Tests/AppContextServiceTests.swiftand some extend the Makefile test list, so each merge after the first needs a trivial conflict resolution there. Suggested merge order: dictionary-ranking → formality-dial → caret-context → transforms → scratch-that → raw-undo → rebindable-cancel → mouse-ptt.