Repository navigation
fix(app): keep typed vocabulary words when saving them fails - #22354
Conversation
The Custom Vocabulary page cleared the text field before calling addVocabularyWords and ignored a false result, so when the save failed (offline, a server error, the list busy with a removal) the typed words were gone and nothing said the save had failed. The field now clears once the words are saved. A failed save keeps them in the field and shows the existing "Failed to save. Please check your connection." error. A false result with every word already in the list still clears the field without an error, since there was nothing new to save. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
The production change here is correct and nicely scoped — this fixes a real data-loss UX bug, and I'm approving.
- app/lib/pages/settings/custom_vocabulary_page.dart —
_addWordnow clears the field only after the awaited save is known to have succeeded, with a correctmountedguard after the await. The!success && !words.every(userProvider.transcriptionVocabulary.contains)check cleanly separates a failed save from 'every word was already in the list':addVocabularyWordsfilters out words already in the list before callingupdateTranscriptionVocabulary, so on afalsereturn theeverycheck matches the provider's dedup exactly. Double-submit stays prevented because the field and Add button are disabled whileisUpdatingVocabulary. - app/test/pages/settings/custom_vocabulary_page_test.dart — both branches of the heuristic are covered (failed save keeps the text and shows the error; all-duplicate input clears silently). Hermetic via the SharedPreferences mock; no prior custom-vocabulary page test existed, so no duplication.
- app/changelog/unreleased/20261019-vocabulary-typed-words.json — user-facing change gets a fragment in the dated-JSON convention of its neighbors, and reusing
failedToSaveCheckConnection(already used at 5+ call sites) means no new strings. - app/e2e/flows/custom-vocabulary.yaml — the S4 note now describes when the field clears instead of the stale 'clears immediately'.
UX: users keep their typed words when a save fails and can retry with one tap; the duplicate-word case still clears silently as before.
USER IMPACT: If saving custom vocabulary words fails (offline or server error), the words now stay in the input and an error message appears, instead of silently disappearing.
Nice-to-have, not blocking: a test variant where the save fails with only some typed words already in the list (mixed input) — the behavior follows from the code, but it's the one untested combination.
This review was produced by an AI reviewer operating on behalf of the maintainers.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Mobile bug fix, confidence 5/5: keeps typed vocabulary words on save failure instead of silently dropping them. CI green, tests added.
What changed and why
Fixes #22353
On Custom Vocabulary,
_addWordcleared the text field before it calledUserProvider.addVocabularyWords, and did nothing when that returnedfalse. When the save failed (offline, a server error, or the list still busy with a removal), the words the user typed were gone and nothing said the save had failed; the only sign was that no chips appeared.failedToSaveCheckConnection, already in every locale), so tapping Add again retries. No new strings.addVocabularyWordsalso returnsfalsewhen every typed word is already in the list. That still clears the field without an error: after the call the page checks whether all the words are in the list.app/e2e/flows/custom-vocabulary.yaml) said the field clears immediately; it now says when it clears.This is the page side only. #22309 (open) fixes the provider so an add no longer overwrites the saved list when that list failed to load; in that case
addVocabularyWordsreturnsfalse, which this page now reports instead of dropping the words. The two PRs change different files.Product invariants affected
none. INV-UI-3 covers
app/lib/**; the error goes throughOmiFeedback.erroras the UX contract asks, and no primitive changes.How it was verified
_addWord, which callsaddVocabularyWords. That returnsfalsewithout saving when every word is already in the list, and otherwise returns whatupdateTranscriptionVocabularyreturns:falsewhile another vocabulary update is running, whensetTranscriptionPreferencesgets no response, a non-200 or a status other thanok, or when it throws. Onfalsethe provider leaves the list unchanged. The field's submit stays active while a batch of removals is saving (only the Add button is disabled then), which is how the "busy" case is reached.dart format --language-version=3.0 --line-length 120(pinned Flutter SDK) on the changed Dart files: no changes.check_mobile_ux_contract.py,check_brand_ui.py,check_mobile_ui_isolate.py,mobile-changelog.py validateandcheck-mobile-changelog.pypass locally.ci:fullruns the new tests and the full app suites. I wrote the first test to fail on main, where the field is already empty when the save fails and no error shows.Tests
app/test/pages/settings/custom_vocabulary_page_test.dartpumps the real page with aUserProvidersubclass whoseaddVocabularyWordsanswersfalse, types "Omi, Callie" and taps Add:a failed save keeps the typed words and shows an error: the field still holds "Omi, Callie" and the save-failure error shows. Fails on main.words already in the list clear the field without an error: with both words already saved, the field clears and no error shows.UI evidence
UI-Evidence: none -- no layout change, and no simulator or device here; the widget test checks the field and the error toast after a failed save.
Failure class (fixes)
Failure-Class: FC-refused-mutation-bool-confirmed-as-success
Same contract as #21089: a caller of a bool-returning save treats
falseas the failure path, keeps the user's input and shows the existing error.🤖 Generated with Claude Code