Repository navigation
feat(subscriptions): new buyers get Omi Pro only on mobile and web - #23504
Conversation
David's 2026-10-24 ruling: a buyer with no current paid subscription is
offered only unlimited_v2 (Omi Pro) on mobile, web, and unknown/missing
platforms, in the v1 catalog, the v2 ladder storefront (404) and checkout
enforcement. Desktop platforms and existing subscribers are unchanged.
Kill switch NEW_BUYER_SINGLE_PLAN_ENABLED (default on); rejections count
in omi_new_buyer_checkout_rejected_total{reason,plan}.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 995aa84f22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if subscription_utils.new_buyer_single_plan_applies(subscription.plan, x_app_platform): | ||
| raise HTTPException(status_code=404, detail='Storefront is not enabled') |
There was a problem hiding this comment.
Preserve a purchase surface for storefront-enabled new buyers
When the mobile or web storefront feature flag is enabled, returning 404 here removes the purchase surface rather than switching the client to the v1 catalog. In Flutter, PlansSheet._loadStorefront marks every unsuccessful response as _storefrontFailed and keeps _storefrontEnabled true; on web, useStorefront likewise sets failed, while SettingsPage continues rendering StorefrontPanel. Neither path falls back to the legacy plans sheet, so new buyers see a persistent load error with no Omi Pro checkout option. Add an explicit client fallback or return an Omi Pro-compatible storefront before rejecting these requests.
Useful? React with 👍 / 👎.
| if new_buyer_single_plan_applies(current_plan, platform): | ||
| return [d for d in definitions if d.get('plan_type') == PlanType.unlimited_v2] |
There was a problem hiding this comment.
Determine catalog eligibility from the valid subscription
For a non-desktop user whose stored paid subscription has expired but has not yet been replaced with a basic record, this filter still exposes the previous multi-plan catalog. get_available_plans_endpoint supplies the raw plan from get_user_subscription, whereas the new checkout guard uses get_user_valid_subscription, which normalizes an expired period to basic. Consequently, the sheet offers Plus or other legacy prices that checkout now rejects, and an expired desktop-plan subscriber on mobile can remain limited to an unpurchasable current-plan row. Normalize subscription validity before applying the catalog audience rules so these users receive the same Omi Pro-only catalog that checkout enforces.
Useful? React with 👍 / 👎.
Luna REQUEST-CHANGES follow-ups on #23504: - P1: catalog filtering now keys off the period-valid plan lookup (get_user_valid_subscription) like checkout, so a lapsed Operator/Architect record on mobile is offered Omi Pro instead of their expired desktop SKU (backend/routers/payment.py). - P1: a missing or unknown X-App-Platform keeps the pre-ruling behaviour everywhere (catalog, v2 storefront, checkout); the restriction follows the explicit first-party values (ios/android/web). Every desktop build ever shipped stamps the header on every request (macOS since d51d101, Windows since its platform-identity hardening), and the other desktop-identifying headers are all newer, so no reliable header-less desktop signal exists; desktop compatibility outranks closing the direct-API gap. Allowed legacy checkouts for those callers count in omi_new_buyer_checkout_rejected_total{reason="unknown_platform_allowed"}. - P2: only a current recurring personal subscription exempts a buyer from the guard; an organization grant (pi_ PaymentIntent or no subscription id) is a new buyer for checkout. - P2: /v2/payments/plans serves a new buyer on mobile/web a single-tier Omi Pro sheet (build_single_plan_storefront) instead of 404, so the web plans panel never shows a dead 'Couldn't load plans' state; the web client ranks unlimited_v2 on its ladder so the card can check out. Golden fixture + web/backend tests included. - P3: the trial test now exercises a configured Omi Pro monthly price with trial_days=7 through the real guard (not stubbed). Copy: cta get_unlimited added to every storefront locale (locale completeness contract). Docs and feature-flag registry updated.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8df7e72ed6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if new_buyer_single_plan_applies(current_plan, platform): | ||
| return [d for d in definitions if d.get('plan_type') == PlanType.unlimited_v2] |
There was a problem hiding this comment.
Apply the recurring-subscription boundary to catalog eligibility
For a mobile or web user with an unexpired organization-granted paid plan (stripe_subscription_id is pi_… or absent), the catalog still treats the user as an existing subscriber because this predicate only receives their plan. However, the new checkout guard explicitly treats that same grant as a new buyer and rejects every non-unlimited_v2 price. For example, a granted Plus user still receives purchasable Plus prices through /v1/payments/available-plans, but selecting those prices now produces a 400. Share the recurring-personal-subscription eligibility check with catalog filtering so the displayed purchase options agree with checkout while preserving granted entitlements.
Useful? React with 👍 / 👎.
…ac7939ac origin/main moved under this PR and its merge ref now fails the per-shard backend typecheck (scripts/typecheck.sh runs in every shard when changed paths touch the typed boundary; the offending commits landed on main by direct train push, so PR CI never saw them). All five are annotation/guard mismatches; runtime behavior is preserved: - omi_tools.get_omi_product_info_tool: drop the redundant 'query is None or' before the isinstance guard (isinstance already rejects None), keeping the non-str runtime defense. - result_bounds.cap_items_for_llm: annotate items as List[T] | None so the existing None guard is type-honest. - result_bounds.bounded_result: annotate result as object (the body already coerces None/non-str defensively) and bind the coerced value to a fresh local so narrowing survives to the return. - generate_2025._compute_conversation_duration: filter falsy seg.end instead of 'is not None' (the model types end as float); zero ends were already irrelevant to the max_end > 0 check. Verified: pyright -p pyrightconfig.json -> 0 errors; test_wrapped_* and test_goals_wrapped_firmware_hardening pass through backend/test.sh. Note: test_omi_tools_resilience.py errors at setup on pristine main content too (its importlib fallback never registers sys.modules, so model_text's dataclass lookup crashes) — pre-existing on main, not touched here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 444a17bcb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if subscription_utils.new_buyer_single_plan_applies(subscription.plan, x_app_platform): | ||
| return build_single_plan_storefront( |
There was a problem hiding this comment.
Apply shared usage policy before returning the single-plan sheet
For basic mobile/web callers, this return bypasses the shared usage-policy block below. _usage() populates pro_gates from presentation copy, so those gates now remain present even when LADDER_V1_PRO_GATES_ENABLED is off. With contextual plans enabled, Flutter's showProGateUpsell() consequently intercepts notification-setting changes that previously proceeded without a paywall. The same return also skips the daily-cap observation, leaving mcp_cap_reached false and hiding McpCapUpsellEntry even when the cap is reached. Apply the shared flag filtering and cap observation before choosing the storefront builder.
Useful? React with 👍 / 👎.
| return StorefrontResponse( | ||
| catalog_revision=catalog_revision, |
There was a problem hiding this comment.
Preserve exhausted-budget metadata in the single-plan response
When budget enforcement is enabled and a basic mobile/web user exhausts their budget, this builder never supplies the chat_at_cap or at_cap fields that build_storefront() previously generated. On web, useChatBudgetPause() clears its admission-error state whenever refreshed storefront data arrives, so the missing chat_at_cap removes the pause explanation after a refresh despite chat remaining blocked. On mobile, the missing at_cap makes _offerOnDevice() skip loading and persisting the server-backed budget choice, including its don't-ask-again preference. Reuse the exhausted-budget projection in the single-plan response.
Useful? React with 👍 / 👎.
…ve — unblock CI test_omi_tools_resilience.py (from main d39cae3) errors at setup in a fresh interpreter: omi_tools' and result_bounds' importlib fallbacks exec the modules without registering them in sys.modules, and model_text.py uses 'from __future__ import annotations' with @DataClass, whose string-annotation resolution does sys.modules[cls.__module__].__dict__ -> AttributeError on None. Register each fallback module in sys.modules before exec_module, as importlib requires. The normal (non-fallback) import path is unchanged. test_omi_tools_resilience.py (6 tests) and test_retrieval_result_bounds.py (12) now pass through backend/test.sh; pyright stays at 0 errors.
…12b018 test_payment_declined_proration.py landed on main by direct train push (#23416) without the fast-unit CPU guard measuring it. On this PR's shards it costs 1.29-1.95s CPU per 402-snapshot test vs the 1.00s fail limit (runs 40118527240 and 40115474313, shard 6): the first test amortizes the payment router/app import graph under file isolation and the snapshots build full subscription/stripe objects. Assertions pass; entries follow the allowlist's established boundary shape.
…plan # Conflicts: # backend/utils/retrieval/tools/omi_tools.py # backend/utils/retrieval/tools/result_bounds.py # backend/utils/wrapped/generate_2025.py
…ll site test_reason_label_enums (the reason-label contract) rejects .labels(reason=<variable>): literals are closed by construction, a variable needs a reviewed CLOSED_HELPERS helper or debt. The guard recorder took the reason as a parameter and the zero-init loop iterated the reasons tuple; both now pass literals at each call site (record_new_buyer_checkout_rejection / record_new_buyer_unknown_platform_allowance own their literal; zero-init spells both reasons per plan). No label values change.
…nt golden contracts The Flutter storefront contract pins that every golden fixture has a current tier with no bullets and an exact fixture count; the app and backend fixture directories must also match byte for byte. The Omi Pro sheet now appends the Free current card (same shape as the ladder sheet's basic row: no bullets, no CTA, the $0 price), the golden is regenerated and mirrored to app/test/fixtures, and the app fixture count pin moves 16 -> 17.
New buyers get Omi Pro only (mobile + web), enforced in the backend
Ruling (David, 2026-10-24): a buyer with no current paid subscription goes only on the new plan — Omi Pro (
unlimited_v2, $29.99/mo, $269.91/yr, 7-day trial, fair use) — on mobile (ios/android) and web. Legacy plan prices and entitlements are untouched. Existing subscribers keep, see and manage their current plan exactly as today.Desktop is out of scope:
macos/windowscatalog, checkout and manage flows are unchanged.Missing / unknown
X-App-Platformkeeps the pre-ruling behaviour (review follow-up): every desktop build ever shipped stamps the header on every request — macOS since the first desktop commit (d51d10136e1c, Feb 2026), Windows since its platform-identity hardening (Jul 2026) — and the other desktop-identifying headers (X-Desktop-Request-ID,X-Omi-Plan-Identity,X-Device-Id-Hash) are all newer than the platform header, so a header-less request has no reliable desktop signal. Desktop compatibility outranks closing the header-less direct-API gap, so those callers are not restricted; their legacy-price checkouts are counted in the guard metric underunknown_platform_allowed. Explicitios/android/webvalues get the restriction.What changed
backend/utils/subscription.py→filter_plans_for_user: abasiccaller on an explicit non-desktop platform (mobile or web) is offered only theunlimited_v2entries in/v1/payments/available-plansand/v1/users/me/subscription. Old mobile builds get the same single plan through the existing legacy adaptation. Catalog filtering keys off the same period-valid plan lookup as checkout (get_user_valid_subscription): a lapsed Operator/Architect record is a basic buyer and gets the Omi Pro offer, not their expired desktop SKU.backend/routers/storefront.py+backend/utils/storefront.py→build_single_plan_storefront:GET /v2/payments/plansserves a new buyer on mobile/web a single-tier Omi Pro sheet (monthly + annual with a yearly toggle,Get UnlimitedCTA, Free current row) instead of a 404 — the web plans panel has no catalog fallback, so the 404 rendered as a dead "Couldn't load plans" panel. Desktop, missing/unknown platforms, and current subscribers keep the ladder sheet;NEW_BUYER_SINGLE_PLAN_ENABLED=falserestores the ladder sheet for everyone. The web client ranksunlimited_v2on its ladder (web/app/src/lib/planStorefront.ts) so that card can check out; existingunlimited_v2subscribers still see a legacy current row and never check out from it./v1/payments/checkout-sessionroutesX-App-Platformintonew_buyer_single_plan_violationafter every subscriber escape; a non-desktop buyer with no current paid subscription posting any non-unlimited_v2price gets a 400: "Omi Pro is the only plan available for new subscriptions. Existing subscribers keep their current plan." Only a current recurring personal subscription exempts a caller — an organization grant (pi_…PaymentIntent, or no subscription id) is a new buyer for checkout. Existing rules are unchanged: current subscribers' plan changes, legacy → ladder blocks, pending-cancellation same-price reactivation (including legacy prices), and desktop checkout.NEW_BUYER_SINGLE_PLAN_ENABLED, default on;false/0/off/norestores the pre-ruling catalog, storefront and checkout targets everywhere. Registered inconfig/feature-flags.yaml;backend/docs/feature-flag-registry.mdregenerated.omi_new_buyer_checkout_rejected_total{reason,plan}with the closed reason vocabulary:non_omi_pro_price(rejections on mobile/web) andunknown_platform_allowed(legacy prices allowed because the platform header is missing/unknown — an allowance count, not a rejection; do not sum reasons blindly). Label surfaces are closed by construction and zero-initialized at import; no identifiers.unlimited_v2(unit test); the web plans sheet renders both Omi Pro intervals and checks out the selected price (test), and the web storefront panel now renders + checks out the v2 single-tier sheet (golden fixturesingle_plan_omi_pro+ component test). No new icons, no l10n changes beyond the storefront copy system's newget_unlimitedCTA key in every locale..github/agent-docs/plan-catalog.mdrecords the ruling, the platform matrix, the grant boundary and the code map.Not changed
unlimited_v2display title stays "Unlimited"; the Omi Pro product-naming collision stays a separate open question.Validation
backend/test.sh(BACKEND_UNIT_TEST_FILE_LIST, file-isolated,BACKEND_PYTEST_WORKERS=4), on the pushed tree:test_subscription_restructure.pywithBACKEND_PYTEST_MARK_EXPR="not integration"(its slow-marked audience guardrails): 34 passed.cd app && bash test.sh test/widgets/plans_sheet_selection_test.dart test/unit/paywall_experiment_test.dart(unchanged from the earlier push; no app code touched since).bun run checkafterbun install: typecheck clean, 154 files / 874 tests passed, including the new single-plan PlansSheet and storefront Omi Pro tests;bun run lint: passed (pre-existing warnings only).Merge upkeep (not part of the reviewed change)
origin/mainmoved under this PR three times today (direct train pushes) and was merged in each time. The middle move landed breakage that PR CI had never measured, failing every backend shard of this PR's merge ref; two labeledfix(...)commits repaired it — and main has since landed equivalent upstream fixes, which the final merge takes (the branch now carries main's versions of those three files). For the record:utils/retrieval/tools/omi_tools.py,utils/retrieval/tools/result_bounds.py,utils/wrapped/generate_2025.py) failing the per-shard typecheck;pyright -p pyrightconfig.json→ 0 errors.test_omi_tools_resilience.pysetup crash — importlib fallbacks execing modules without registeringsys.modules, somodel_text.py's@dataclassstring-annotation resolution died. Fixed by registering beforeexec_module.test_payment_declined_proration.pyCPU-guard overruns (from main612b01861b) — 1.29–1.95s CPU per test vs the 1.00s fast-unit limit; grandfathered intests/fast_unit_duration_allowlist.txtper its established boundary-entry pattern (assertions pass).Line-Count-Exception: backend/utils/subscription.py | 2070 -> 2265 | single-plan rule: catalog filter, checkout guard (platform matrix + grant exemption), closed guard-metric labels
Line-Count-Exception: backend/utils/metrics.py | 1523 -> 1537 | omi_new_buyer_checkout_rejected_total counter with two-reason vocabulary
Line-Count-Exception: backend/routers/payment.py | 1827 -> 1846 | X-App-Platform routed into the checkout single-plan guard; catalog keys off the period-valid plan
Failure-Class: none
UI-Evidence: none -- the only UI-tree files touched are the regenerated desktop Swift API DTO (parameter order for the checkout header; no visible UI change) and web plans-panel logic/tests whose visible behavior is covered by the component tests above
🤖 Generated with Claude Code