Skip to content

fix(dictionary): accept Set/iterable snapshots and guard non-string words (#1880) - #1923

Open
dominikake wants to merge 1 commit into
OpenWhispr:mainfrom
dominikake:fix/agent-name-dictionary-iterables
Open

fix(dictionary): accept Set/iterable snapshots and guard non-string words (#1880)#1923
dominikake wants to merge 1 commit into
OpenWhispr:mainfrom
dominikake:fix/agent-name-dictionary-iterables

Conversation

@dominikake

Copy link
Copy Markdown

Summary

Fixes #1880. agentNameDictionaryChanges only accepted string[], so a Set or other iterable dictionary snapshot silently degraded to [] and wrongly suggested adding the name. findStoredWord also threw TypeError: word.toLowerCase is not a function on a non-string word.

  • agentNameDictionaryChanges now coerces arrays, Sets, and other iterables to a word list (strings and non-iterables degrade to [] without throwing).
  • findStoredWord guards against non-string word (returns undefined).
  • Added unit tests for Set, Map-key iterator, non-iterable, and non-string-element inputs, plus a findStoredWord non-string guard.

Verification

  • node --import tsx --test "test/helpers/agentNameDictionary.test.js" → 21 passing
  • npm run quality-check → passes (format + typecheck)
  • npm run i18n:check → passes

This supersedes the failing PR #1881 with an equivalent fix that is prettier-clean.

🤖 Generated with OpenCode

…ords in agentNameDictionary (OpenWhispr#1880)

Issue OpenWhispr#1880: agentNameDictionaryChanges only accepted arrays, so a Set or
other iterable dictionary silently degraded to [] and wrongly suggested adding
the name. findStoredWord also threw on a non-string word.

- Coerce arrays, Sets, and other iterables to a word list (excluding strings);
  degrades other inputs to [] without throwing.
- Guard findStoredWord against non-string words (returns undefined).
- Add unit tests for Set, Map-key, and non-iterable inputs, plus a
  findStoredWord non-string guard.
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.

agentNameDictionaryChanges ignores Set/iterable dictionaries and findStoredWord throws on non-string word

1 participant