refactor(app): trust the server's single_language_mode, drop the client mirror (after #10097)#10126
Conversation
…nt mirror Follow-up to BasedHardware#10097, doing what its out-of-scope note and review both pointed at: PATCH /v1/users/language already returns the single_language_mode the server derived from the live STT capability policy, so the client list mirroring MODULATE_SUPPORTED_LANGUAGES — and the drift risk that comes with every future policy change — is deleted. setUserPrimaryLanguage now returns the server-decided mode (null on failure) and updateUserPrimaryLanguage syncs local state from that response. No eligibility decision remains client-side. The mirror's unit test is replaced by a wire-contract test pinning that the response carries single_language_mode and fails loudly when absent — the property that makes trusting the server safe. Not run locally (no Flutter SDK on this machine); hermetic, app CI lane compiles and runs it. Depends on BasedHardware#10097 (stacked on its branch). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Clean refactor — trusting the server's Quick notes for the maintainer:
Leaving for human maintainer review given the stack dependency and the product-level multilingual-eligibility policy. No changes requested on this PR's own commit. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level Noted. We'll wait for #10097 to merge first. |
- primary_language_widget.dart: capture the bool result of updateUserPrimaryLanguage(); show a failure snackbar and block navigation on false instead of silently ignoring errors - test_ws_b_short_term_lifecycle.py: replace frozen datetime(2026, 6, 20, ...) with datetime.now(timezone.utc)
|
Thanks. Confirmed — this is stacked on #10097; merge that first and this collapses to the single app-side commit. |
…lient-language-mirror # Conflicts: # app/lib/providers/home_provider.dart
Summary
Follow-up to #10097, doing exactly what its out-of-scope note and Git-on-my-level's review both pointed at: the client-side mirror of
MODULATE_SUPPORTED_LANGUAGESis deleted, and the app trusts thesingle_language_modethe server already returns fromPATCH /v1/users/language.setUserPrimaryLanguagenow returns the server-decided mode (bool?, null on any failure) instead of discarding the parsed field;updateUserPrimaryLanguagesyncs local state from that response.Why now
#10097 made the mirror byte-for-byte correct; the review verified that equality manually. That manual verification is exactly the maintenance burden this removes: the wire response is the contract, so the list and its normalization helper go away entirely.
Failure class
Failure-Class: none
This PR's own commit is a
refactor:with no triggering defect; the declaration covers the stacked #10097fix:commit in this diff range (same call as #10097's own body — divergent read-side policy copies, no registered class).Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Validation
app/test/unit/language_update_response_test.dart): the response carriessingle_language_mode, both values round-trip, and a response missing the field fails loudly instead of defaulting — the property that makes trusting the server safe.setUserPrimaryLanguagehas exactly one consumer (updateUserPrimaryLanguage);supportsLiveMultilingualMode/multiLanguageSupportedhave zero remaining references after deletion.make preflight(local lane, this PR body) → all selected checks pass.Out of scope, named
single_language_modestate updates only on a successful server response — identical to today's behavior for the persisted preference (the server was already the only writer of the durable value; the mirror only fed optimistic local state).