Skip to content

Revert last dictation to the literal transcript (AI edit undo) - #11

Merged
Kuberwastaken merged 4 commits into
mainfrom
feat/raw-undo
Jul 21, 2026
Merged

Revert last dictation to the literal transcript (AI edit undo)#11
Kuberwastaken merged 4 commits into
mainfrom
feat/raw-undo

Conversation

@Kuberwastaken

Copy link
Copy Markdown
Owner

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 via selectTextImmediatelyBeforeCaret, pastes the literal transcript over it. If selection fails it aborts with a toast (never pastes without a selection — no duplication).
  • After revert, the history entry becomes the raw text, so follow-up wake commands ("megaphone, make that shorter") edit the reverted words and Paste Again repeats them.
  • Menu bar: "Revert Last Cleanup", disabled when ineligible or raw == cleaned. History rows already had a "Copy literal transcript" affordance — unchanged.
  • Shared lookup refactored into recentDictationHistoryItem(in:now:) (context-optional for menu validation).

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

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.
@Kuberwastaken
Kuberwastaken merged commit 83e1dea into main Jul 21, 2026
1 check passed
@Kuberwastaken
Kuberwastaken deleted the feat/raw-undo branch July 21, 2026 09:27
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