feat: Replacement Suggestions from dictation corrections
This implements feature request #272: an Alpha, review-first queue that suggests Instant Replacements from corrections made after dictation.
It deliberately does not silently auto-add anything. FluidVoice proposes replacements, the user reviews them, and approved suggestions become deterministic Instant Replacement entries.
Status
This feature turned out to be significantly harder to implement robustly than I first expected. The current version is working, but it is still rough around the edges and is not yet at the quality bar I would be comfortable with for a public release.
I am keeping this PR open as draft while I spend more time hardening the behavior across real editors and correction flows. Once I have had time to do that, I will decide whether this is ready to merge or whether it needs more substantial rework.

What changed
- Adds a
Replacement Suggestionsreview queue to Custom Dictionary. - Detects edits made after FluidVoice types dictated text and extracts correction candidates.
- Supports AX-readable editors and a generic post-dictation event fallback for editors that do not expose readable AX text.
- Aggregates repeated corrections before showing ordinary suggestions to the user.
- Allows high-signal technical replacements such as
signal flow->SignalFlowto appear after one correction. - Supports ordinary case-only corrections such as
obsidian->Obsidian. - Supports repeated compact-equivalent corrections such as
anti-gravity->Antigravity,anti gravity->Antigravity, andcafe->Caféin AX-blind editor fallback. - Defers likely partial captures so slower corrections such as
fluid sync->FluidSyncdo not create prematurefluid->FluidSsuggestions. - Keeps approved suggestions tied to Instant Replacement, not Parakeet-only Custom Words.
- Shows at most 5 suggestions at once, with a count for any remaining suggestions.
- Preserves pending suggestions on conflicts instead of silently dropping them.
- Adds inline
Addedconfirmation before approved rows animate away. - Refreshes the suggestion list live while the Custom Dictionary page is open.
- Preserves the original target app PID when monitoring helper-process AX text elements.
- Skips Replacement Suggestions AX capture entirely while the opt-in is disabled.
- Escapes approved replacement text so
$and backslashes are applied literally by Instant Replacement. - Preserves technical edge punctuation in learned diff and event-fallback candidates while still stripping sentence punctuation.
- Waits for Reliable Paste verification before starting AX-based correction monitoring, and primes the event fallback during that wait so AX-blind editors can still capture quick corrections.
- Starts the Reliable Paste event fallback only after the typing request is accepted, so rejected insertions cannot monitor unrelated edits.
- Keeps debug logs to correction metadata rather than logging the private replacement text.
- Rejects malformed captured suggestions with unsupported boundary punctuation or mismatched apostrophe rewrites.
Suggestion thresholds
- Most suggestions appear after 2 corrections.
- Technical spellings such as
FluidVoice, acronyms, numbers, and punctuation can appear after 1 correction.
The screenshot uses seeded examples so the review queue and overflow count are visible.
Validation
Latest local validation on 6 May 2026:
swiftformat --lint --config .swiftformat Sources/Fluid/Services/AutoLearnDictionaryService.swift Sources/Fluid/UI/CustomDictionaryView.swift Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftpassed.swiftlint lint Sources/Fluid/Services/AutoLearnDictionaryService.swift Sources/Fluid/UI/CustomDictionaryView.swift Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftpassed with 0 violations.git diff --checkpassed.xcodebuild test -project Fluid.xcodeproj -scheme Fluid -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NO -skip-testing:FluidDictationIntegrationTests/DictationE2ETests/testDictationEndToEnd_whisperTiny_transcribesFixturepassed 50/50 tests.xcodebuild build -project Fluid.xcodeproj -scheme Fluid -configuration Release -destination 'platform=macOS' CODE_SIGNING_ALLOWED=NOpassed.- Manual smoke tests passed in Codex, TextEdit, and Obsidian, including technical joins and
obsidian->Obsidiancase correction.
The skipped test is the existing legacy Whisper tiny E2E fixture. This PR does not change default model download behavior; the feature validation above covers the replacement-suggestion code paths without using that fixture.
Pushed a small CI follow-up: fixed the SwiftLint failure by removing trailing whitespace and moving the custom dictionary/suggestion types into a separate SettingsStore extension so SettingsStore.swift stays under the file-length limit. No behavior change intended.
Pushed a small quality pass on the alpha Suggested Replacements feature: learning is now scoped to the text FluidVoice just inserted, simple title-case fixes can be suggested after repeated corrections, high-signal suggestions are more conservative, and focused tests cover the new behavior.
Pushed one final polish commit. The suggestion thresholds are intentionally balanced so high-signal replacements can appear quickly, while ordinary casing fixes still need repeat evidence before they appear. I also clarified the helper naming, documented the inserted-text scoping trade-off, and added coverage for ordinary title-case corrections.
Updated this PR with the latest tested Replacement Suggestions work.

Latest update includes the Codex/event fallback path for editors without readable AX text, tighter target binding, long-document scoped diffing, conflict-safe approval, the inline Added confirmation, final UI copy/polish using the Replacement Suggestions name, punctuation-edge Instant Replacement matching for approved suggestions such as .net, c++, and node.js, target-PID preservation for helper-process AX text elements, opt-in gating so disabled users do not run Replacement Suggestions AX capture, escaped replacement templates so $ and backslashes apply literally, diff/event-fallback tokenization that preserves technical edge punctuation such as .NET, C++, C#, and 5% while still stripping sentence punctuation, Reliable Paste completion timing that waits for paste verification while priming event fallback during the wait for AX-blind editors, and acceptance gating so rejected typing requests cannot leave fallback monitoring attached to unrelated edits.
Validation on the pushed commit:
swiftlint --stricton the touched Swift files passed with 0 violations.git diff --checkpassed.- Selected DictationE2ETests suite passed 37/37 with the legacy Whisper tiny fixture explicitly skipped.
- Release build passed.
The skipped test is the existing Whisper tiny E2E fixture; this PR does not change default model download behavior.
@codex review
@codex review
@codex review
@codex review
@codex review
Codex Review: Didn't find any major issues. :rocket:
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review
Codex Review: Didn't find any major issues. Nice work!
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review
Codex Review: Didn't find any major issues. Delightful!
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review
Codex Review: Didn't find any major issues. Hooray!
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review
Codex Review: Didn't find any major issues. Swish!
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@codex review
Codex Review: Didn't find any major issues. :rocket:
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".