Skip to content

fix(app): keep typed vocabulary words when saving them fails - #22354

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/app-vocab-keep-typed-words
Oct 19, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/app-vocab-keep-typed-words

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #22353

On Custom Vocabulary, _addWord cleared the text field before it called UserProvider.addVocabularyWords, and did nothing when that returned false. 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.

  • The field now clears only once the words are saved. After a failed save the words stay in the field and the page shows the existing "Failed to save. Please check your connection." error (failedToSaveCheckConnection, already in every locale), so tapping Add again retries. No new strings.
  • addVocabularyWords also returns false when 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.
  • The e2e flow note for this step (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 addVocabularyWords returns false, 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 through OmiFeedback.error as the UX contract asks, and no primitive changes.

How it was verified

  • Read the flow: the Add button and the field's submit both call _addWord, which calls addVocabularyWords. That returns false without saving when every word is already in the list, and otherwise returns what updateTranscriptionVocabulary returns: false while another vocabulary update is running, when setTranscriptionPreferences gets no response, a non-200 or a status other than ok, or when it throws. On false the 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 validate and check-mobile-changelog.py pass locally.
  • I did not run the tests locally. CI with ci:full runs 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.dart pumps the real page with a UserProvider subclass whose addVocabularyWords answers false, 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 false as the failure path, keeps the user's input and shows the existing error.

🤖 Generated with Claude Code

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]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — _addWord now clears the field only after the awaited save is known to have succeeded, with a correct mounted guard after the await. The !success && !words.every(userProvider.transcriptionVocabulary.contains) check cleanly separates a failed save from 'every word was already in the list': addVocabularyWords filters out words already in the list before calling updateTranscriptionVocabulary, so on a false return the every check matches the provider's dedup exactly. Double-submit stays prevented because the field and Add button are disabled while isUpdatingVocabulary.
  • 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 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mobile bug fix, confidence 5/5: keeps typed vocabulary words on save failure instead of silently dropping them. CI green, tests added.

@kodjima33
kodjima33 merged commit 584ee2b into BasedHardware:main Oct 19, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile Custom Vocabulary: words you type disappear with no error when adding them fails

3 participants