FluidVoice icon indicating copy to clipboard operation
FluidVoice copied to clipboard

feat: voice editing commands — scratch/capitalize/slash/new line (#406)

Open Kayaba-Attribution opened this issue 5 months ago • 2 comments

Closes #406

What this does

Adds inline voice editing commands spoken at the end of a dictation utterance:

Phrase Effect Example
"scratch that" / "delete that" Delete last N words (default 1) "send the report scratch that" → "send the"
"capitalize that" Capitalize first letter of last word "call monday capitalize that" → "call Monday"
"slash that" Append "/" to last word "src slash that" → "src/"
"new line" / "new paragraph" Insert newline "first item new line" → "first item\n"

Design

New file: Sources/Fluid/Services/VoiceCommandProcessor.swift — self-contained detect/apply pipeline, no dependencies beyond Foundation. Parameterized via VoiceCommandSettings protocol so it's testable in isolation.

Intercept point: DictationPostProcessingService.process(_:dictationSlot:), immediately after input trimming, before any provider routing — covers Private AI, Apple Intelligence, and cloud LLM paths uniformly.

Two execution paths:

  • Command-only utterance (e.g. "scratch that" alone) → early return, LLM bypassed entirely
  • Mixed utterance (text + command) → strip command phrase before LLM, apply edit post-GAAV formatting

Feature gate: voiceCommandsEnabled in Settings (defaults off). "Scratch that" word count is configurable via voiceCommandScratchWordCount (defaults 1).

Scope / v1 limits

  • Trailing-position commands only. Mid-sentence detection is deferred to v2.
  • ASR variance handled: comma-space and hyphen variants normalized before matching.
  • Word-boundary enforced: "capitalize that letter" does not trigger "capitalize that".
  • Punctuation on tokens: stripped before edit, re-attached after.
  • Literal intent escape hatch (saying "new line" as dictated text) is flagged with a TODO(v2) comment.

Tests

19 unit tests in VoiceCommandProcessorTests covering: feature toggle, all commands and synonyms, trailing-only enforcement, word-boundary matching, ASR variance normalization, punctuation stripping/reattach, one-word empty result, and configurable scratch count.

Checklist

  • [x] Builds without errors
  • [x] All 63 tests pass (19 new + 44 existing)
  • [x] swiftlint clean (0 warnings on changed files)
  • [x] swiftformat run on changed files
  • [x] Feature gated off by default — no behaviour change for existing users
  • [ ] Settings UI for the toggle (out of scope for this PR — feature is accessible via UserDefaults for now)

Kayaba-Attribution avatar Jun 29 '26 12:06 Kayaba-Attribution

Will fully test and verify in the upcoming days

Kayaba-Attribution avatar Jun 29 '26 12:06 Kayaba-Attribution

I was going to add this but it needs clear UI and UX design before we add it in so people can use easily. Nice work but we need to spend a lot of time on this :(

altic-dev avatar Jul 01 '26 04:07 altic-dev

Sounds like something thats probably better if baked into the post processing. Larger models can obviously do this well but getting this into Fluid-1 would be a good win.

Resolving this PR for now, please open a discussion thread and we can discuss more and revisit this PR if necessary.

grohith327 avatar Jul 10 '26 01:07 grohith327