A snippet is skipped whenever its expansion appears inside any word of the dictation: "Ops" is switched off by "stopsign"

Open Beginner friendly
#716 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Under an hour
Newbie friendliness
92/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
macos, swift
Domain
desktop

Research direction

Start in Sources/UttrflowAI/SnippetExpander.swift:20-56, comparing the quoting check with Surroundings.repeats in Sources/UttrflowContext/Surroundings.swift. Add the regression to Tests/UttrflowAITests/SnippetExpanderTests.swift and run make verify after setting DEVELOPER_DIR. Done means expansions inside larger words no longer suppress snippets, while existing quoting tests still pass.

Written by the indexing model from the issue text.

Description

area:dictation bug good first issue P2

What happens

SnippetExpander.expand skips a snippet when the dictation already "quotes" its expansion (Sources/UttrflowAI/SnippetExpander.swift:26-27):

let spoken = TextTidy.collapseWhitespace(transcript).lowercased()
let eligible = candidates.filter { !spoken.contains($0.quoted) }

contains is a plain substring test, so an expansion found inside any other word switches the snippet off for that whole dictation. The trigger matching next to it is careful about word boundaries (fits, :66-92); this check is not.

Measured with a throwaway test in UttrflowAITests:

Snippet Dictation Expected Actual
my teamOps Ask my team about the rollout. Ask Ops about the rollout. Ask Ops about the rollout.
my teamOps Ask my team about the stopsign rollout. Ask Ops about the stopsign rollout. unchanged (stopsign contains ops)
sigBest That is the bestseller, sig That is the bestseller, Best unchanged (bestseller contains best)

Why it matters

Short expansions (a team handle, initials, a short code) are common, and they are the ones most likely to sit inside an ordinary word. The snippet then fails without any sign, in some dictations and not others, which is hard for anyone to work out.

How to reproduce

Add to Tests/UttrflowAITests/SnippetExpanderTests.swift:

let expander = SnippetExpander(snippets: [makeSnippet(trigger: "my team", expansion: "Ops")])
#expect(expander.expand("Ask my team about the stopsign rollout.").text
    == "Ask Ops about the stopsign rollout.")

Acceptance criteria

  • The quoting check matches the expansion only on word boundaries (letters or digits must not continue it on either side), so it still holds back My address is <expansion>, as you know. and the case- and spacing-insensitive cases in quotingIsRecognisedLoosely.
  • The two rows above expand; the existing quoting tests still pass.

Where to start

  • Sources/UttrflowAI/SnippetExpander.swift:20-56; Surroundings.repeats in Sources/UttrflowContext/Surroundings.swift already has a whole-word substring check that shows the shape.
  • Tests: Tests/UttrflowAITests/SnippetExpanderTests.swift (the "Never expanding what the user is quoting" section).
  • Run make verify (export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer first) and read CONTRIBUTING.md.

Size: S, about an hour.

Dominant language
Swift
Stars
4
Forks
17
Avg merge
18h 15m
Merged PRs (30d)
442

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uttrflow/uttrflow-swift

All issues in uttrflow/uttrflow-swift

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.