Repository navigation
fix(app): stop reporting a failed template install as success - #10100
Conversation
Creating a summary template from a conversation called enableAppServer directly and ignored its result: on failure the sheet still showed 'App created and installed!', opened the summarized-apps picker, and let the user set the never-enabled template as their default — the app-side half of BasedHardware#10074 (the server-side honor fix landed in BasedHardware#10078). The sheet now installs through AppProvider.toggleApp — the existing owner of enable/disable, which already reverts prefs/app-list state and shows the failure dialog — and reports the real outcome: success keeps the current flow, failure shows 'Failed to install {app}' instead of a false success, and the created-but-not-installed template stays visible in the store to retry. toggleApp now returns whether the toggle stuck (all existing callers ignore the return, unchanged). Not run locally (no Flutter SDK on this machine): change is confined to the sheet's install branch and a Future<void>->Future<bool> provider signature; app CI lane compiles and analyzes it. Failure-Class: none 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. |
|
Thanks @aryanorastar — this is a clean, well-scoped fix. Routing the create-template install through Quick review notes:
One ask before this lands: a small widget/unit test covering the failed-install branch (the exact regression this PR fixes), so the false-success path cannot silently return. Added Not approving formally (human maintainer sign-off on the UX/string choice), but this looks good to merge once a regression test is added. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Reviewed by automated PR reviewer — scoped, correct, CI acceptable. Approving + merging.
Follow-up to #10100 which changed toggleApp from Future<void> to Future<bool> routed the create-template sheet through it. The reviewer requested a test covering the failure path so the false-success regression cannot return silently. Adds a minimal test seam (enableAppOverride) to AppProvider to allow mocking enableAppServer without a mocking library. Test: app/test/providers/app_provider_toggle_test.dart - toggleApp returns false when enableAppServer fails - toggleApp returns true when enableAppServer succeeds
Follow-up to #10100 which changed toggleApp from Future<void> to Future<bool> routed the create-template sheet through it. The reviewer requested a test covering the failure path so the false-success regression cannot return silently. Adds a minimal test seam (enableAppOverride) to AppProvider to allow mocking enableAppServer without a mocking library. Test: app/test/providers/app_provider_toggle_test.dart - toggleApp returns false when enableAppServer fails - toggleApp returns true when enableAppServer succeeds
…10121) # Summary Adds a regression test for the failed-install branch that PR #10100 fixed. The PR changed `toggleApp` from `Future<void>` → `Future<bool>` and routed the create-template sheet through it. The reviewer [requested](#10100 (comment)) a test covering the failure path so the false-success regression cannot silently return. # Changes ## `app/lib/providers/app_provider.dart` (+10/-3) Adds two minimal test seams: | Seam | Purpose | |------|---------| | `enableAppOverride` | Mocks `enableAppServer` in tests for the failed-install branch | | `disableAppOverride` | Mocks `disableAppServer` for the disable path | Both fall through to the real functions when null — existing callers unaffected. ## `app/lib/utils/alerts/app_dialog.dart` (+3/-1) Makes `AppDialog.show()` null-safe: returns early when no navigator is mounted. Prevents a hard crash on the failure path in edge-case production scenarios and in tests without a widget tree. ## `app/test/providers/app_provider_toggle_test.dart` (new, ~85 lines) Three tests, all pure `test()` (no widget tree needed): | Test | What it covers | |------|---------------| | `returns false when enableAppServer fails (regression guard)` | The exact regression #10100 fixed — `toggleApp` must surface failure to its caller | | `returns true when enableAppServer succeeds` | Happy path — the override is plumbed correctly and success propagates | | `does not call enableAppOverride when disabling` | Disable path uses its own override, not the enable one | # Verification ``` $ flutter test test/providers/app_provider_toggle_test.dart 00:00 +3: All tests passed! ``` Existing provider tests also pass (no regressions): ``` $ flutter test test/widget_test.dart test/providers/add_app_provider_test.dart 00:00 +20: All tests passed! ``` pre-push checks: 10/10 passed.
…on (BasedHardware#10074) BasedHardware#10100 fixed the quick-template sheet so a failed install is reported as an error instead of a false success, but shipped without a regression test: the decision was inline in the widget's post-await branch, which a hermetic test can't reach without a full widget harness (five stubbed API calls plus path_provider 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. Orchestration, analytics timing, getApps ordering, and the mounted gating are all byte-identical to BasedHardware#10100; the only change is that the install branch sources its success/error choice from the tested classifier instead of an inline bool, so the failed-install-reads-as-success regression cannot be silently reintroduced. Tests pin the full outcome table, including installFailed -> error (the BasedHardware#10074 guarantee) and installed/createdWithoutInstall -> success. Pure unit tests, no widget pumping, no plugin channels. Not run locally (no Flutter SDK on this machine); hermetic, app CI lane runs them. Co-Authored-By: Claude Fable 5 <[email protected]>
…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. -->
…nt mirror (after #10097) (#10126) # 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 #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 #10097/#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). <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10126?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
AppProvider.toggleApp— the existing owner of enable/disable — and reports the real outcome: on failure the user seesFailed to install {app}. Please try again.(existing l10n string) plus the provider's standard error dialog, instead of a false success and the summarized-apps picker.AppProvider.toggleAppnow returnsFuture<bool>(whether the toggle stuck). All existing callers ignore the return value and are source-compatible unchanged.App-side half of #10074; the server-side honor fix landed in #10078's scope (preferred app admitted by the setter is now honored at generation time). This closes the flow that created the never-enabled default in the first place.
Root cause
create_template_bottom_sheet.dartcalled the rawenableAppServerAPI and ignored its result (if (success)with no else): a failed enable still showed the success snackbar, opened the picker, and let the user set the never-enabled template as default. MeanwhileAppProvider.toggleApp— used by every other enable surface — already handles the failure path (error dialog, no false local state). Classic sibling-caller divergence; the fix routes the sheet through the shared owner instead of patching the raw call site.Failure class
Failure-Class: none
No registered class covers a UI flow reporting success for a failed side effect; the nearest theme (one authoritative owner per decision) is the shape of the fix, not a registered class.
Validation
Future<void>→Future<bool>signature widening; the app CI lane compiles, analyzes, and runs the app test suite over it.getGeneratedDescriptionAndEmoji,submitAppServer,getAppDetailsServer, plus enable) with no injection seams, and the repo's app tests have no network-mocking harness for them. Introducing that seam is a refactor beyond this fix's scope; the change instead reduces untested surface by deleting a raw API call site in favor of the provider path that every other enable surface already exercises.toggleAppcall sites (chat/page.dart,apps/list_item.dart) — all ignore the return value;app_detail.dartuses its own wrapper, untouched.Out of scope, named