Revert last dictation to the literal transcript (AI edit undo) - #11
Merged
Conversation
When the smart cleanup over-edits, recover exactly what was said (Wispr Flow's "AI edit undo"). revertLastDictationToRaw() reuses the wake REPLACE_PREVIOUS machinery: select the cleaned text via AX only while it still sits immediately before the caret (same 120s window and app/window matching as wake commands), then paste the raw transcript over the selection. A successful revert rewrites the tracked previous text so follow-up wake commands and Paste Again target the reverted words.
Sits next to Paste Again; disabled while recording/transcribing, when no dictation landed within the previous-text window, or when the cleanup made no edits (raw == cleaned). The Settings run-log rows already offer a copy-literal-transcript button, so no history UI changes were needed.
Pure string-side checks: revert only when both transcripts are non-empty and differ beyond surrounding whitespace, returning the trimmed raw text. Registers the suite in the hand-rolled runner and adds the new source and test files to both TEST_RUNNER lists in the Makefile.
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.
When smart cleanup over-edits, recover exactly what you said.
revertLastDictationToRaw(): finds the newest eligible history entry via the same 120s/app/window predicate the wake path uses, selects the cleaned text viaselectTextImmediatelyBeforeCaret, pastes the literal transcript over it. If selection fails it aborts with a toast (never pastes without a selection — no duplication).recentDictationHistoryItem(in:now:)(context-optional for menu validation).Verified on macOS 26.5 (arm64):
make testpasses, full build clean. Manual QA: in-place swap in a real app; menu item can be enabled but still safely refuse after switching apps (intended fail-safe).Conflicts: refactors the lookup that #scratch-that filters — 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.