Repository navigation
fix(app): keep the vocabulary list when it failed to load - #22309
Conversation
Saving custom vocabulary sends the whole list and the server replaces its copy with it. When the list failed to load at startup (offline, a timeout, a server error, or a failed profile read before it), the provider kept the cached copy, which is empty after a reinstall or sign-out and out of date after edits on web or desktop. Adding a word then saved just that word, or the stale list plus it, and the other saved words were lost. Track whether the list came from the server. Before an add or a remove, load it if it has not loaded yet; if it still can't be read, save nothing. The preferences read and the vocabulary write are injectable so the regression test can drive both. 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 — approved. This closes a real data-loss path: PATCH /v1/users/transcription-preferences replaces the whole server-side vocabulary (set_user_transcription_preferences sets transcription_preferences.vocabulary wholesale), so an add or remove built from a stale or empty cached list wiped the saved words with no error.
- app/lib/providers/user_provider.dart — _transcriptionVocabularyLoaded plus _loadVocabularyBeforeEdit() gate both addVocabularyWords and removeVocabularyWord: while the list can't be read, nothing is saved, which is the same invariant the web app took in #15244. I checked for a bypass — nothing else calls updateTranscriptionVocabulary directly — and clearUserData() resets the flag, so the next sign-in re-establishes server truth before the next edit. The generation guard also keeps a stale session from writing after a sign-out.
- app/test/providers/user_provider_vocabulary_test.dart — the four tests cover the regression matrix (blocked add, blocked remove, load-then-save including the no-refetch-after-load assertion, and reload after clearUserData). These would have caught the original bug.
- app/changelog/unreleased/20261019-vocabulary-load-failure.json — accurate, user-facing wording.
UX: a blocked edit now behaves like any other failed save — the word isn't added / the chip reverts — consistent with the existing treatment of failed writes; the extra fetch rides the existing isUpdatingVocabulary spinner state. Blast radius: confined to Custom Vocabulary editing; the startup load path is unchanged.
Non-blocking, optional: when an edit is blocked because the list can't be loaded, the page gives no explicit feedback (this matches the pre-existing pattern for failed saves) — a small error SnackBar would make that failure legible. Good follow-up material, not something to hold this fix for.
USER IMPACT: adding or removing a word while your saved vocabulary list couldn't be loaded no longer erases your other saved words — the edit just doesn't go through until the list can be read.
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: vocabulary list no longer saved as whole-list-wipe when it failed to load. CI green, tests added.
What changed and why
Fixes #22308
Custom Vocabulary saves the whole list: the app sends every word to
PATCH /v1/users/transcription-preferencesand the server replaces its list with it. The app reads that list once, at startup. If the read fails (offline at launch, a timeout, a server error, or the profile request before it failing, which skips the read),UserProviderkeeps the cached copy. That copy is empty after a reinstall or sign-out and out of date after edits on web or desktop. Adding a word then sent the cached list plus the word, so the server's list became just that word (or the stale list plus it) and the other saved words were gone, with no error. Removing a word had the same problem.UserProvidernow tracks whether the vocabulary came from the server this session. Sign-out resets it.transcriptionPreferencesFetcherandvocabularySetter, defaulting togetTranscriptionPreferencesandsetTranscriptionPreferences), like the private cloud sync and training data seams in the same provider.This is the same fix as #15244 on web: a list that failed to load must never be saved back as the whole list. Web disables adding until the list loads. Mobile retries the read at edit time instead, because it only reads at startup and one failed read would otherwise block edits until the app restarts.
Product invariants affected
none
How it was verified
AppShellcallsUserProvider.initializeonce after sign-in.initializecallsPrivacyApi.getUserProfile, which throws on failure, and only then_loadTranscriptionPreferences.getTranscriptionPreferencesreturnsnullon no response or a non-200, and the provider keeps the cached list.CustomVocabularyPage._addWordcallsaddVocabularyWords, which builds[...cached, word]and sends it throughsetTranscriptionPreferences(vocabulary:). The backend'sset_user_transcription_preferencesstoresvocabulary[:100]as the whole list. Web and macOS edit the same list.dart format --line-length 120(pinned Flutter SDK) on the changed files: no changes.ci:fullruns the new tests and the full app suites. I wrote the tests to fail without the fix: with only the new seams, the old add saves['omi']and the old remove saves[].Tests
app/test/providers/user_provider_vocabulary_test.dart, in the same style asuser_provider_training_data_test.dart:does not save an added word while the saved list cannot be loaded: the old code saved['omi'].loads the saved list before adding a word, so the saved words are kept: the first read fails and the next one works. The add saves['alpha', 'beta', 'omi'], and later edits don't read the list again.does not save a removal while the saved list cannot be loaded: the old code saved[].loads the list again after sign-out before saving.UI evidence
UI-Evidence: none -- no layout change, and no simulator or device here; the provider tests check what gets saved.
Failure class (fixes)
Failure-Class: none
🤖 Generated with Claude Code