From fa5ae4f180bd883791e2f75a849f4d1d38b666ed Mon Sep 17 00:00:00 2001 From: Dante Date: Thu, 29 Oct 2026 06:17:12 +0000 Subject: [PATCH] FRONT-3626 fix(billing): fill the handoff card, add the plan credit meter, and say Available until on an ending plan (#22181) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FRONT-3626 "Moved before the flag" items 1, 2 and 4. Alex checked the Billing tab live on testcloud, and these read as broken rather than unpolished, so they go into 1.59 before `unified_billing_settings` turns on in production. 1. The owner handoff card had only its button. The "Manage everything else about billing on platform.comfy.org" line and the footer (Partner Nodes pricing · Message support) from DES-1232 were never built. 2. The Credits card rendered the plan cell as one bold line, "{x} of {y} Refills {date}", with no meter or "% used". 4. An ending plan still said "Refills {date}". Its credits don't refill, so the line should be "Available until {date}". 1. **Handoff card:** the owner card shows the line, with platform.comfy.org linked through the same `usePlatformHandoff` link and telemetry as Open billing ↗. - **Footer:** Partner Nodes pricing goes to `docsPaths.partnerNodesPricing`. Message support reuses `handleMessageSupport`, the existing `Comfy.ContactSupport` command. 2. **Plan cell:** two lines. - Line 1: the bold remaining amount and a muted "of {total}". - Line 2: the date line and "{n}% used". - A meter (`role="meter"`) sits between them. - % used is presentation math on the served plan credits and the total the card already has. - With no total there's no "of", meter or %. 3. **Ending plan (item 4):** gets `availableUntil` with the end date. Notes: - The member handoff card is unchanged; Figma shows only the owner card. | AS IS | TO BE | | --- | --- | | _screenshot pending_ | _screenshot pending_ | | Item | PR | Status | | --- | --- | --- | | Paused plan row + refill line | #22171 | open | | Before-the-flag 1, 5, 7 | #22176 | open | | Before-the-flag 2, 3 | #22177 | open | | Before-the-flag 4, 6 | #22175 | open | | **Moved before the flag 1, 2, 4 (handoff card, plan cell meter, Available until)** | **this PR** | **open** | | Moved before the flag 3, 5 (Enterprise row, Complete verification) | ```mermaid graph LR T["FRONT-3626 moved before the flag"] --> D["This PR: items 1, 2, 4"] T --> E["PR 22180: items 3, 5"] style D fill:#f9d71c,stroke:#333 ``` Siblings touch `BillingTab.vue`, `BillingCreditsCard.vue` and `creditsCard.ts` (#22171/#22174 paused refill line, #22177 Add credits emphasis); whichever lands second merges main and is re-verified. (cherry picked from commit e370de9c0197c30dd8a5b2edb2112b0bc2d4b48b) --- src/locales/en/main.json | 10 +- .../billingTab/BillingCreditsCard.test.ts | 99 +++++++++++-- .../billingTab/BillingCreditsCard.vue | 52 +------ .../billingTab/BillingCreditsPlanCell.vue | 130 ++++++++++++++++++ .../billingTab/BillingLocalCreditBanner.vue | 10 +- .../components/billingTab/BillingTab.test.ts | 63 ++++++++- .../components/billingTab/BillingTab.vue | 52 ++++++- .../components/billingTab/creditsCard.ts | 35 ++++- .../billingTab/useBillingCreditsCard.ts | 3 +- .../settings/BillingStatusBanner.vue | 9 +- .../billing/composables/useLongDate.test.ts | 48 +++++++ .../billing/composables/useLongDate.ts | 19 +++ .../composables/useSubscriptionActions.ts | 48 ++++--- 13 files changed, 472 insertions(+), 106 deletions(-) create mode 100644 src/platform/billing/components/billingTab/BillingCreditsPlanCell.vue create mode 100644 src/platform/billing/composables/useLongDate.test.ts create mode 100644 src/platform/billing/composables/useLongDate.ts diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 85a40305722..b99bb1498bc 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3632,10 +3632,12 @@ "credits": { "addCredits": "Add credits", "available": "Available", + "availableUntil": "Available until {date}", "inUse": "In use now", "overdrawn": "Your runs used {count} more credit than you had. | Your runs used {count} more credits than you had.", "plan": "Plan", "planOfPool": "{remaining} of {total}", + "planUsed": "{percent}% used", "planTooltip": "Credits included with your plan. They refill each billing period.", "rateInfo": "About credits", "rateTooltip": "Credits pay for runs. {credits} credits = $1.", @@ -3644,6 +3646,10 @@ "topUpTooltip": "Credits you added. They're used once plan credits run out.", "unavailable": "Couldn't load your balance." }, + "footer": { + "messageSupport": "Message support", + "partnerNodesPricing": "Partner Nodes pricing" + }, "handoff": { "member": { "action": "View usage", @@ -3651,7 +3657,9 @@ }, "owner": { "action": "Open billing", - "label": "Payment methods, invoices, and usage" + "label": "Payment methods, invoices, and usage", + "line": "Manage everything else about billing on {platform}", + "platform": "platform.comfy.org" } }, "loadError": "We couldn't load your plan.", diff --git a/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts b/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts index 9f8e6d75302..6707533aabd 100644 --- a/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts +++ b/src/platform/billing/components/billingTab/BillingCreditsCard.test.ts @@ -30,7 +30,8 @@ const activeFacts: CreditsCardFacts = { planKind: 'active', billingStatus: 'paid', planPoolCredits: 1000, - renewalDate: null + renewalDate: null, + endDate: null } const SUBSCRIBE_NOTE = @@ -108,7 +109,7 @@ describe('BillingCreditsCard', () => { case: 'a paused plan keeps the real balance and empties the plan line', facts: { billingStatus: 'paused', planKind: 'paused' }, available: '1,477', - plan: '0 of 1,000 Refills when the payment goes through', + plan: '0 of 1,000', topUp: '633', inUse: false, addCredits: true, @@ -223,15 +224,86 @@ describe('BillingCreditsCard', () => { ) }) - it('ends the plan line with the renewal date', () => { - renderCard({ - ...activeFacts, - renewalDate: '2026-10-01T00:00:00Z' - }) + it.for<{ + case: string + facts: Partial + amount: string + date: string + used: string | null + meter: string | null + }>([ + { + case: 'an active plan refills on its renewal date', + facts: { renewalDate: '2026-10-01T00:00:00Z' }, + amount: '844 of 1,000', + date: 'Refills October 1, 2026', + used: '16% used', + meter: '16' + }, + { + case: 'an ending plan is available until its end date', + facts: { + planKind: 'ending', + renewalDate: '2026-10-01T00:00:00Z', + endDate: '2026-12-31T12:00:00Z' + }, + amount: '844 of 1,000', + date: 'Available until December 31, 2026', + used: '16% used', + meter: '16' + }, + { + case: 'a plan with no known total shows no meter', + facts: { planPoolCredits: null, renewalDate: '2026-10-01T00:00:00Z' }, + amount: '844', + date: 'Refills October 1, 2026', + used: null, + meter: null + }, + { + case: 'a paused plan keeps the pool but shows no usage', + facts: { + billingStatus: 'paused', + planKind: 'paused', + renewalDate: '2026-10-01T00:00:00Z' + }, + amount: '0 of 1,000', + date: 'Refills when the payment goes through', + used: null, + meter: null + }, + { + case: 'used-up plan credits fill the meter', + facts: { balance: balanceOf({ effective: 300, plan: 0, topUp: 300 }) }, + amount: '0 of 1,000', + date: '', + used: '100% used', + meter: '100' + } + ])('splits the plan cell for $case', (row) => { + renderCard({ ...activeFacts, ...row.facts }) expect(screen.getByTestId('billing-credits-plan').textContent.trim()).toBe( - '844 of 1,000 Refills October 1, 2026' + row.amount ) + expect( + screen.queryByTestId('billing-credits-plan-date')?.textContent.trim() ?? + '' + ).toBe(row.date) + expect( + screen.queryByTestId('billing-credits-plan-used')?.textContent.trim() ?? + null + ).toBe(row.used) + expect( + screen.queryByRole('meter')?.getAttribute('aria-valuenow') ?? null + ).toBe(row.meter) + }) + + it('shows nothing under the amount without a date or a total', () => { + renderCard({ ...activeFacts, planPoolCredits: null }) + + expect(screen.queryByTestId('billing-credits-plan-date')).toBeNull() + expect(screen.queryByRole('meter')).toBeNull() }) it('waits for the payment instead of a renewal date on a paused plan', () => { @@ -242,9 +314,10 @@ describe('BillingCreditsCard', () => { renewalDate: '2026-11-23T00:00:00Z' }) - expect(screen.getByTestId('billing-credits-plan').textContent.trim()).toBe( - '0 of 1,000 Refills when the payment goes through' - ) + expect( + screen.getByTestId('billing-credits-plan-date').textContent.trim() + ).toBe('Refills when the payment goes through') + expect(screen.queryByRole('meter')).toBeNull() }) it('puts the credits title above a 12px card', () => { @@ -263,9 +336,7 @@ describe('BillingCreditsCard', () => { 'text-2xl', 'font-medium' ) - expect(screen.getByTestId('billing-credits-plan')).toHaveClass( - 'font-semibold' - ) + expect(screen.getByText('844')).toHaveClass('font-semibold') }) it('asks for the balance again from Try again', async () => { diff --git a/src/platform/billing/components/billingTab/BillingCreditsCard.vue b/src/platform/billing/components/billingTab/BillingCreditsCard.vue index 8cf862b9ebe..42dd295128e 100644 --- a/src/platform/billing/components/billingTab/BillingCreditsCard.vue +++ b/src/platform/billing/components/billingTab/BillingCreditsCard.vue @@ -82,25 +82,7 @@
-
- - {{ $t('workspacePanel.billingTab.credits.plan') }} -