Repository navigation
[backport core/1.60] fix(billing): hide auto top-up while billing is paused (#23323) - #23339
Conversation
## Summary Per [DES-1240](https://linear.app/comfyorg/issue/DES-1240) (Not available row) and Alex's call in the #23278 review thread, auto top-up is hidden with no Turn on while a plan is paused. Cloud still offered Turn on for `auto_top_up_setup` frozen with `billing_paused`; Platform already offered no action. - **Why:** auto top-up can't charge while billing is paused. It comes back as it was once the payment goes through. - **Root cause:** `canSetUpAutoTopUp` only treated `payment_past_due` as paused. The account-ui card hid only `state: 'unavailable'`. - **How:** account-core adds `isAutoTopUpNotAvailable(setup)`. It returns true when setup is `unavailable`, or `frozen` for `payment_past_due` or `billing_paused`. - `canSetUpAutoTopUp` uses it, which covers the top-up dialog's Set up offer and the Add credits suggestion. - The account-ui `BillingAutoTopUpCard` hides on it, and so does the card-viewed event. - `TopUpAutoTopUpCard` reads `canSetUpAutoTopUp` instead of its inline copy. This is the same swap as #23278, so whichever PR lands second needs a trivial rebase. - Server facts: the rule renders the served setup state and reason. It does not combine them with role, plan or tier. - The 1.60 code under `legacy160` is unchanged. | | AS IS | TO BE | |---|---|---| | setup frozen, `billing_paused` | card shows Off · Turn on ↗; dialog offers Set up | card hidden; no Set up offer | | setup frozen, `payment_past_due` | card shown; no Set up offer | card hidden; no Set up offer | ```mermaid graph LR A[#23278 platformAutoTopUpPath] -. touches same lines of TopUpAutoTopUpCard .- B[this PR] ``` ## Verification - `vitest`: account-core `autoTopUpCard` and `addCredits` (230 passed); account-ui `BillingAutoTopUpCard` (19 passed); app `TopUpAutoTopUpCard`, `useAutoTopUpCardSection`, `useAutoTopUpSetupOffer` (71 passed). - Mutation check: I dropped `billing_paused` from the rule and re-ran. The new card case and the new `TopUpAutoTopUpCard` case both failed, then passed once I restored it. - Not checked against a live backend in the paused state. (cherry picked from commit 4d07c59) # Conflicts: # packages/account-core/src/core/billing/billingTab/autoTopUpCard.test.ts # packages/account-core/src/core/billing/billingTab/autoTopUpCard.ts # packages/account-core/src/core/billing/index.ts # packages/account-ui/src/billing/tab/BillingAutoTopUpCard.test.ts # packages/account-ui/src/billing/tab/BillingAutoTopUpCard.vue # src/platform/billing/composables/useAutoTopUpCardSection.ts
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords: 2
Please check the settings in the CodeRabbit UI or the
|
🎭 Playwright: ✅ 3232 passed, 0 failed📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure
Findings and check detailsExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight The matrix runs on same-repository version-bump PRs with relevant changes, main-branch pushes, and manual dispatches. This candidate does not qualify, so every expensive stage was skipped. Full docs: scripts/registry-census/README.md Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
🌾 Fallow: ✅ PassedFindings and check detailsFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Full docs: ADR-DEVEX-LINT-0015 Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 888b274a2f617b0323be1e776c8d24334aa22b00
🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (394)
Full docs: Frontend domain catalog Reproduce locallypnpm architecture:check |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## core/1.60 #23339 +/- ##
=============================================
+ Coverage 87.43% 87.53% +0.09%
=============================================
Files 2920 3028 +108
Lines 160682 164068 +3386
Branches 40900 44123 +3223
=============================================
+ Hits 140494 143612 +3118
- Misses 19425 19525 +100
- Partials 763 931 +168
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 109 files with indirect coverage changes 🚀 New features to boost your workflow:
|
🔧 Auto-fixes AppliedThis PR has been automatically updated to fix linting and formatting issues.
Changes made:
|
… paused (#23323) (#23340) Manual backport of #23323 (merged as 4d07c59) to `cloud/1.60`. The bot's cherry-pick failed with conflicts. ## Why Per DES-1240 and Alex's call in the #23278 review, auto top-up is "not available" while a plan is paused: no Turn on, no Set up. On cloud/1.60, the top-up dialog still offered Set up and the Billing tab card still showed Off · Turn on when `auto_top_up_setup` is `frozen` for `billing_paused`. The Billing tab card also stayed visible for `payment_past_due`. ## Root cause - `TopUpAutoTopUpCard.vue` only treated `frozen` + `payment_past_due` as paused. - The Billing tab `BillingAutoTopUpCard.vue` (and its card-viewed event) hid only on `state: 'unavailable'`. ## How (adapted) - `isAutoTopUpNotAvailable(setup)` goes into the existing `packages/account-core/src/core/billing/capabilities.ts` and is exported from `@comfyorg/account-core/billing`. True for `unavailable`, or `frozen` for `payment_past_due` / `billing_paused`. Same rule and body as main. - `TopUpAutoTopUpCard.vue` uses it in its inline `canSetUp`. - `src/platform/billing/components/billingTab/BillingAutoTopUpCard.vue` hides on it, and so does its card-viewed event. - No feature flag: this is a bug fix. ### Conflict notes | Main file in #23323 | On cloud/1.60 | Resolution | |---|---|---| | `account-core/.../billingTab/autoTopUpCard.ts` (+ test) | missing (1.61 SDK billing tab) | dropped; the helper goes into existing `capabilities.ts`, and its table test into `capabilities.test.ts` | | `account-core/.../billing/index.ts` | export list differs | kept cloud/1.60's list; added one export | | `account-ui/.../BillingAutoTopUpCard.vue` (+ test) | missing; the 1.60 card is `src/platform/billing/components/billingTab/BillingAutoTopUpCard.vue` | same change applied to the 1.60 card; test ported to its test file | | `useAutoTopUpCardSection.ts` | missing; the 1.60 card-viewed call lives in the card itself | same change applied in the card | | `TopUpAutoTopUpCard.vue` | `canSetUpAutoTopUp` is not on cloud/1.60 | kept the inline `canSetUp`; replaced its paused check with the helper | | `TopUpAutoTopUpCard.test.ts` | applied cleanly | unchanged from main | | | AS IS | TO BE | |---|---|---| | setup frozen, `billing_paused` | Billing tab card shows Off · Turn on; dialog offers Set up | card hidden; no Set up offer | | setup frozen, `payment_past_due` | card shown; no Set up offer | card hidden; no Set up offer | ```mermaid graph LR M[#23323 on main] --> C[backport core/1.60] M --> L[backport cloud/1.60] ``` ## Test evidence - `vitest` (app): `TopUpAutoTopUpCard.test.ts` + `billingTab/BillingAutoTopUpCard.test.ts`: 61 passed. - `vitest` (account-core): `capabilities.test.ts`: 59 passed, including the new `isAutoTopUpNotAvailable` table. - Red check: with only the two `.vue` files reverted to cloud/1.60, 3 tests fail (`shows the prompt: false while setup is frozen for billing_paused`, `renders nothing when setup is frozen for billing_paused`, `renders nothing when setup is frozen for payment_past_due`). They pass with the fix. - `pnpm typecheck`, `pnpm typecheck:account-core`, oxlint + eslint on changed files, and account-core `lint`: clean. - Not checked against a live backend in the paused state. Same commit as the core/1.60 backport: #23339 (cherry-picked cleanly onto cloud/1.60; the same tests, red check, typecheck and lint were re-run here).
Manual backport of #23323 (merged as 4d07c59) to
core/1.60. The bot's cherry-pick failed with conflicts.Why
Per DES-1240 and Alex's call in the #23278 review, auto top-up is "not available" while a plan is paused: no Turn on, no Set up. On core/1.60, the top-up dialog still offered Set up and the Billing tab card still showed Off · Turn on when
auto_top_up_setupisfrozenforbilling_paused. The Billing tab card also stayed visible forpayment_past_due.Root cause
TopUpAutoTopUpCard.vueonly treatedfrozen+payment_past_dueas paused.BillingAutoTopUpCard.vue(and its card-viewed event) hid only onstate: 'unavailable'.How (adapted)
isAutoTopUpNotAvailable(setup)goes into the existingpackages/account-core/src/core/billing/capabilities.tsand is exported from@comfyorg/account-core/billing. True forunavailable, orfrozenforpayment_past_due/billing_paused. Same rule and body as main.TopUpAutoTopUpCard.vueuses it in its inlinecanSetUp.src/platform/billing/components/billingTab/BillingAutoTopUpCard.vuehides on it, and so does its card-viewed event.Conflict notes
account-core/.../billingTab/autoTopUpCard.ts(+ test)capabilities.ts, and its table test intocapabilities.test.tsaccount-core/.../billing/index.tsaccount-ui/.../BillingAutoTopUpCard.vue(+ test)src/platform/billing/components/billingTab/BillingAutoTopUpCard.vueuseAutoTopUpCardSection.tsTopUpAutoTopUpCard.vuecanSetUpAutoTopUpis not on core/1.60canSetUp; replaced its paused check with the helperTopUpAutoTopUpCard.test.tsbilling_pausedpayment_past_dueTest evidence
vitest(app):TopUpAutoTopUpCard.test.ts+billingTab/BillingAutoTopUpCard.test.ts: 61 passed.vitest(account-core):capabilities.test.ts: 59 passed, including the newisAutoTopUpNotAvailabletable..vuefiles reverted to core/1.60, 3 tests fail (shows the prompt: false while setup is frozen for billing_paused,renders nothing when setup is frozen for billing_paused,renders nothing when setup is frozen for payment_past_due). They pass with the fix.pnpm typecheck,pnpm typecheck:account-core, oxlint + eslint on changed files, and account-corelint: clean.