Skip to content

Add “scratch that” voice command to delete the last dictation - #10

Merged
Kuberwastaken merged 3 commits into
mainfrom
feat/scratch-that
Jul 21, 2026
Merged

Add “scratch that” voice command to delete the last dictation#10
Kuberwastaken merged 3 commits into
mainfrom
feat/scratch-that

Conversation

@Kuberwastaken

Copy link
Copy Markdown
Owner

Saying "scratch that" / "delete that" (whole utterance only) deletes the just-inserted dictation instead of pasting.

  • Whole-utterance matcher in new ScratchCommandMatcher (unit-tested: casing/punctuation variants pass; mid-sentence mentions like "scratch that itch please" never trigger).
  • Reuses the wake REPLACE_PREVIOUS safety check (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.
  • After a scratch, older history entries are invalidated so a second "scratch that" (or a wake command) can't act on the deleted text. lastTranscript keeps the deleted dictation, so Paste Again works as an undo.
  • Settings toggle under the press-enter command (default on), key scratch_that_command_enabled.

Verified on macOS 26.5 (arm64): make test passes, 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.swift and 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.

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).
@Kuberwastaken
Kuberwastaken merged commit b08a6d6 into main Jul 21, 2026
1 check passed
@Kuberwastaken
Kuberwastaken deleted the feat/scratch-that branch July 21, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant