You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
refactor(billing): use canonical status and preserve legacy rail (#14614)
## Summary
Part 3/4 of the workspace/billing rollout retirement stack. Standardizes
Cloud subscription discovery on canonical workspace billing status while
preserving explicit `legacy_stripe` account operations.
Predecessor:
[#14613](#14613).
Successor:
[#14615](#14615).
## Root cause
Cloud subscription state was read from both
`/customers/cloud-subscription-status` and `/api/billing/status` with
different response types and cancellation fields (`end_date` versus
`cancel_at`). That allowed stale rail selection and could mix workspace
status/balance with legacy top-up and management behavior.
## Changes
- Read Cloud subscription status only from `/api/billing/status` using
the canonical type and `cancel_at`.
- Avoid ingress status requests for non-Cloud builds.
- Preserve `legacy_stripe` balance, top-up, and management while unified
checkout remains workspace-backed.
- Keep `consolidated_billing_enabled` routing intact.
- Dispatch the production pending-checkout event in the Playwright
helper.
- Strengthen the rail regression to prove canonical discovery, no
old-status request, legacy balance/credits visibility, and rejection of
stale workspace zero balance.
## AS IS
Two status contracts can compete, and cancellation/rail state can be
stale or translated inconsistently.
## TO BE
Canonical status selects the rail; explicit legacy Stripe continues
legacy account operations and unified checkout. No intended visual
change, so no screenshot is required.
## Regression coverage
- Canonical Cloud status and non-Cloud no-ingress behavior.
- Canonical cancellation in watcher and legacy adapter.
- Adapter switching and stale-rail failure.
- Playwright regression serves `consolidated_billing_enabled: true` +
`legacy_stripe`, observes canonical status and legacy balance, proves
old status absent, and verifies credits/top-up UI without stale zero
balance.
## Validation
- 4 focused Vitest files: 79 tests passed.
- `pnpm typecheck` and `pnpm typecheck:browser` passed via commit hooks.
- targeted format/lint passed via commit hooks.
- `git diff --check dante/retire-team-workspace-flag...HEAD` passed.
- `pnpm knip --cache` passed via push hook.
- Focused Playwright legacy-rail regression passed against local Cloud
dev server (1 passed). The full two-test file had one transient initial
boot timeout on its first run; its second pricing-flow test passed, and
the focused failed case passed on rerun.
## Review focus
Review only canonical status/cancellation semantics and the
legacy-account/unified-checkout boundary. Consolidated flag retirement
belongs to part 4.
## Stack/deployment order
1. [#14612](#14612) —
recovery foundation
2. [#14613](#14613) —
retire team workspace rollout flag
3. **This PR** — canonical status and legacy rail preservation
4. [#14615](#14615) —
retire consolidated billing rollout flag
Deploy the frontend stack before the backend removes `/api/features`
compatibility keys.
---------
Co-authored-by: Connor Byrne <c.byrne@comfy.org>
Co-authored-by: Amp <amp@ampcode.com>
0 commit comments