Repository navigation
[backport cloud/1.60] M4 feat(billing): members see the auto top-up block; refused Add credits shows the served reason (#22696, #22711) - #22794
Conversation
…o the billing SDK (#22746) ## Why The ComfyUI Billing tab and Platform billing implement the same sections twice, so every rule change lands as two PRs and drifts. Agreed in #proj-billing: rules and UI move into the Billing SDK, ComfyUI being the default look and Platform overriding styling. This is the first step: the framework-free section rules move into `@comfyorg/account-core/billing` so account-ui (FRONT-3797) and Platform (FRONT-3801) can consume them. ## How - Moved with their tests, unchanged in logic, into `packages/account-core/src/core/billing/billingTab/`: `planRow`, `planLifecycle`, `creditsCard`, `planCheckoutBanner`, `topupCheckoutBanner`. Exported from `@comfyorg/account-core/billing`. - Extracted the auto top-up card state derivation from `useBillingAutoTopUpCard` as `deriveAutoTopUpCard({ isLoading, settings })` (same precedence: served settings win, else loading, else unavailable), with a table test. The scoped auto top-up reader stays in the app; it moves with #22413 (FRONT-3650). - No new package dependency: `billing-core` type aliases are replaced by the `ingest-types` types they re-export, and `deriveCreditsCard` takes a structural `CreditsCardBalance` instead of the app's `BalanceInfo` (which satisfies it). - App components and composables only rewire imports to the package; nothing is duplicated. Moving the remaining consumers is FRONT-3799. - Inputs stay served facts as received, outputs discriminated view states; no role/tier/`isCloud` checks (`lint:server-facts` clean). ## Dependency graph ```mermaid flowchart LR F3650[FRONT-3650 auto top-up reader in SDK #22413] --> F3796 F3796 --> M4[Unmerged PRs rebuilt on the SDK: #22696 #22711 #22437 #22435 #22431 #22717] F3796[FRONT-3796 account-core rules] --> F3797[FRONT-3797 account-ui components] F3796 --> F3799[FRONT-3799 Migration: ComfyUI reads SDK rules] F3797 --> F3798[FRONT-3798 Publish to npm] F3796 --> F3798 F3797 --> F3800[FRONT-3800 Migration: ComfyUI renders account-ui] F3799 --> F3800 F3798 --> F3801[FRONT-3801 Integration: Platform billing] DPLAT[DPLAT-2852 Platform reads via SDK #1547 #1518] --> F3801 F3793[FRONT-3793 Add credits dialog package] -. same package home .- F3797 ``` ## AS IS / TO BE No UI change: a module move with behaviour unchanged. Covered by the moved rule tests (account-core: 100 files, 1896 tests) and the Billing tab component tests (`src/platform/billing`, `settings`: 135 files, 3395 tests), all passing. - Fixes FRONT-3796 ## After the SDK rebuild Rendered from the stack top (e6202d5), behaviour unchanged by the rebuild unless noted. | State | Render | | --- | --- | | `plan-active` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/plan-active.png"> | | `credits-plan` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/credits-plan.png"> | | `autotopup-on` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/autotopup-on.png"> | | `banner-plan-verify-payment` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/banner-plan-verify-payment.png"> | | `banner-topup-processing` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/banner-topup-processing.png"> | No UI change; same render after the move. (cherry picked from commit d5049a6)
Workspace members could not see that auto top-up exists: the block rendered only for owners who can manage it. Members should see it for discoverability and know who to ask. - `useBillingCapabilities` exposes `manageAutoTopUpDenial` from the served `denied_reasons.can_manage_auto_top_up`, the same way `runWorkflowsDenial` is exposed. - New `BillingAutoTopUpMemberCard` renders a title and one line when that denial is `not_workspace_owner`. `BillingTab` mounts it inside the existing `auto_top_up_enabled` gate, so it shows only when both served facts hold. No client role/tier check. - The member block never calls `ensureRead`, so `GET /api/billing/auto-reload` stays owner-only. No status, button or settings; Add credits stays on `can_top_up`. The owner card is unchanged. - The block has the same title + one line structure as the owner Off row. - Copy added to `en` and the other 14 locales (`pnpm locale:check` accepts them). - DES-1301 - Figma member row: https://www.figma.com/design/C1fxz3akrW7Pl22zM2b301/Unified-Settings---Billing?node-id=3039-12853 (states matrix node 2112-9443) - Ticket: https://linear.app/comfyorg/issue/FRONT-3738 - `BillingTab.test.ts`: a member (`not_workspace_owner`) sees the title and line, with no status, button, link or Add credits, and no auto-reload read. The block stays hidden when the flag is off, for `not_a_member`, when no denial is sent, and for an owner. The existing owner card tests pass unchanged. - I mutation-checked the gate: loosening the denial comparison makes the hide cases fail. | | AS IS (main) | TO BE (this PR) | |---|---|---| | Member, auto top-up on | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-on-asis.png" width="560"> | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-on-tobe.png" width="560"> | | Member, auto top-up off | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-off-asis.png" width="560"> | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-off-tobe.png" width="560"> | | Owner, auto top-up on (unchanged) | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-owner-on-asis.png" width="560"> | <img src="https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-owner-on-tobe.png" width="560"> | Full Billing tab, member: [AS IS](https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-on-asis-dialog.png) / [TO BE](https://gist.githubusercontent.com/dante01yoon/e881af82d860506bdd71666bc754bc21/raw/069c56c4fd51ff3eb2dc537160e16ac3ea17c8be/pr22696-member-on-tobe-dialog.png) All responses are mocked. Captured headless in the cloud build (`DEV_SERVER_COMFYUI_URL=https://testcloud.comfy.org/` dev server, nothing signed in) with the repo's Playwright cloud harness (`setupCloudApp`, `cloudAppFixture`) on a team workspace, `unified_billing_settings` via `ff:` override. `GET /api/billing/capabilities` serves `auto_top_up_enabled: true`; for the member rows `can_manage_auto_top_up: false` with `denied_reasons.can_manage_auto_top_up: "not_workspace_owner"`, for the owner row `can_manage_auto_top_up: true`. `GET /api/billing/auto-reload` is mocked `status: on` or `off`; the member never requests it, so the two member TO BE shots are pixel-identical. The owner card is pixel-identical between AS IS and TO BE. Fixes FRONT-3738 Rendered from the stack top (e6202d5), behaviour unchanged by the rebuild unless noted. | State | Render | | --- | --- | | `member-block` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/member-block.png"> | | `tab-full-owner` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/tab-full-owner.png"> | (cherry picked from commit d5841ab)
…eason (#22711) ## Summary **Why:** Alex's decision: a refused Add credits uses the same cases, logic and copy on both sites. Today every surface hides Add credits whenever `can_top_up` is false, so an owner refused for any reason other than membership gets no button, no explanation and, in the out-of-credits banners, no banner at all. **How:** - New pure helper `addCreditsAvailability` maps the served `can_top_up` and `denied_reasons.can_top_up` to `enabled | hidden | disabled + reason`. It hides only for `not_workspace_owner` and `not_a_member`. Every other refusal, including unrecognized values, shows the button disabled with a reason linked via `aria-describedby`: - `topup_purchases_paused`: "Buying credits isn't available right now. Try again later, or message support." - `payment_past_due`: "Update your payment method to add credits." - anything else: "Adding credits isn't available for this workspace right now." - It renders hidden until capabilities resolve, so an outage never flashes a refusal. - Used in the avatar popover, `CreditsTile` and `BillingCreditsCard`. Past due used to show an enabled Add credits that opened payment recovery. It now shows the disabled button with the reason plus a separate Update payment action gated on `payment_recovery_available`. Update payment also stays in the past-due banners. - Out-of-credits banners (`BillingStatusBanner`, `BillingLocalCreditBanner`) read `topUpDenial` instead of `can_manage_subscription`. Member reasons keep the "ask your workspace owner" body, a paused refusal uses the paused line, and any other refusal gets a body with no instruction. - Two E2E assertions that expected the refused button to be absent now expect it to be disabled. Not included: - The Enterprise copy ("Your credits are managed through your sales contract.") waits on a server reason. No value maps to it yet. - Optional B1 (past-due banner title "Payment failed") is left for a follow-up. ## Verification - `pnpm exec vitest run` on the helper and on the touched component suites (popover, CreditsTile, BillingCreditsCard, BillingStatusBanner, BillingLocalCreditBanner, BillingTab): 348 passed. The new tests failed first. - Also ran the consumer suites (WorkspaceSettingsPanelContent, SubscriptionPanelContentWorkspace, CreditsPanel, BillingAutoTopUpCard, CurrentUserButton): 124 passed. - E2E not run locally. CI covers the two adjusted specs. ## AS IS / TO BE Personal Pro owner, out of credits, `can_top_up: false`. Local cloud dev server with mocked billing endpoints and `unified_billing_settings` on. AS IS is `main` (dcb6476). | State | AS IS | TO BE | | --- | --- | --- | | Paused (`topup_purchases_paused`), avatar popover | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-asis-paused-popover.png" width="400"> | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-tobe-paused-popover.png" width="400"> | | Paused, Settings > Billing | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-asis-paused-billing.png" width="400"> | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-tobe-paused-billing.png" width="400"> | | Past due (`payment_past_due`, `payment_recovery_available: true`), avatar popover | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-asis-pastdue-popover.png" width="400"> | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-tobe-pastdue-popover.png" width="400"> | | Past due, Settings > Billing | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-asis-pastdue-billing.png" width="400"> | <img src="https://gist.githubusercontent.com/dante01yoon/fa694139ad89134570759157df87409a/raw/627e8b5c321e26c7b40eb48483a8f46e104453f8/pr22711-tobe-pastdue-billing.png" width="400"> | ## After the SDK rebuild Rendered from the stack top (e6202d5), behaviour unchanged by the rebuild unless noted. | State | Render | | --- | --- | | `credits-refused-paused` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/credits-refused-paused.png"> | | `credits-refused-pastdue` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/credits-refused-pastdue.png"> | | `banner-out-of-credits-member` | <img width="480" src="https://gist.githubusercontent.com/dante01yoon/aa35483cb18885036fe69ae26581459f/raw/b6a16e0bc3d5b6099a1bd2dd3074b3b3726bdf65/banner-out-of-credits-member.png"> | (cherry picked from commit ee386d7)
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords: 2
Please check the settings in the CodeRabbit UI or the
|
🎭 Playwright: ✅ 3216 passed, 0 failed · 2 flaky📊 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. Fallow gates on new findings in changed files only, so everything below was introduced or moved by this PR (66 changed files).
Pre-existing findings are baselined in Full docs: ADR-DEVEX-LINT-0015 Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 0ed5cbfee06345165372814387d369049e15e8f8
🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (353)
Full docs: Frontend domain catalog Reproduce locallypnpm architecture:check |
|
Closing: this backport carried #22746 (After M4), which must not go to 1.60. Replaced by per-change backports rebuilt on 1.60's existing app-side code. |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## cloud/1.60 #22794 +/- ##
=============================================
Coverage ? 87.56%
=============================================
Files ? 2995
Lines ? 162545
Branches ? 41758
=============================================
Hits ? 142338
Misses ? 19274
Partials ? 933
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Why
The automatic
cloud/1.60backports of #22696 (members see the auto top-up block) and #22711 (refused Add credits shows disabled with the served reason) failed with conflicts. Both M4 changes are built on #22746, which moved the Billing tab section rules into@comfyorg/account-core/billingand is not oncloud/1.60.How
Cherry-picks, in merge order with
-x:Verified on this branch: billing, account-core and settings unit tests pass (3422), and
pnpm typecheck:appis clean.AS IS / TO BE: same UI as the original PRs; screenshots are in #22696 and #22711.