Repository navigation
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 <[email protected]>
|
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
|
Update on the stack: #10097 merged (2026-07-21), so the "stacked on an unmerged base" concern is resolved — this PR now stands on its own two commits against The refactor still looks right:
One minor note (not blocking): the second commit bundles a one-line fix to Leaving formal approval to a human maintainer per 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 need human response — kodjima33 approved, and #10097 (the base) is now merged, so this stands on its own two commits against main. Ready for a maintainer to merge. |
|
@Git-on-my-level need human response — this PR is approved, rebased onto latest |
…on (#10074) (#10170) # Summary The regression test #10100 deferred. #10100 fixed the quick-template sheet so a failed install is surfaced as an **error** instead of a false success (#10074), but shipped **without a regression test** — the decision lived inline in the widget's post-`await` branch, unreachable by a hermetic test without a full widget harness (five stubbed API calls plus `path_provider` platform channels). This extracts **only that decision** — the success/error polarity of the terminal outcome — into `templateCreationOutcomeIsError`, a pure function the sheet now derives its install-branch snackbar from. Everything else is byte-identical to #10100. - New `TemplateCreationOutcome` enum + `templateCreationOutcomeIsError` (one pure file, no Flutter deps). - The sheet's install branch sources its success/error choice from the classifier instead of an inline `bool`; the arm order flips (error-first) but the behavior is identical. - Unit tests pin the full outcome table, including `installFailed → error` — the #10074 guarantee — so the failed-install-reads-as-success regression cannot be silently reintroduced. ## Behavior identity (verified line-by-line) Diff is the import line + the install-branch arm-swap; **nothing else in `_createTemplate` changed**. Confirmed unchanged vs the #10100 baseline: `quickTemplateCreated` analytics timing (still fires on submit success, before install), `getApps()` ordering (still before install), the `if (mounted && createdApp != null)` gating (so a mid-flow sheet dismissal still cancels install exactly as before), the `createdWithoutInstall`/`submitFailed` branches, and the catch block. - `success → installed → not error → appCreatedAndInstalled + summarized-apps sheet` - `!success → installFailed → error → failedToInstallApp` (provider already showed its dialog) ## Failure class Failure-Class: none `test:` commit — adds the regression coverage a prior `fix:` (#10100) deferred; no new triggering defect. ## Product invariants affected none (verified with `scripts/pr-preflight --suggest`) ## Validation - Five hermetic unit tests (`app/test/unit/template_creation_outcome_test.dart`) pin the table: `installFailed → true` and `submitFailed → true` (errors); `installed → false` and `createdWithoutInstall → false` (success); plus an exhaustiveness assertion that exactly `{submitFailed, installFailed}` read as errors. Each calls the exact function production calls — flipping the classifier fails the test. - **Not run locally — no Flutter SDK on this machine** (same stated constraint as #10097/#10100/#10126, all merged/approved); tests are hermetic and the app CI lane runs them. - Behavior identity and analyzer-cleanliness (imports used, exhaustive switch, no `use_build_context_synchronously` regression, `createdApp.name` non-null promotion intact) independently reviewed against the #10100 baseline before opening. - `make preflight` (local lane, this PR body) → all selected checks pass. ## Out of scope, named - The `submitFailed`/`createdWithoutInstall` outcomes are classified and tested but the sheet's other two branches still snackbar inline (they were never the #10074 surface and have a single, unconditional polarity). Routing them through the classifier too would be ceremony, not safety. - A broader flow-orchestration extraction was considered and dropped: it drifted analytics timing, `getApps()` ordering, and mid-dismiss install behavior for no gain over this focused pin. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10170?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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).