Skip to content

feat(app): recover declined renewals from Home - #23953

Merged
kodjima33 merged 17 commits into
mainfrom
mux/2026-10-29-card-declined
Nov 5, 2026
Merged

kodjima33 merged 17 commits into
mainfrom
mux/2026-10-29-card-declined

Conversation

@kodjima33

@kodjima33 kodjima33 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

52 of 265 monthly churns (19.6%) were failed payments in the proposal's 30-day Stripe analysis. The app only exposes active/inactive subscription state, while a failed Stripe renewal becomes Basic. Home gives the reader no way to see or fix the failed payment.

Change

Show the approved Home row below Home / Tasks and above Today: a red dot, “Your card was declined”, “Update it to get Omi Pro back”, and a black Update pill. At large accessibility text sizes the action moves below the copy. It opens the existing Stripe-hosted customer billing portal. Refresh the subscription on return so a paid invoice removes the row.

The backend adds optional payment_issue {status, plan} only on iOS/Android for a recoverable past_due/unpaid renewal with an open, attempted invoice, billing_reason=subscription_cycle and money remaining. Failed plan changes (subscription_update), new subscriptions and missing billing reasons are excluded. Recovery reuses the Stripe subscription already read by reconciliation, so it never makes a second subscription lookup. Desktop/web do not read recovery invoices. An expired stored billing period still checks Stripe for a payable renewal. Chosen cancellations, ended trials, hidden billing UI and non-Omi prices stay excluded. Entitlement handling and the active/inactive enum stay unchanged. All locales include the new copy through scripts/l10n.py.

Impact estimate

Churn 10.5% → ~9.8% (modeled: recover ~40% of 52 monthly involuntary churns)

Basis: ACTUAL, proposal analysis: 52 failed-payment churns out of 265 monthly churns. MODELED: 40% recovery, about 21 subscriptions/month. The 10.5% baseline and approximate 9.8% target are the supplied proposal estimate; no new live metric query was run. Home reach and actual recovery are unmeasured.

Money review

Verdict: no charge path. Recovery reuses reconciliation's existing subscription snapshot and only retrieves the latest invoice for a mobile past_due/unpaid reader. Update creates the same customer-portal session as Plans & Billing; card entry and payment happen on Stripe's page. No charge, retry, cancel, price, coupon, entitlement or schedule change is added. No PostHog flags or live state changed.

Reviewed against ~/mobile-ux-agent/runs/2026-10-29/money-review-p4.md. Simulator portal content and paid-state transitions use the offline loopback Stripe stub, not live Stripe.

Evidence

Before and after

Portal, paid state, dark, largest text, locales and error evidence

Main: same past_due month-2 payer, Home has no payment recovery row

Past_due payer: approved Home row above Today with Update

The payment recovery row in dark mode

The row at the largest accessibility text size

Update opens the existing payment web view and offline billing portal

After the invoice is paid, the declined-card row is gone; the yearly offer shown here is inherited from main PR #23764

German localized payment recovery row

Japanese localized payment recovery row

Arabic right-to-left payment recovery row

Main at largest text: existing header, conversation and chat input overflows are outside this proposal

Money review

Verification details

User action Observed result
Same past_due payer on main Basic, no recovery row
Same payer on this branch One recovery row above Today with accurate get Pro back copy
Failed upgrade: open attempted $255.27 subscription_update invoice Backend returns no payment_issue; real Home row absent
Update, return unpaid, twice Portal opens; row remains both times
Third Update, paid invoice fixture, return App refresh is the first subscription read; Pro restored and row removed
Relaunch after paid Row stays absent
Portal failures (current hermetic widget regression) Error feedback retains the row; failed and HTTP error pages emit no portal-opened event
Money calls across three visits 3 portal sessions; 0 charge or subscription-change calls
Large text and locales Recovery copy and Update fit; German, Japanese and Arabic rendered

Full native recordings, short MP4/GIF, raw stub requests and per-step checks are under ~/mobile-ux-agent/runs/2026-10-29/p4/. The revised 20.48-second native video is round1/demo.mp4; round1/demo.gif is its animated preview. Raw requests, checks and visual inspection are under round1/.

Evidence uses an iPhone 17 Pro simulator, the real Flutter app and local backend, Firestore/Auth emulators and offline Stripe fixtures. BEFORE is main 92bff3c2d5 at the start of this run; AFTER uses source 4e7904d217 with the same past_due month-2 subscriber. The portal is an explicit offline stub.

At ship

Draft only. No rollout, release or flag change. Backend and app must both ship to expose the row. New app + old backend shows no row; older clients ignore the optional field. Three typed events are registered with an executable consumer: Subscription Payment Issue Shown, Subscription Payment Issue Update Tapped, and Subscription Payment Issue Portal Opened. Their names match the subscri ingestion keep rule. Shown deduplicates unchanged issue refreshes; portal-opened fires after the native page finishes loading, excluding blank, failed and HTTP error pages. No event claims payment recovery; use authoritative Stripe invoices for that outcome. No ingestion rule or flag was changed.

Tests

Review round 1: 578 backend tests and 16 app widget tests passed, one file per process:

  • Billing recovery decision: 44 passed, including renewal-only billing reasons and missing/foreign reconciliation snapshots. The four non-renewal cases failed before the fix.
  • Real subscription router plus real reconciliation: 19 passed. Call-count regressions failed before the fix; canceled former subscribers now use exactly one existing Subscription.retrieve on each of six platforms. Only iOS/Android past_due readers add Invoice.retrieve; desktop/web and hidden billing UI do not.
  • Related backend tests: subscription plans 69, lapsed-paid reconciliation 6, users router 327, BYOK security 43, subscription caches 70 passed.
  • Flutter 3.44.5 Home row: 13 passed, including accurate copy, largest text, exposure deduplication, duplicate taps, loaded-portal timing and portal failure.
  • Native payment web-view load callback: 3 passed; successful page reports once, about:blank and resource/HTTP failure pages do not report opened.
  • scripts/l10n.py check passes with pinned Flutter 3.44.5: 49 locales, 4350 keys. Static analysis of the changed Dart sources and tests reports no issues.
  • All 51 selected repository checks passed on source 4e7904d217, across the initial and resumed run. The two required line-count declarations were supplied, and localization was rerun with pinned Flutter after the resumed shell selected the machine's older SDK.
  • Native proof was refreshed on source 4e7904d217: light, dark, largest text, German/Japanese/Arabic, three loaded portal visits, paid refresh and relaunch. The raw 20.48-second MP4 ends with Pro restored and recovery absent. All non-GET stub calls were audited: 7 fixture-control POSTs and 3 existing billing-portal session POSTs; zero charge or subscription-change calls.
  • New capture tooling used the shared guarded lane, with an opt-in 180-second Firebase startup deadline after one Auth timeout. No live Stripe, flag, rollout or release action was taken. Push uses the authorized pre-push fallback after local gate work exceeded 20 minutes; all 51 selected checks passed.

Not verified

  • Real Stripe portal/card entry, real payment recovery and webhook timing. No real payment was attempted.
  • Physical iPhone and Android runtime. Evidence is an iPhone simulator with seeded accounts.
  • Production behavior, recovered churn and Home reach. This PR is a draft and is not deployed.
  • Known existing limitation: at the largest accessibility text size, main already overflows the Home/Tasks header, conversation rows and chat input. The new recovery row is fixed and tested at this size; those surrounding controls are outside this proposal. German also has a small existing bottom/input overflow.

Follow-up for Nik

Should past_due keep Pro during Stripe's retry window instead of dropping to Basic? This proposal preserves the current entitlement behavior.

Invariants

The shared OmiButton adds an opt-in pill shape for the approved Update control; its UX contract documents the option. No entitlement policy changed. The row uses Omi tokens, OmiButton, OmiFeedback and the existing payment web view; visibility is server-authorized. INV-UI-1, INV-UI-3 and INV-PERF-1 are preserved. The additive response preserves released-client compatibility.

Line-Count-Exception: backend/routers/users.py | 2767 -> 2772 | Share the existing reconciliation snapshot with mobile recovery without adding a second Stripe lookup.
Line-Count-Exception: backend/utils/subscription.py | 2237 -> 2242 | Return the already retrieved Stripe snapshot through an optional request-local output; preserve existing reconciliation callers.

Failure-Class: none
UI-Evidence: see the images above (.agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/)

GET /v1/users/me/subscription gains an optional payment_issue {status, plan}
when the stored Stripe subscription is past_due or unpaid with an open,
attempted invoice. Never for a chosen cancellation, an emailed-invoice
subscription, or a trial whose first charge failed. Read-only Stripe; no
URL travels in the response (clients use POST /v1/payments/customer-portal).
Omitted when absent, so released clients see an unchanged body. The
past_due to Basic entitlement is unchanged.
When the subscription answer carries payment_issue, Home shows a single
row above Today: red dot, "Your card was declined", "Update it to keep
<plan>", and Update. Update opens the existing Stripe billing portal
(POST /v1/payments/customer-portal) in the payment web view; on return the
subscription is fetched again, so a paid invoice removes the row. Hidden
when subscription UI is hidden. Copy in all 49 locales.
@kodjima33 kodjima33 added the mux-proposal Mobile UX improver (MUX) proposal; waits for Nik's ship label Oct 29, 2026
@mintlify

mintlify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Nov 5, 2026, 3:25 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

…eclined

# Conflicts:
#	app/lib/l10n/app_ar.arb
#	app/lib/l10n/app_be.arb
#	app/lib/l10n/app_bg.arb
#	app/lib/l10n/app_bn.arb
#	app/lib/l10n/app_bs.arb
#	app/lib/l10n/app_ca.arb
#	app/lib/l10n/app_cs.arb
#	app/lib/l10n/app_da.arb
#	app/lib/l10n/app_de.arb
#	app/lib/l10n/app_el.arb
#	app/lib/l10n/app_en.arb
#	app/lib/l10n/app_es.arb
#	app/lib/l10n/app_et.arb
#	app/lib/l10n/app_fa.arb
#	app/lib/l10n/app_fi.arb
#	app/lib/l10n/app_fr.arb
#	app/lib/l10n/app_he.arb
#	app/lib/l10n/app_hi.arb
#	app/lib/l10n/app_hr.arb
#	app/lib/l10n/app_hu.arb
#	app/lib/l10n/app_id.arb
#	app/lib/l10n/app_it.arb
#	app/lib/l10n/app_ja.arb
#	app/lib/l10n/app_kn.arb
#	app/lib/l10n/app_ko.arb
#	app/lib/l10n/app_localizations.dart
#	app/lib/l10n/app_localizations_ar.dart
#	app/lib/l10n/app_localizations_be.dart
#	app/lib/l10n/app_localizations_bg.dart
#	app/lib/l10n/app_localizations_bn.dart
#	app/lib/l10n/app_localizations_bs.dart
#	app/lib/l10n/app_localizations_ca.dart
#	app/lib/l10n/app_localizations_cs.dart
#	app/lib/l10n/app_localizations_da.dart
#	app/lib/l10n/app_localizations_de.dart
#	app/lib/l10n/app_localizations_el.dart
#	app/lib/l10n/app_localizations_en.dart
#	app/lib/l10n/app_localizations_es.dart
#	app/lib/l10n/app_localizations_et.dart
#	app/lib/l10n/app_localizations_fa.dart
#	app/lib/l10n/app_localizations_fi.dart
#	app/lib/l10n/app_localizations_fr.dart
#	app/lib/l10n/app_localizations_he.dart
#	app/lib/l10n/app_localizations_hi.dart
#	app/lib/l10n/app_localizations_hr.dart
#	app/lib/l10n/app_localizations_hu.dart
#	app/lib/l10n/app_localizations_id.dart
#	app/lib/l10n/app_localizations_it.dart
#	app/lib/l10n/app_localizations_ja.dart
#	app/lib/l10n/app_localizations_kn.dart
#	app/lib/l10n/app_localizations_ko.dart
#	app/lib/l10n/app_localizations_lt.dart
#	app/lib/l10n/app_localizations_lv.dart
#	app/lib/l10n/app_localizations_mk.dart
#	app/lib/l10n/app_localizations_mr.dart
#	app/lib/l10n/app_localizations_ms.dart
#	app/lib/l10n/app_localizations_nl.dart
#	app/lib/l10n/app_localizations_no.dart
#	app/lib/l10n/app_localizations_pl.dart
#	app/lib/l10n/app_localizations_pt.dart
#	app/lib/l10n/app_localizations_ro.dart
#	app/lib/l10n/app_localizations_ru.dart
#	app/lib/l10n/app_localizations_sk.dart
#	app/lib/l10n/app_localizations_sl.dart
#	app/lib/l10n/app_localizations_sr.dart
#	app/lib/l10n/app_localizations_sv.dart
#	app/lib/l10n/app_localizations_ta.dart
#	app/lib/l10n/app_localizations_te.dart
#	app/lib/l10n/app_localizations_th.dart
#	app/lib/l10n/app_localizations_tl.dart
#	app/lib/l10n/app_localizations_tr.dart
#	app/lib/l10n/app_localizations_uk.dart
#	app/lib/l10n/app_localizations_ur.dart
#	app/lib/l10n/app_localizations_vi.dart
#	app/lib/l10n/app_localizations_zh.dart
#	app/lib/l10n/app_lt.arb
#	app/lib/l10n/app_lv.arb
#	app/lib/l10n/app_mk.arb
#	app/lib/l10n/app_mr.arb
#	app/lib/l10n/app_ms.arb
#	app/lib/l10n/app_nl.arb
#	app/lib/l10n/app_no.arb
#	app/lib/l10n/app_pl.arb
#	app/lib/l10n/app_pt.arb
#	app/lib/l10n/app_ro.arb
#	app/lib/l10n/app_ru.arb
#	app/lib/l10n/app_sk.arb
#	app/lib/l10n/app_sl.arb
#	app/lib/l10n/app_sr.arb
#	app/lib/l10n/app_sv.arb
#	app/lib/l10n/app_ta.arb
#	app/lib/l10n/app_te.arb
#	app/lib/l10n/app_th.arb
#	app/lib/l10n/app_tl.arb
#	app/lib/l10n/app_tr.arb
#	app/lib/l10n/app_uk.arb
#	app/lib/l10n/app_ur.arb
#	app/lib/l10n/app_vi.arb
#	app/lib/l10n/app_zh.arb
…issue tests

main removed utils.subscription.is_trial_paywalled (f7aad77), so the stub
raised AttributeError in all 19 cases.
…eclined

# Conflicts:
#	app/lib/l10n/app_ar.arb
#	app/lib/l10n/app_be.arb
#	app/lib/l10n/app_bg.arb
#	app/lib/l10n/app_bn.arb
#	app/lib/l10n/app_bs.arb
#	app/lib/l10n/app_ca.arb
#	app/lib/l10n/app_cs.arb
#	app/lib/l10n/app_da.arb
#	app/lib/l10n/app_de.arb
#	app/lib/l10n/app_el.arb
#	app/lib/l10n/app_en.arb
#	app/lib/l10n/app_es.arb
#	app/lib/l10n/app_et.arb
#	app/lib/l10n/app_fa.arb
#	app/lib/l10n/app_fi.arb
#	app/lib/l10n/app_fr.arb
#	app/lib/l10n/app_he.arb
#	app/lib/l10n/app_hi.arb
#	app/lib/l10n/app_hr.arb
#	app/lib/l10n/app_hu.arb
#	app/lib/l10n/app_id.arb
#	app/lib/l10n/app_it.arb
#	app/lib/l10n/app_ja.arb
#	app/lib/l10n/app_kn.arb
#	app/lib/l10n/app_ko.arb
#	app/lib/l10n/app_localizations.dart
#	app/lib/l10n/app_localizations_ar.dart
#	app/lib/l10n/app_localizations_be.dart
#	app/lib/l10n/app_localizations_bg.dart
#	app/lib/l10n/app_localizations_bn.dart
#	app/lib/l10n/app_localizations_bs.dart
#	app/lib/l10n/app_localizations_ca.dart
#	app/lib/l10n/app_localizations_cs.dart
#	app/lib/l10n/app_localizations_da.dart
#	app/lib/l10n/app_localizations_de.dart
#	app/lib/l10n/app_localizations_el.dart
#	app/lib/l10n/app_localizations_en.dart
#	app/lib/l10n/app_localizations_es.dart
#	app/lib/l10n/app_localizations_et.dart
#	app/lib/l10n/app_localizations_fa.dart
#	app/lib/l10n/app_localizations_fi.dart
#	app/lib/l10n/app_localizations_fr.dart
#	app/lib/l10n/app_localizations_he.dart
#	app/lib/l10n/app_localizations_hi.dart
#	app/lib/l10n/app_localizations_hr.dart
#	app/lib/l10n/app_localizations_hu.dart
#	app/lib/l10n/app_localizations_id.dart
#	app/lib/l10n/app_localizations_it.dart
#	app/lib/l10n/app_localizations_ja.dart
#	app/lib/l10n/app_localizations_kn.dart
#	app/lib/l10n/app_localizations_ko.dart
#	app/lib/l10n/app_localizations_lt.dart
#	app/lib/l10n/app_localizations_lv.dart
#	app/lib/l10n/app_localizations_mk.dart
#	app/lib/l10n/app_localizations_mr.dart
#	app/lib/l10n/app_localizations_ms.dart
#	app/lib/l10n/app_localizations_nl.dart
#	app/lib/l10n/app_localizations_no.dart
#	app/lib/l10n/app_localizations_pl.dart
#	app/lib/l10n/app_localizations_pt.dart
#	app/lib/l10n/app_localizations_ro.dart
#	app/lib/l10n/app_localizations_ru.dart
#	app/lib/l10n/app_localizations_sk.dart
#	app/lib/l10n/app_localizations_sl.dart
#	app/lib/l10n/app_localizations_sr.dart
#	app/lib/l10n/app_localizations_sv.dart
#	app/lib/l10n/app_localizations_ta.dart
#	app/lib/l10n/app_localizations_te.dart
#	app/lib/l10n/app_localizations_th.dart
#	app/lib/l10n/app_localizations_tl.dart
#	app/lib/l10n/app_localizations_tr.dart
#	app/lib/l10n/app_localizations_uk.dart
#	app/lib/l10n/app_localizations_ur.dart
#	app/lib/l10n/app_localizations_vi.dart
#	app/lib/l10n/app_localizations_zh.dart
#	app/lib/l10n/app_lt.arb
#	app/lib/l10n/app_lv.arb
#	app/lib/l10n/app_mk.arb
#	app/lib/l10n/app_mr.arb
#	app/lib/l10n/app_ms.arb
#	app/lib/l10n/app_nl.arb
#	app/lib/l10n/app_no.arb
#	app/lib/l10n/app_pl.arb
#	app/lib/l10n/app_pt.arb
#	app/lib/l10n/app_ro.arb
#	app/lib/l10n/app_ru.arb
#	app/lib/l10n/app_sk.arb
#	app/lib/l10n/app_sl.arb
#	app/lib/l10n/app_sr.arb
#	app/lib/l10n/app_sv.arb
#	app/lib/l10n/app_ta.arb
#	app/lib/l10n/app_te.arb
#	app/lib/l10n/app_th.arb
#	app/lib/l10n/app_tl.arb
#	app/lib/l10n/app_tr.arb
#	app/lib/l10n/app_uk.arb
#	app/lib/l10n/app_ur.arb
#	app/lib/l10n/app_vi.arb
#	app/lib/l10n/app_zh.arb
#	app/lib/pages/conversations/conversations_page.dart

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 issues found across 143 files

Confidence score: 3/5

  • backend/routers/users.py can miss renewal recovery when a downgrade webhook was missed because the expired subscription’s Stripe ID is cleared before payment_issue_for runs. Preserve the raw subscription identity for this lookup.
  • test_users_payment_issue.py patches stripe.Subscription.retrieve, but the route uses screen_vector_entitlements.refresh_subscription and StripeClient, so the test does not stub the lookup it exercises. Stub the actual lookup path.
  • The recovery analytics question describes unique readers, but its query counts event rows. Reword it as event counts or change the query and event data to count unique readers.
  • The card-declined evidence is not reproducible from this checkout: its reported checks depend on an uncommitted pipeline change, and money-review.md cites files absent from the artifact directory. Include the missing harness change and referenced evidence.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="contracts/analytics/consumers/subscription-payment-recovery.json">

<violation number="1" location="contracts/analytics/consumers/subscription-payment-recovery.json:5">
P2: This question claims to report how many readers completed each step, but the referenced query counts event rows, not unique readers. Reword the question as event/exposure counts, or change the query and event data to support distinct-reader counts.</violation>
</file>

<file name="app/docs/ux-contract.md">

<violation number="1" location="app/docs/ux-contract.md:101">
P3: This adds a mandatory compact-pill contract without adding checker coverage, so future hand-rolled compact pills can violate the rule without CI detecting them. Add a checker rule and failing test alongside this contract change.</violation>
</file>

<file name="app/lib/l10n/app_hu.arb">

<violation number="1" location="app/lib/l10n/app_hu.arb:4733">
P3: This message displays the Hungarian article placeholder `a(z)` literally before the plan name, producing awkward user-facing copy such as `a(z) Omi Pro`. Rephrase the sentence so it does not require a dynamic article, or provide grammatically correct variants for the plan name.</violation>
</file>

<file name="app/lib/l10n/app_nl.arb">

<violation number="1" location="app/lib/l10n/app_nl.arb:4636">
P3: This recovery prompt mixes formal `Uw` in the title with informal `je` in the message, so Dutch users see inconsistent address within two adjacent lines. Use the app's informal form consistently, for example `Je kaart is geweigerd`.</violation>
</file>

<file name="backend/tests/routers/test_users_payment_issue.py">

<violation number="1" location="backend/tests/routers/test_users_payment_issue.py:70">
P2: This fixture does not fake the route’s screen-vector Stripe lookup: the route calls `screen_vector_entitlements.refresh_subscription`, which uses `StripeClient`, not the patched `stripe.Subscription.retrieve`. Stub `users_router.screen_vector_entitlements.refresh_subscription` (or its underlying read) so the endpoint test remains hermetic and the Stripe call-count assertions cover every lookup.</violation>
</file>

<file name=".agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/money-review.md">

<violation number="1" location=".agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/money-review.md:32">
P3: The evidence citation points to `p4/round1/after/*/{checks.txt,stripe-requests.jsonl}`, `money-requests.json`, and `result.txt`, but none of those files are committed under this artifact directory. Include the referenced run outputs or cite the committed evidence so reviewers can independently verify the payment-safety claims.</violation>
</file>

<file name="app/lib/l10n/app_localizations_uk.dart">

<violation number="1" location="app/lib/l10n/app_localizations_uk.dart:15398">
P3: The Ukrainian message reads as “update the card to return Pro,” which is a literal and unnatural description of restoring access. Use wording such as “Оновіть картку, щоб знову користуватися $plan” so the recovery action is clear to Ukrainian users.</violation>
</file>

<file name="app/lib/l10n/app_en.arb">

<violation number="1" location="app/lib/l10n/app_en.arb:18755">
P3: `paymentDeclinedMessage` does not declare the `plan` placeholder metadata, so generated callers lose the `String` type and localization tooling lacks the placeholder’s type/example. Add a `placeholders.plan` entry with `type: "String"` and an example such as `Omi Pro`.</violation>
</file>

<file name=".agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/verification.txt">

<violation number="1" location=".agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/verification.txt:32">
P2: The reported check results depend on a local pipeline commit that is not part of this PR, so reviewers cannot reproduce them from the submitted checkout. Commit the harness change or include its patch and clearly separate those results from checks run against repository state.</violation>
</file>

<file name="app/test/pages/settings/payment_webview_loaded_test.dart">

<violation number="1" location="app/test/pages/settings/payment_webview_loaded_test.dart:55">
P3: This fake drops `onPageStarted`, so the HTTP-error test never exercises the production reset of `_failedHttpUrls`; a regression that leaves a later successful navigation suppressed would still pass. Store the callback and invoke it before each simulated navigation in the relevant tests.</violation>
</file>

<file name="app/lib/pages/home/widgets/payment_issue_row.dart">

<violation number="1" location="app/lib/pages/home/widgets/payment_issue_row.dart:42">
P3: `PaymentIssue` equality includes `status` and `plan`, so a refresh from `past_due` to `unpaid` keeps the row visible but emits another `SubscriptionPaymentIssueShown`. Track whether the row was previously visible instead of comparing the issue value.</violation>
</file>

<file name="app/changelog/unreleased/20261029-card-declined-row.json">

<violation number="1" location="app/changelog/unreleased/20261029-card-declined-row.json:2">
P3: This release note is inaccurate for legacy-plan users supported by the feature: the row can recover Operator, Architect, or another plan, not only Omi Pro. Say “get your plan back” (or otherwise describe restoring the subscription) so the note matches the user-visible behavior.</violation>
</file>

<file name="app/lib/l10n/app_localizations_ko.dart">

<violation number="1" location="app/lib/l10n/app_localizations_ko.dart:15147">
P3: This Korean message hardcodes `을` after a dynamic plan name; with the documented `Omi Pro`, it renders `Omi Pro을`, which is grammatically incorrect. Rephrase the sentence to avoid a fixed particle, such as `'$plan 이용을 다시 시작하려면 카드를 업데이트하세요'`.</violation>
</file>

<file name="backend/routers/users.py">

<violation number="1" location="backend/routers/users.py:1607">
P2: Expired paid subscriptions lose their Stripe ID before this call, so `payment_issue_for` returns `None` and Home cannot recover renewals when the downgrade webhook was missed. Preserve the raw subscription identity, or pass a recovery candidate that retains its Stripe ID, when evaluating the reconciliation snapshot.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

"id": "subscription-payment-recovery",
"kind": "question",
"owner": "Subscription",
"question": "How many readers see the failed-renewal Home row, tap Update and successfully load the billing portal, per namespace and build? Shown emits once per visible issue, not on repeated subscription refreshes. Portal Opened requires the web page to finish loading without a main-frame error. These events measure exposure and portal access, never payment or recovered revenue. Names contain Subscription to match the ingestion keep rule.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This question claims to report how many readers completed each step, but the referenced query counts event rows, not unique readers. Reword the question as event/exposure counts, or change the query and event data to support distinct-reader counts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At contracts/analytics/consumers/subscription-payment-recovery.json, line 5:

<comment>This question claims to report how many readers completed each step, but the referenced query counts event rows, not unique readers. Reword the question as event/exposure counts, or change the query and event data to support distinct-reader counts.</comment>

<file context>
@@ -0,0 +1,15 @@
+  "id": "subscription-payment-recovery",
+  "kind": "question",
+  "owner": "Subscription",
+  "question": "How many readers see the failed-renewal Home row, tap Update and successfully load the billing portal, per namespace and build? Shown emits once per visible issue, not on repeated subscription refreshes. Portal Opened requires the web page to finish loading without a main-frame error. These events measure exposure and portal access, never payment or recovered revenue. Names contain Subscription to match the ingestion keep rule.",
+  "query": "contracts/analytics/consumers/subscription-payment-recovery.sql",
+  "events": [
</file context>
Suggested change
"question": "How many readers see the failed-renewal Home row, tap Update and successfully load the billing portal, per namespace and build? Shown emits once per visible issue, not on repeated subscription refreshes. Portal Opened requires the web page to finish loading without a main-frame error. These events measure exposure and portal access, never payment or recovered revenue. Names contain Subscription to match the ingestion keep rule.",
"question": "How many failed-renewal Home-row exposures, Update taps and successfully loaded billing portals occur per namespace and build? Shown emits once per visible issue, not on repeated subscription refreshes. Portal Opened requires the web page to finish loading without a main-frame error. These events measure exposure and portal access, never payment or recovered revenue. Names contain Subscription to match the ingestion keep rule.",

}
)

monkeypatch.setattr(billing_recovery.stripe.Subscription, 'retrieve', retrieve_sub)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This fixture does not fake the route’s screen-vector Stripe lookup: the route calls screen_vector_entitlements.refresh_subscription, which uses StripeClient, not the patched stripe.Subscription.retrieve. Stub users_router.screen_vector_entitlements.refresh_subscription (or its underlying read) so the endpoint test remains hermetic and the Stripe call-count assertions cover every lookup.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/routers/test_users_payment_issue.py, line 70:

<comment>This fixture does not fake the route’s screen-vector Stripe lookup: the route calls `screen_vector_entitlements.refresh_subscription`, which uses `StripeClient`, not the patched `stripe.Subscription.retrieve`. Stub `users_router.screen_vector_entitlements.refresh_subscription` (or its underlying read) so the endpoint test remains hermetic and the Stripe call-count assertions cover every lookup.</comment>

<file context>
@@ -0,0 +1,167 @@
+            }
+        )
+
+    monkeypatch.setattr(billing_recovery.stripe.Subscription, 'retrieve', retrieve_sub)
+    monkeypatch.setattr(billing_recovery.stripe.Invoice, 'retrieve', retrieve_invoice)
+    monkeypatch.setattr(users_router.users_db, 'is_byok_active', lambda uid: False)
</file context>
Suggested change
monkeypatch.setattr(billing_recovery.stripe.Subscription, 'retrieve', retrieve_sub)
monkeypatch.setattr(billing_recovery.stripe.Subscription, 'retrieve', retrieve_sub)
monkeypatch.setattr(
users_router.screen_vector_entitlements,
'refresh_subscription',
lambda uid, subscription, **kwargs: subscription,
)

- demo.mp4: 20.48 seconds, unmodified continuous native recording. Frames 0,5,10,15,20 and final inspected; start has recovery, middle has loaded portal, final has Pro restored and recovery absent.
- before-after.png: unmodified native before/after screenshots placed side by side, inspected.

Tooling: shared lane sim.2 and public resource guard throughout. After one Auth-emulator timeout, local pipeline commit 9e70478 added opt-in bounded MUX_FIREBASE_HEALTH_TIMEOUT (1..300s); this run used 180s. Default deadlines, resource limits and lane ports are unchanged. No private pipeline copy or foreground app/browser control used this round.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The reported check results depend on a local pipeline commit that is not part of this PR, so reviewers cannot reproduce them from the submitted checkout. Commit the harness change or include its patch and clearly separate those results from checks run against repository state.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .agent-artifacts/ui-evidence/mux-2026-10-29-card-declined/verification.txt, line 32:

<comment>The reported check results depend on a local pipeline commit that is not part of this PR, so reviewers cannot reproduce them from the submitted checkout. Commit the harness change or include its patch and clearly separate those results from checks run against repository state.</comment>

<file context>
@@ -0,0 +1,35 @@
+- demo.mp4: 20.48 seconds, unmodified continuous native recording. Frames 0,5,10,15,20 and final inspected; start has recovery, middle has loaded portal, final has Pro restored and recovery absent.
+- before-after.png: unmodified native before/after screenshots placed side by side, inspected.
+
+Tooling: shared lane sim.2 and public resource guard throughout. After one Auth-emulator timeout, local pipeline commit 9e70478 added opt-in bounded MUX_FIREBASE_HEALTH_TIMEOUT (1..300s); this run used 180s. Default deadlines, resource limits and lane ports are unchanged. No private pipeline copy or foreground app/browser control used this round.
+Original capture-script cleanup error was corrected; attempt1-light is retained as diagnostics. Final light, dark and maximum-text runs all exited 0.
+
</file context>

Comment thread backend/routers/users.py
phone_call_quota=phone_call_quota,
desktop_grandfather_until=desktop_grandfather_until,
payment_issue=(
billing_recovery.payment_issue_for(uid, subscription, stripe_snapshot)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Expired paid subscriptions lose their Stripe ID before this call, so payment_issue_for returns None and Home cannot recover renewals when the downgrade webhook was missed. Preserve the raw subscription identity, or pass a recovery candidate that retains its Stripe ID, when evaluating the reconciliation snapshot.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/routers/users.py, line 1607:

<comment>Expired paid subscriptions lose their Stripe ID before this call, so `payment_issue_for` returns `None` and Home cannot recover renewals when the downgrade webhook was missed. Preserve the raw subscription identity, or pass a recovery candidate that retains its Stripe ID, when evaluating the reconciliation snapshot.</comment>

<file context>
@@ -1599,10 +1599,15 @@ def _user_subscription_response(
         phone_call_quota=phone_call_quota,
         desktop_grandfather_until=desktop_grandfather_until,
+        payment_issue=(
+            billing_recovery.payment_issue_for(uid, subscription, stripe_snapshot)
+            if is_mobile and show_subscription_ui
+            else None
</file context>

Comment thread app/docs/ux-contract.md

- Every tappable control is at least **44×44 pt** (48 dp on Android is fine), including the label
next to a checkbox (`OmiCheckboxRow`).
- A compact pill action uses `OmiButton(size: OmiButtonSize.compact, pill: true)` with `OmiRadius.pillAll`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This adds a mandatory compact-pill contract without adding checker coverage, so future hand-rolled compact pills can violate the rule without CI detecting them. Add a checker rule and failing test alongside this contract change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/docs/ux-contract.md, line 101:

<comment>This adds a mandatory compact-pill contract without adding checker coverage, so future hand-rolled compact pills can violate the rule without CI detecting them. Add a checker rule and failing test alongside this contract change.</comment>

<file context>
@@ -98,6 +98,7 @@ There are exactly two ways out, and they mean different things.
 
 - Every tappable control is at least **44×44 pt** (48 dp on Android is fine), including the label
   next to a checkbox (`OmiCheckboxRow`).
+- A compact pill action uses `OmiButton(size: OmiButtonSize.compact, pill: true)` with `OmiRadius.pillAll`.
 - A button label is a verb in Title Case ("Save", "Delete Task", "Try Again"). A button that is
   busy keeps its size and shows a spinner in place of or beside its label.
</file context>

Comment thread app/lib/l10n/app_en.arb
Comment on lines +18755 to 18757
"@paymentDeclinedMessage": {
"description": "Home row line under 'Your card was declined'. it = the card; plan = a product name such as Omi Pro"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: paymentDeclinedMessage does not declare the plan placeholder metadata, so generated callers lose the String type and localization tooling lacks the placeholder’s type/example. Add a placeholders.plan entry with type: "String" and an example such as Omi Pro.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_en.arb, line 18755:

<comment>`paymentDeclinedMessage` does not declare the `plan` placeholder metadata, so generated callers lose the `String` type and localization tooling lacks the placeholder’s type/example. Add a `placeholders.plan` entry with `type: "String"` and an example such as `Omi Pro`.</comment>

<file context>
@@ -18746,5 +18746,13 @@
+        "description": "Home row title when the renewal charge for the user's plan failed"
+    },
+    "paymentDeclinedMessage": "Update it to get {plan} back",
+    "@paymentDeclinedMessage": {
+        "description": "Home row line under 'Your card was declined'. it = the card; plan = a product name such as Omi Pro"
     }
</file context>
Suggested change
"@paymentDeclinedMessage": {
"description": "Home row line under 'Your card was declined'. it = the card; plan = a product name such as Omi Pro"
}
"@paymentDeclinedMessage": {
"description": "Home row line under 'Your card was declined'. it = the card; plan = a product name such as Omi Pro",
"placeholders": {
"plan": {
"type": "String",
"example": "Omi Pro"
}
}
}

late WebResourceErrorCallback failed;
late HttpResponseErrorCallback httpFailed;
@override
Future<void> setOnPageStarted(PageEventCallback callback) async {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This fake drops onPageStarted, so the HTTP-error test never exercises the production reset of _failedHttpUrls; a regression that leaves a later successful navigation suppressed would still pass. Store the callback and invoke it before each simulated navigation in the relevant tests.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/pages/settings/payment_webview_loaded_test.dart, line 55:

<comment>This fake drops `onPageStarted`, so the HTTP-error test never exercises the production reset of `_failedHttpUrls`; a regression that leaves a later successful navigation suppressed would still pass. Store the callback and invoke it before each simulated navigation in the relevant tests.</comment>

<file context>
@@ -0,0 +1,120 @@
+  late WebResourceErrorCallback failed;
+  late HttpResponseErrorCallback httpFailed;
+  @override
+  Future<void> setOnPageStarted(PageEventCallback callback) async {}
+  @override
+  Future<void> setOnPageFinished(PageEventCallback callback) async => finished = callback;
</file context>

_shownIssue = null;
return const SizedBox.shrink();
}
if (_shownIssue != issue) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: PaymentIssue equality includes status and plan, so a refresh from past_due to unpaid keeps the row visible but emits another SubscriptionPaymentIssueShown. Track whether the row was previously visible instead of comparing the issue value.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/pages/home/widgets/payment_issue_row.dart, line 42:

<comment>`PaymentIssue` equality includes `status` and `plan`, so a refresh from `past_due` to `unpaid` keeps the row visible but emits another `SubscriptionPaymentIssueShown`. Track whether the row was previously visible instead of comparing the issue value.</comment>

<file context>
@@ -0,0 +1,133 @@
+      _shownIssue = null;
+      return const SizedBox.shrink();
+    }
+    if (_shownIssue != issue) {
+      _shownIssue = issue;
+      WidgetsBinding.instance.addPostFrameCallback((_) {
</file context>

@@ -0,0 +1,3 @@
{
"change": "If your card is declined at renewal, Home shows one row to update it and get Omi Pro back"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This release note is inaccurate for legacy-plan users supported by the feature: the row can recover Operator, Architect, or another plan, not only Omi Pro. Say “get your plan back” (or otherwise describe restoring the subscription) so the note matches the user-visible behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/changelog/unreleased/20261029-card-declined-row.json, line 2:

<comment>This release note is inaccurate for legacy-plan users supported by the feature: the row can recover Operator, Architect, or another plan, not only Omi Pro. Say “get your plan back” (or otherwise describe restoring the subscription) so the note matches the user-visible behavior.</comment>

<file context>
@@ -0,0 +1,3 @@
+{
+  "change": "If your card is declined at renewal, Home shows one row to update it and get Omi Pro back"
+}
</file context>
Suggested change
"change": "If your card is declined at renewal, Home shows one row to update it and get Omi Pro back"
"change": "If your card is declined at renewal, Home shows one row to update it and get your plan back"


@override
String paymentDeclinedMessage(Object plan) {
return '$plan을 다시 이용하려면 카드를 업데이트하세요';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This Korean message hardcodes 을 after a dynamic plan name; with the documented Omi Pro, it renders Omi Pro을, which is grammatically incorrect. Rephrase the sentence to avoid a fixed particle, such as '$plan 이용을 다시 시작하려면 카드를 업데이트하세요'.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/l10n/app_localizations_ko.dart, line 15147:

<comment>This Korean message hardcodes `을` after a dynamic plan name; with the documented `Omi Pro`, it renders `Omi Pro을`, which is grammatically incorrect. Rephrase the sentence to avoid a fixed particle, such as `'$plan 이용을 다시 시작하려면 카드를 업데이트하세요'`.</comment>

<file context>
@@ -15138,4 +15138,12 @@ class AppLocalizationsKo extends AppLocalizations {
+
+  @override
+  String paymentDeclinedMessage(Object plan) {
+    return '$plan을 다시 이용하려면 카드를 업데이트하세요';
+  }
 }
</file context>
Suggested change
return '$plan을 다시 이용하려면 카드를 업데이트하세요';
return '$plan 이용을 다시 시작하려면 카드를 업데이트하세요';

@kodjima33
kodjima33 merged commit 92b7d7d into main Nov 5, 2026
65 checks passed
@kodjima33
kodjima33 deleted the mux/2026-10-29-card-declined branch November 5, 2026 03:57
kodjima33 added a commit that referenced this pull request Nov 14, 2026
…row (#25294)

## Problem

First-year yearly plans renew at only 42% (22 of 52 anniversaries since
Oct 1): 25% end on a failed card, 23% cancel, 10% pending. 58% of
trial-end and renewal card failures are insufficient funds. 329
first-year yearly renewals come due in the next 75 days (about 147
between Dec 7 and 27), and half of those payers had no app session in 30
days. Source: `~/mobile-ux-agent/runs/2026-11-13/analysis/sessions.md`
section 5 (Stripe, ACTUAL).

#23953's declined-card row on Home already recovers some failed
renewals, but it only offers updating the card for the same yearly
charge. Someone who cannot pay $199.99 today has no smaller option and
is lost after Stripe's retries.

New fact from the same Stripe snapshot: **all 320 first-year yearly
renewals due in the next 75 days are on the Neo yearly price**
(`price_1RtJQ71F8wnoWYvwKMPaGlGY`, $199.99), not Omi Pro's $269.91. So
the switch targets the subscription's own plan's catalog monthly price
(Neo monthly $19.99, live and active; Omi Pro monthly $29.99), which
`retired_plan_change_error` already allows ("may switch interval within
it").

## Change

What the reader sees (only when the renewal that failed is yearly):

- The declined row reads "Update it, or get Omi Pro back for US$29.99 a
month" and adds **Switch to Monthly** (secondary) next to **Update**
(primary, unchanged).
- Switch to Monthly opens a confirm sheet laid out like the shipped
yearly-switch sheet: Plan, **Due today** (the catalog monthly price),
"Replaces the unpaid US$269.91 yearly charge. Renews monthly. Cancel
anytime.", Confirm and Cancel.
- Declined card: "Payment declined. Your plan didn't change." and the
row stays. Success: "You're on monthly", the row leaves.
- Monthly renewals, trials, discounted, non-USD, cancel-scheduled and
unpaid subscriptions see exactly today's row.

Backend:
- `utils/monthly_switch.py`: offer rules and the switch. `GET
/v1/users/me/subscription` adds `payment_issue.monthly_switch`
(`price_id`, `amount`, `currency`, `yearly_amount`), omitted when not
offered.
- `POST /v1/payments/payment-issue/monthly-switch`
(`routers/monthly_switch.py`, mounted next to `yearly_switch`).
- `routers/payment.py`: `invoice.paid` retries a void the switch could
not finish (+5 lines).
- Kill switch `PAYMENT_ISSUE_MONTHLY_SWITCH_ENABLED` (default on,
`ops_kill`, registered in `config/feature-flags.yaml`).

App: `payment_issue_row.dart`, new `monthly_switch_sheet.dart`, model +
API call, 8 strings in all 49 locales. At large text the stacked actions
put Update (the primary) first, so it stays clear of Home's pinned Ask
bar. `PlanSwitchFactRow` (shared with the yearly sheet) stacks label
over value at large text so amounts never break mid-number.

## Money safety

- **Pause, charge, then void.**
1. Before the charge, the unpaid yearly invoice's automatic collection
is paused (`Invoice.modify(auto_advance=False)`), so no Stripe retry can
collect it while the switch runs or while a failed void is being
retried.
2. Then `Subscription.modify(items=[monthly], billing_cycle_anchor=now,
proration_behavior=none, payment_behavior=error_if_incomplete)`. The
unpaid yearly period earns no credit.
3. Only after the monthly charge succeeds is the yearly invoice voided.
- **Any failure that did not switch restores dunning exactly as
before:**
  - A decline (`card_error`, Stripe changed nothing) resumes collection.
- An unclear Stripe error re-reads the subscription and resumes unless
the switch landed. If it landed, collection stays paused and the retry
voids.
- A failed pause is undone before anything is charged. A failed resume
is logged and reported (`record_fallback`); Update still pays the
invoice.
- **Double payment is reported, never silent:** if the superseded yearly
invoice is found `paid` (amount_paid > 0), `void_superseded` logs an
error and records `monthly_switch_superseded_invoice → paid_twice`
(outcome exhausted) so someone refunds it. No automatic refund.
- **Proven on the Stripe sandbox** ("Omi pricing qa", test mode,
`livemode=false`, test clock;
`runs/2026-11-14/y1/stripe-sandbox/proof2.log`). Three payers whose
19999 renewal was declined:
- **A (switch works, void never runs):** paused (next attempt none),
charged 1999. At +3, +8 and +20 days the yearly invoice is still open
and never retried; charges stay 19999, 1999.
- **B (switch declined):** `card_error`, collection resumed with the
same next retry as before the pause, still past_due on yearly. Once the
card works, dunning collects it: 19999, 19999 and no monthly charge.
  - **C (manual pay while paused, what Update does):** paid 19999.
- Before the fix, the review's sandbox run without the pause charged
19999, 1999, 19999.
- Earlier `proof.log`: a declined switch leaves no stray invoice, the
preview equals the price, and the void with the same idempotency key
replays.
- **No double charge from taps or retries:**
  - A per-user Redis lock (no lock, no charge).
- A replay check: a subscription already switched by us returns without
a second modify.
  - An idempotency key bound to subscription, invoice and attempt.
- **The charge is what the reader saw:** `expected_amount` must equal
the live price and Stripe's preview for the same items, anchor and
proration. No new prices, coupons or discounts. Only the plan's
configured monthly price is accepted.
- **Refused before any Stripe write:** anything not past_due (unpaid,
active, trial), cancel scheduled, schedule attached, pending update,
discount on the subscription or invoice, paused, invoiced billing, more
than one item, non-USD, not on a consumer plan's configured yearly
price, invoice not the open latest `subscription_cycle` invoice, wrong
owner uid, kill switch off.
- **A failed void is repaired:** `invoice.paid` for the new monthly
invoice retries the void and returns 503 so Stripe redelivers. With the
pause, nothing can collect the yearly invoice in the meantime.
- **Compatibility** (`contracts/client-compat`,
`check_app_client_openapi_compatibility.py` passes): the new field is
additive and omitted when absent.
  - Old app + new backend: unchanged row (BEFORE run).
- New app + old backend: no field, so the Update-only row (widget test).
- **Cancel stays easy:** the sheet has Cancel and a close X, and nothing
on the row or sheet blocks the existing cancel flow.

## Impact estimate

> If a declined first-year yearly renewal can switch to the plan's
monthly price from the Home row, first-year yearly renewal (any paid
plan) goes 42% → 45% (44–48%); 30-day subscriber churn 11.21% → 11.06%
(11.13–10.95%).

Basis:
- **A, ACTUAL:**
  - 42% (22/52) first-year yearly renewal (sessions.md section 5).
  - Churn 11.214% (`runs/2026-11-14/metrics.json`, `subscriber_churn`).
- **Card failures that end, ACTUAL:** 25% of first-year yearly renewals
(13/52).
- **They rarely recover on their own, ACTUAL:**
- 7 of 71 paid first-year yearly renewals paid after a failed first
attempt, against 42 that ended on card failure (Stripe snapshot,
paid-invoice lag).
- So about 86% of failures are lost today, and the switch mostly reaches
payers who would otherwise leave.
- **Reach, MODELED 35–50% (42% central):**
- Seeing the row needs an app session while past_due (up to 14 days of
retries).
  - 50% of the 329 had a session in the last 30 days (ACTUAL).
  - The existing failed-renewal push sends people to Home.
- **Take-up, MODELED 30% (20–45%) of row viewers who would otherwise
end:**
  - 58% of failures are insufficient funds (ACTUAL).
- The monthly charge is 10% of the yearly one for the Neo wave ($19.99
vs $199.99).
  - #23953's row: 4 of 6 tappers paid (ACTUAL, small n).
- **Gain:** 25 × 0.42 × 0.30 ≈ +3.2 points (+1.8 to +5.6).
- **Churn:** 329 × 3.2% ≈ 10 more payers kept over 75 days, about 4 per
30 days on ~2,800 active subscribers, so −0.15 points.
- **Why not the brief's 55%:** that needs about half of all card
failures to switch, but half of these payers never open the app.
Reaching dormant payers needs the push or email to carry the offer
(below).
- **Revenue risk, MODELED:** someone who would have fixed the card and
paid $199.99 now pays $19.99 a month instead. That is at most the ~14%
of failures that recover today.

## At ship

- Deploy backend first. The app shows nothing new until
`payment_issue.monthly_switch` arrives, and
`PAYMENT_ISSUE_MONTHLY_SWITCH_ENABLED=false` turns the offer and the
endpoint off.
- Events are unsampled (names contain "Subscri"), registered in
`contracts/analytics/events.json`, consumer
`subscription-payment-recovery`:
- `Subscription Payment Issue Monthly Shown` / `Tapped` / `Switched`
(after the server confirms) / `Failed` (reason: declined, refused,
error).
- Calibration read about 3 weeks after the Dec 7 wave: Monthly Switched
÷ Monthly Shown, and first-year yearly renewal (any paid plan) from
Stripe.
- **Dormant payers (not built, nothing sent):** the only Omi-owned path
is the existing failed-renewal push
(`_schedule_payment_recovery_notification` in `routers/payment.py`,
"Payment declined / Update your payment method…", `navigate_to:
/conversations` = Home, where this row is).
- The same offer could ride it: when
`billing_recovery.payment_issue_from_stripe` + `monthly_switch.offer()`
return an offer at the past_due transition, append "Or keep <plan> for
<price> a month." to the body. It needs copy approval and server-side
l10n.
- There is no Omi email for failed renewals. Stripe's own dunning emails
(if enabled in the Stripe settings) link to the hosted invoice, which
cannot switch plans.
- Review follow-ups not in this PR:
  - The app re-reads the plan only on a lost answer, not on a 503.
- The superseded-invoice metadata key is never cleared, so later monthly
`invoice.paid` events do one extra invoice read.
- Confirm the Stripe API version's invoice `subscription` field for the
webhook gate.
- Review follow-ups not in this PR:
  - The app re-reads the plan only on a lost answer, not on a 503.
- The superseded-invoice metadata key is never cleared, so later monthly
`invoice.paid` events do one extra invoice read.
- Confirm the Stripe API version's invoice `subscription` field for the
webhook gate.
- Overlap: #25289 (open) extracts the upgrade path's store step. This PR
leaves that path untouched and stores its own result with the same
calls. Fold into that helper once it lands.

## Evidence

Simulator (MUX pipeline, lane sim, iPhone 17 Pro iOS 26.2, local backend
+ Stripe stub). Same seed on main (BEFORE) and this branch (AFTER): Omi
Pro yearly, first renewal declined, past_due with an open $269.91
invoice.

![Home row before and after, and the confirm
sheet](https://raw.githubusercontent.com/BasedHardware/omi/34b1546d9f5c8aba02400c070690af7f3c8084c4/.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save/001-mobile-ios-home-row-before-after.png)
![Declined, switched, row gone, after
relaunch](https://raw.githubusercontent.com/BasedHardware/omi/34b1546d9f5c8aba02400c070690af7f3c8084c4/.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save/002-mobile-ios-declined-switched-row-gone.png)
![Dark before and
after](https://raw.githubusercontent.com/BasedHardware/omi/34b1546d9f5c8aba02400c070690af7f3c8084c4/.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save/003-mobile-ios-dark-before-after.png)
![Largest text before and after (light and
dark)](https://raw.githubusercontent.com/BasedHardware/omi/34b1546d9f5c8aba02400c070690af7f3c8084c4/.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save/004-mobile-ios-max-text-before-after.png)
![German, Japanese,
Arabic](https://raw.githubusercontent.com/BasedHardware/omi/34b1546d9f5c8aba02400c070690af7f3c8084c4/.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save/005-mobile-ios-locales-de-ja-ar.png)

| check (same seed) | main | this branch |
|---|---|---|
| backend `payment_issue` | `{past_due, unlimited_v2}` | +
`monthly_switch {2999 usd, yearly 26991}` |
| row | Update only | offer line + Switch to Monthly + Update |
| open sheet, Cancel | n/a | no Stripe write; still past_due, invoice
open |
| Confirm, card declined | n/a | "Payment declined. Your plan didn't
change."; past_due, invoice open, 0 charges |
| Confirm, card works | n/a | active monthly, 1 charge, yearly invoice
void, plan unlimited_v2 |
| replayed POST ×2 | n/a | HTTP 200, still 1 charge, 1 void |
| relaunch | n/a | row stays gone |

The full flow passed on the final backend tree
(`runs/2026-11-14/y1/raw/after-light-final/checks.txt`): collection
paused then resumed for the declined attempt, paused for the switch,
yearly invoice void, 1 charge. Artifacts in
`~/mobile-ux-agent/runs/2026-11-14/y1/`:
- `before-after.png`, `demo.mp4` (28 s), `demo.gif`, `result.txt`,
`stripe-sandbox/proof.log`
- `before/` and `after/` (light, dark, largest text light and dark,
de/ja/ar)
- `stripe-sandbox/proof2.log`: the pause proof

## Tests

- Backend:
- `tests/unit/test_monthly_switch.py` (50): offer rules, pause, charge,
void order; a decline resumes collection; an unclear failure resumes
only if not switched; a failed pause never charges; a failed resume and
a paid-twice invoice are reported; refusals before any write; replay;
failed void; kill switch.
- `tests/routers/test_payment_monthly_switch.py` (12): status codes,
lock, store.
- `tests/unit/test_monthly_switch_webhook.py` (3): void retry on
`invoice.paid`, 503 on failure.
- `tests/routers/test_users_payment_issue.py` (+2): offer on the
subscription response.
- Related suites green: billing_recovery, yearly_switch,
declined_proration, promotion_codes, webhook_delivery, paid_app_renewal,
stripe_event_ledger.
- App: `test/pages/home/payment_issue_row_test.dart` (24): offer row,
old-server row, sheet content, Cancel, single charge on double tap,
declined, refused, lost answer, largest text (row with Update first, and
the sheet), events.
- Guards: mobile UX contract, UI isolate, brand UI, event registry, l10n
check, OpenAPI export + Dart/TS/Swift generation, app-client
compatibility, route-policy baseline, feature-flag registry.

## Not verified

- Real take-up and reach: the estimate above is modeled.
- The Neo yearly-to-monthly switch on live Stripe. The sandbox replica
($199.99 to $19.99) and the unit tests cover it, but the simulator shot
uses Omi Pro prices (the stub has no Neo prices).
- Live Smart Retry timing: the sandbox retried about 3 days after the
declined renewal. The pause holds through +20 days there.
- Pre-existing, not from this change: at the largest text the Home/Tasks
header overflows on main too. One app test (`voice_recorder_test`)
flaked once in a full run and passes alone on main and on this branch.

Line-Count-Exception: backend/routers/payment.py | 2100 -> 2105 | the
invoice.paid webhook is the durable retry point for voiding the
superseded yearly invoice; the endpoint itself lives in
routers/monthly_switch.py

UI-Evidence: see the images above
(.agent-artifacts/ui-evidence/mux-2026-11-14-yearly-renewal-save)

This branch was successfully deployed

1 active deployment
staging - docs — 67e6e3c7 Deployed Nov 5, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mux-proposal Mobile UX improver (MUX) proposal; waits for Nik's ship

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant