Skip to content

Redact text shortcut expansions only as whole words - #302

Merged
alexkroman merged 1 commit into
AssemblyAI:mainfrom
rupokghosh:fix/shortcut-redaction-whole-words
Nov 5, 2026
Merged

alexkroman merged 1 commit into
AssemblyAI:mainfrom
rupokghosh:fix/shortcut-redaction-whole-words

Conversation

@rupokghosh

Copy link
Copy Markdown
Contributor

What changed

  • when blurt puts pasted shortcut expansions in the text before the cursor back to their triggers (before it goes out as stt_prompt), it now only matches whole words, the same rule expand already uses
  • the clipped expansion check at the start of the text only counts a tail that ends a word
  • expansions next to punctuation are still redacted, for example "Rupok's" and "(me@example.com)."

Why

redaction used a plain find and replace, so a short expansion matched inside other words. with "thumbs" -> "ok", "I booked a token for the joker" was sent as "I bothumbsed a tthumbsen for the jthumbser". the pasted text was never affected, but the context meant to help the transcript was garbled.

one trade-off: "Rupoks" (no apostrophe) is now left as is, so it is not redacted. this matches how expand treats word boundaries.

Fixes #301

How it was tested

  • new tests in TextShortcutTests for the cases above. two of them fail on main and pass with this change
  • swift test passes (1218 tests) and swift format lint --strict is clean on both files
  • scripts/mutate.sh --files Sources/BlurtEngine/Pipeline/TextShortcuts.swift kills 10 of 10 mutants
  • checked the real stt_prompt against the live dictation api with a small harness, before and after
  • i did not run the full scripts/check.sh locally, so CI is the source of truth for the rest

redactingExpansions puts pasted expansions in the text before the cursor
back to their triggers before it rides stt_prompt. It used a plain
replacingOccurrences, so a short expansion also matched inside other
words: with "thumbs" -> "ok", "I booked a token for the joker" went out
as "I bothumbsed a tthumbsen for the jthumbser". The pasted text was
never affected, only the context meant to prime the transcript.

Redaction now follows the whole-word rule expand already uses: an
expansion that starts or ends with a letter or digit never matches
inside a longer word, so "Rupok's" and "(me@example.com)." are still
caught. The clipped-expansion check at the start of the text only counts
a clip that ends a word, so "Rupok Ghosh" no longer turns "k Ghoshal"
into "my nameal". The trigger is inserted as a literal template.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@alexkroman
alexkroman enabled auto-merge (squash) November 5, 2026 01:14
@alexkroman
alexkroman merged commit c078b1f into AssemblyAI:main Nov 5, 2026
12 checks passed
@rupokghosh
rupokghosh deleted the fix/shortcut-redaction-whole-words branch November 5, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text shortcut redaction replaces expansions inside other words

2 participants