Skip to content

refactor(app): trust the server's single_language_mode, drop the client mirror (after #10097)#10126

Open
aryanorastar wants to merge 3 commits into
BasedHardware:mainfrom
aryanorastar:refactor/10022-drop-client-language-mirror
Open

refactor(app): trust the server's single_language_mode, drop the client mirror (after #10097)#10126
aryanorastar wants to merge 3 commits into
BasedHardware:mainfrom
aryanorastar:refactor/10022-drop-client-language-mirror

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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_LANGUAGES is deleted, and the app trusts the single_language_mode the server already returns from PATCH /v1/users/language.

  • setUserPrimaryLanguage now returns the server-decided mode (bool?, null on any failure) instead of discarding the parsed field; updateUserPrimaryLanguage syncs local state from that response.
  • No eligibility decision remains client-side — future policy changes (new languages, provider swaps) reach the app with zero client releases and zero drift risk.
  • Stacked on fix(users): gate multi-language mode by the live STT capability policy #10097 (its branch is the base of this diff; merge it first — this PR then shows only the one commit).

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 #10097 fix: 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

  • The mirror's unit test is replaced by a wire-contract test (app/test/unit/language_update_response_test.dart): the response carries single_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.
  • Not run locally — no Flutter SDK on this machine (same stated constraint as fix(users): gate multi-language mode by the live STT capability policy #10097/fix(app): stop reporting a failed template install as success #10100, both since approved/merged); the test is hermetic and the app CI lane compiles and runs it.
  • Call-site sweep: setUserPrimaryLanguage has exactly one consumer (updateUserPrimaryLanguage); supportsLiveMultilingualMode/multiLanguageSupported have zero remaining references after deletion.
  • make preflight (local lane, this PR body) → all selected checks pass.

Out of scope, named

  • Offline-set language: with no client list, local single_language_mode state 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).

Review in cubic

…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>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Git-on-my-level

Copy link
Copy Markdown
Collaborator

Clean refactor — trusting the server's single_language_mode response and deleting the client-side 19-locale mirror is the right direction. Single source of truth eliminates the drift risk on every future STT policy change, and the wire-contract test (fails loudly instead of defaulting when the field is absent) pins exactly the property that makes that trust safe.

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 need human response.

@aryanorastar

Copy link
Copy Markdown
Contributor Author

@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)
@aryanorastar

Copy link
Copy Markdown
Contributor Author

Thanks. Confirmed — this is stacked on #10097; merge that first and this collapses to the single app-side commit. updateUserPrimaryLanguage is the only consumer of the new bool? return and handles the null (failure) path, and the wire-contract test pins that the response carries single_language_mode.

…lient-language-mirror

# Conflicts:
#	app/lib/providers/home_provider.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants