From 678656517f89c0848d08f74b0dbd8d43d985b1ab Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 00:11:11 -0400 Subject: [PATCH 1/7] fix(billing): say This plan has ended without an end date and keep one white button when an ended plan is out of credits An ended subscription with no served end date fell through to the unknown plan row: no status line and a Manage button, so it read like an active plan. The ended row now renders with or without ended_at, and subscription_state ended maps to it too. When an ended plan is out of credits, Choose a plan stays the white action on Cloud. On local ComfyUI Add credits takes white and Choose a plan turns grey, so there is still exactly one white button. --- src/locales/en/main.json | 1 + .../dialogs/settings/BillingTab.test.ts | 55 +++++++++++++++++++ .../dialogs/settings/BillingTab.vue | 4 +- .../components/billingTab/BillingPlanRow.vue | 24 +++++--- .../components/billingTab/planRow.test.ts | 17 +++++- .../billing/components/billingTab/planRow.ts | 14 +++-- 6 files changed, 102 insertions(+), 13 deletions(-) diff --git a/src/locales/en/main.json b/src/locales/en/main.json index bc809a0b813..0a129e48912 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3708,6 +3708,7 @@ "yearly": "Billed yearly. Next invoice {date}." }, "ended": "Ended {date}.", + "endedNoDate": "This plan has ended.", "ending": "Ends {date}. You won't be charged again.", "lifecycleRefused": "We couldn't make this change. Try again.", "managedByOwner": "Managed by the workspace owner.", diff --git a/src/platform/account/components/dialogs/settings/BillingTab.test.ts b/src/platform/account/components/dialogs/settings/BillingTab.test.ts index 1516ca16a07..984efd31cf6 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.test.ts +++ b/src/platform/account/components/dialogs/settings/BillingTab.test.ts @@ -1067,6 +1067,27 @@ describe('BillingTab', () => { ) }) + it.for([ + { + case: 'a served end date', + endDate: '2026-09-01T00:00:00Z', + line: 'Ended September 1.' + }, + { case: 'no end date', endDate: null, line: 'This plan has ended.' } + ])('reads an ended plan with $case as "$line"', ({ endDate, line }) => { + arrange({ + subscriptionStatus: 'ended', + subscription: { ...activeSubscription, isActive: false, endDate } + }) + + expect(screen.getByTestId('billing-plan-line').textContent.trim()).toBe( + line + ) + expect( + screen.getByRole('link', { name: 'Choose a plan' }) + ).toBeInTheDocument() + }) + it('renders an unrecognised plan as Your plan', () => { arrange({ subscription: { ...activeSubscription, tier: null } }) @@ -1288,6 +1309,40 @@ describe('BillingTab', () => { expect(addCreditsVariants()).toEqual(['secondary']) }) + it.for([ + { + surface: 'Cloud', + isCloud: true, + choosePlan: 'inverted', + addCredits: 'secondary' + }, + { + surface: 'local ComfyUI', + isCloud: false, + choosePlan: 'secondary', + addCredits: 'inverted' + } + ])( + 'keeps one white button on $surface when an ended plan is out of credits', + async ({ isCloud, choosePlan, addCredits }) => { + distribution.isCloud = isCloud + onTestFinished(() => { + distribution.isCloud = false + }) + arrange({ + balance: zeroBalance, + subscriptionStatus: 'ended', + subscription: { ...activeSubscription, isActive: false } + }) + + await screen.findByTestId('billing-auto-top-up-status') + expect( + screen.getByRole('link', { name: 'Choose a plan' }) + ).toHaveAttribute('data-variant', choosePlan) + expect(addCreditsVariants()).toEqual([addCredits]) + } + ) + it('offers no Add credits on a failed top-up when the server withholds can_top_up', async () => { servedCheckouts(checkout('failed')) arrange({ canTopUp: false }) diff --git a/src/platform/account/components/dialogs/settings/BillingTab.vue b/src/platform/account/components/dialogs/settings/BillingTab.vue index 395c02b504d..b81f223eb6e 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.vue +++ b/src/platform/account/components/dialogs/settings/BillingTab.vue @@ -59,6 +59,7 @@ :state="planRow" :action="action" :sales-variant="salesVariant" + :add-credits-variant="addCreditsVariant" :can-manage-subscription="capabilities.canManageSubscription.value" /> @@ -160,6 +161,7 @@ import Skeleton from '@comfyorg/design-system/skeleton/Skeleton' import { useBillingContext } from '@/platform/billing/composables/useBillingContext' import { useBillingDialogs } from '@/platform/billing/composables/useBillingDialogs' import { useFeatureFlags } from '@/composables/useFeatureFlags' +import { isCloud } from '@/platform/distribution/types' import { useExternalLink } from '@/composables/useExternalLink' import { useMessageSupport } from '@/platform/billing/subscription/composables/useSubscriptionActions' import { useTelemetry } from '@comfyorg/telemetry' @@ -252,7 +254,7 @@ const addCreditsVariant = computed(() => ? autoTopUp.value.settings.status : null, planActionIsPrimary: - action.value === 'subscribe' || action.value === 'choosePlan' + action.value === 'subscribe' || (action.value === 'choosePlan' && isCloud) }) ) diff --git a/src/platform/billing/components/billingTab/BillingPlanRow.vue b/src/platform/billing/components/billingTab/BillingPlanRow.vue index 9b680a219fc..55cb4b8843f 100644 --- a/src/platform/billing/components/billingTab/BillingPlanRow.vue +++ b/src/platform/billing/components/billingTab/BillingPlanRow.vue @@ -35,7 +35,11 @@ :href="plansHref" target="_blank" rel="noopener" - :variant="action === 'manage' ? 'secondary' : 'inverted'" + :variant=" + action === 'manage' || addCreditsVariant === 'inverted' + ? 'secondary' + : 'inverted' + " size="md" class="shrink-0 no-underline" @click="trackPlans" @@ -67,12 +71,14 @@ const { state, action, canManageSubscription, - salesVariant = 'secondary' + salesVariant = 'secondary', + addCreditsVariant = 'secondary' } = defineProps<{ state: PlanRowState action: PlanRowAction | null canManageSubscription: boolean salesVariant?: 'inverted' | 'secondary' + addCreditsVariant?: 'inverted' | 'secondary' }>() const { href: plansHref, track: trackPlans } = usePlatformHandoff( @@ -124,6 +130,14 @@ function noPlanLine(state: Extract) { : t(`${key}.freeRunsUsed`, { total }) } +function endedLine(state: Extract) { + const key = 'workspacePanel.billingTab.plan' + if (!state.endedAt) return t(`${key}.endedNoDate`) + return t(`${key}.ended`, { + date: formatPlanDate(state.endedAt, locale.value, state.cadence) + }) +} + const statusLine = computed(() => { const key = 'workspacePanel.billingTab.plan' if (state.kind === 'activating') { @@ -144,11 +158,7 @@ const statusLine = computed(() => { date: formatPlanDate(state.endsAt, locale.value, state.cadence) }) } - if (state.kind === 'ended') { - return t(`${key}.ended`, { - date: formatPlanDate(state.endedAt, locale.value, state.cadence) - }) - } + if (state.kind === 'ended') return endedLine(state) return '' }) diff --git a/src/platform/billing/components/billingTab/planRow.test.ts b/src/platform/billing/components/billingTab/planRow.test.ts index ebd2a228cf9..fa1a2104416 100644 --- a/src/platform/billing/components/billingTab/planRow.test.ts +++ b/src/platform/billing/components/billingTab/planRow.test.ts @@ -166,7 +166,22 @@ describe('derivePlanRow', () => { { case: 'an ended plan without an end date', facts: { subscriptionStatus: 'ended' }, - expected: { kind: 'unknown' } + expected: { + kind: 'ended', + planName: 'Pro', + cadence: 'monthly', + endedAt: null + } + }, + { + case: 'a served ended subscription_state', + facts: { subscriptionState: 'ended', subscriptionStatus: null }, + expected: { + kind: 'ended', + planName: 'Pro', + cadence: 'monthly', + endedAt: null + } }, { case: 'an active sales-managed plan with no served plan name', diff --git a/src/platform/billing/components/billingTab/planRow.ts b/src/platform/billing/components/billingTab/planRow.ts index 406615a7381..ade2d628645 100644 --- a/src/platform/billing/components/billingTab/planRow.ts +++ b/src/platform/billing/components/billingTab/planRow.ts @@ -44,7 +44,7 @@ export type PlanRowState = kind: 'ended' planName: string cadence: BillingCadence | null - endedAt: string + endedAt: string | null } | { kind: 'noPlan' @@ -105,6 +105,14 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { if (facts.subscriptionState === 'activating' && planName !== null) { return { kind: 'activating', planName } } + if (facts.subscriptionState === 'ended' && planName !== null) { + return { + kind: 'ended', + planName, + cadence: toCadence(facts.duration), + endedAt: endDate + } + } if (subscriptionStatus === null) { return { kind: 'noPlan', freeRuns: facts.freeRuns } } @@ -132,9 +140,7 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { ? { kind: 'ending', planName, cadence, endsAt: endDate } : UNKNOWN case 'ended': - return endDate - ? { kind: 'ended', planName, cadence, endedAt: endDate } - : UNKNOWN + return { kind: 'ended', planName, cadence, endedAt: endDate } default: return UNKNOWN } From db5590a555823be6b2eda1965a55bceab00924eb Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 00:29:15 -0400 Subject: [PATCH 2/7] fix(billing): show the ended row without a plan name and date it from the served ended_at A served subscription_state ended with no plan name now renders the ended row titled Your plan instead of falling to No plan. Both billing adapters pass ended_at through. The ended row uses it as served, including null for an unrecorded end, and falls back to cancel_at only when the server omits ended_at. --- .../dialogs/settings/BillingTab.test.ts | 15 +++++++ .../components/billingTab/BillingPlanRow.vue | 3 ++ .../components/billingTab/planRow.test.ts | 42 +++++++++++++++++++ .../billing/components/billingTab/planRow.ts | 13 ++++-- .../billingTab/useBillingPlanRow.ts | 24 ++++++++--- src/platform/billing/composables/types.ts | 2 + .../billing/composables/useLegacyBilling.ts | 11 ++++- .../composables/useWorkspaceBilling.test.ts | 17 ++++++++ .../composables/useWorkspaceBilling.ts | 1 + 9 files changed, 116 insertions(+), 12 deletions(-) diff --git a/src/platform/account/components/dialogs/settings/BillingTab.test.ts b/src/platform/account/components/dialogs/settings/BillingTab.test.ts index 984efd31cf6..16e9c4254ba 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.test.ts +++ b/src/platform/account/components/dialogs/settings/BillingTab.test.ts @@ -1088,6 +1088,21 @@ describe('BillingTab', () => { ).toBeInTheDocument() }) + it('titles an ended plan with no served plan name as Your plan', () => { + arrange({ + subscriptionStatus: null, + subscriptionState: 'ended', + subscription: { ...activeSubscription, isActive: false, tier: null } + }) + + expect( + screen.getByRole('heading', { name: 'Your plan' }) + ).toBeInTheDocument() + expect(screen.getByTestId('billing-plan-line').textContent.trim()).toBe( + 'This plan has ended.' + ) + }) + it('renders an unrecognised plan as Your plan', () => { arrange({ subscription: { ...activeSubscription, tier: null } }) diff --git a/src/platform/billing/components/billingTab/BillingPlanRow.vue b/src/platform/billing/components/billingTab/BillingPlanRow.vue index 55cb4b8843f..baed0b3eec0 100644 --- a/src/platform/billing/components/billingTab/BillingPlanRow.vue +++ b/src/platform/billing/components/billingTab/BillingPlanRow.vue @@ -95,6 +95,9 @@ const title = computed(() => { if (state.kind === 'unknown') { return t('workspacePanel.billingTab.plan.unknown.title') } + if (state.kind === 'ended') { + return state.planName ?? t('workspacePanel.billingTab.plan.unknown.title') + } if (state.kind === 'salesManaged') { return ( state.planName ?? t('workspacePanel.billingTab.plan.salesManaged.title') diff --git a/src/platform/billing/components/billingTab/planRow.test.ts b/src/platform/billing/components/billingTab/planRow.test.ts index fa1a2104416..83b874f2754 100644 --- a/src/platform/billing/components/billingTab/planRow.test.ts +++ b/src/platform/billing/components/billingTab/planRow.test.ts @@ -173,6 +173,48 @@ describe('derivePlanRow', () => { endedAt: null } }, + { + case: 'an ended plan with a served ended_at over cancel_at', + facts: { + subscriptionStatus: 'ended', + endedAt: '2026-08-20T00:00:00Z', + endDate: '2026-09-01T00:00:00Z' + }, + expected: { + kind: 'ended', + planName: 'Pro', + cadence: 'monthly', + endedAt: '2026-08-20T00:00:00Z' + } + }, + { + case: 'an ended plan whose ended_at is served as null', + facts: { + subscriptionStatus: 'ended', + endedAt: null, + endDate: '2026-09-01T00:00:00Z' + }, + expected: { + kind: 'ended', + planName: 'Pro', + cadence: 'monthly', + endedAt: null + } + }, + { + case: 'an ended subscription_state with no plan name', + facts: { + subscriptionState: 'ended', + subscriptionStatus: null, + planName: null + }, + expected: { + kind: 'ended', + planName: null, + cadence: 'monthly', + endedAt: null + } + }, { case: 'a served ended subscription_state', facts: { subscriptionState: 'ended', subscriptionStatus: null }, diff --git a/src/platform/billing/components/billingTab/planRow.ts b/src/platform/billing/components/billingTab/planRow.ts index ade2d628645..b8b469a17fb 100644 --- a/src/platform/billing/components/billingTab/planRow.ts +++ b/src/platform/billing/components/billingTab/planRow.ts @@ -19,6 +19,7 @@ export interface PlanRowFacts { planName: string | null renewalDate: string | null endDate: string | null + endedAt?: string | null scheduledChange: { planName: string; effectiveAt: string } | null freeRuns: { remaining: number; total: number } | null planKind: PlanKind | null @@ -42,7 +43,7 @@ export type PlanRowState = } | { kind: 'ended' - planName: string + planName: string | null cadence: BillingCadence | null endedAt: string | null } @@ -80,6 +81,10 @@ function toCadence( return null } +function endedDate(facts: PlanRowFacts): string | null { + return facts.endedAt === undefined ? facts.endDate : facts.endedAt +} + function salesManagedRow(facts: PlanRowFacts): PlanRowState | null { if (facts.planKind !== 'sales_managed') return null switch (facts.billingStatus) { @@ -105,12 +110,12 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { if (facts.subscriptionState === 'activating' && planName !== null) { return { kind: 'activating', planName } } - if (facts.subscriptionState === 'ended' && planName !== null) { + if (facts.subscriptionState === 'ended') { return { kind: 'ended', planName, cadence: toCadence(facts.duration), - endedAt: endDate + endedAt: endedDate(facts) } } if (subscriptionStatus === null) { @@ -140,7 +145,7 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { ? { kind: 'ending', planName, cadence, endsAt: endDate } : UNKNOWN case 'ended': - return { kind: 'ended', planName, cadence, endedAt: endDate } + return { kind: 'ended', planName, cadence, endedAt: endedDate(facts) } default: return UNKNOWN } diff --git a/src/platform/billing/components/billingTab/useBillingPlanRow.ts b/src/platform/billing/components/billingTab/useBillingPlanRow.ts index 31faa31ea08..5dad62f4699 100644 --- a/src/platform/billing/components/billingTab/useBillingPlanRow.ts +++ b/src/platform/billing/components/billingTab/useBillingPlanRow.ts @@ -43,12 +43,24 @@ export function useBillingPlanRow() { : null ) - const subscriptionFacts = computed(() => ({ - duration: subscription.value?.duration ?? null, - planName: planNameFor(subscription.value?.tier ?? null), - renewalDate: subscription.value?.renewalDate ?? null, - endDate: subscription.value?.endDate ?? null - })) + const subscriptionFacts = computed(() => { + const current = subscription.value + if (!current) { + return { + duration: null, + planName: null, + renewalDate: null, + endDate: null + } + } + return { + duration: current.duration, + planName: planNameFor(current.tier), + renewalDate: current.renewalDate, + endDate: current.endDate, + endedAt: current.endedAt + } + }) const state = computed(() => derivePlanRow({ diff --git a/src/platform/billing/composables/types.ts b/src/platform/billing/composables/types.ts index db2b6be5ef4..d2976930a3b 100644 --- a/src/platform/billing/composables/types.ts +++ b/src/platform/billing/composables/types.ts @@ -76,6 +76,8 @@ export interface SubscriptionInfo { renewalDate: string | null /** ISO 8601; format at the display site. */ endDate: string | null + /** Served `ended_at`; absent when the server omits the field. */ + endedAt?: string | null isCancelled: boolean hasFunds: boolean /** Agent funds across shared credits and the Agent-scoped balance. */ diff --git a/src/platform/billing/composables/useLegacyBilling.ts b/src/platform/billing/composables/useLegacyBilling.ts index e88ea5a3c2c..8bb5ba64df4 100644 --- a/src/platform/billing/composables/useLegacyBilling.ts +++ b/src/platform/billing/composables/useLegacyBilling.ts @@ -33,6 +33,14 @@ type RuntimeLegacyBalance = Omit< } type StatusReadResult = { ok: true } | { ok: false; cause: unknown } +function datesFromStatus(status: BillingStatusResponse | null) { + return { + renewalDate: status?.renewal_date ?? null, + endDate: status?.cancel_at ?? null, + endedAt: status?.ended_at + } +} + function fundsFromStatus( status: BillingStatusResponse | null, statusReadAuthoritative: boolean @@ -132,8 +140,7 @@ export function useLegacyBilling(): BillingState & BillingActions { duration: subscriptionDuration.value, planSlug: null, scheduledChange: null, - renewalDate: status?.renewal_date ?? null, - endDate: status?.cancel_at ?? null, + ...datesFromStatus(status), isCancelled: isCancelled.value, ...fundsFromStatus(status, statusReadAuthoritative.value) } diff --git a/src/platform/billing/composables/useWorkspaceBilling.test.ts b/src/platform/billing/composables/useWorkspaceBilling.test.ts index d7d77bf3066..93101f1008a 100644 --- a/src/platform/billing/composables/useWorkspaceBilling.test.ts +++ b/src/platform/billing/composables/useWorkspaceBilling.test.ts @@ -288,6 +288,23 @@ describe('useWorkspaceBilling', () => { } ) + it.for([ + { case: 'a recorded end', endedAt: '2026-05-20T00:00:00Z' }, + { case: 'an unrecorded end', endedAt: null } + ])('passes the served ended_at through for $case', async ({ endedAt }) => { + mockWorkspaceApi.getBillingStatus.mockResolvedValue({ + ...activeStatus, + subscription_status: 'ended', + subscription_state: 'ended', + ended_at: endedAt + }) + + const billing = setupBilling() + await billing.fetchStatus() + + expect(billing.subscription.value?.endedAt).toBe(endedAt) + }) + it('maps status response into subscription info', async () => { mockWorkspaceApi.getBillingStatus.mockResolvedValue({ ...activeStatus, diff --git a/src/platform/billing/composables/useWorkspaceBilling.ts b/src/platform/billing/composables/useWorkspaceBilling.ts index 0208f2c560b..8468a7f6c61 100644 --- a/src/platform/billing/composables/useWorkspaceBilling.ts +++ b/src/platform/billing/composables/useWorkspaceBilling.ts @@ -238,6 +238,7 @@ export function useWorkspaceBilling(): WorkspaceBilling { scheduledChange: status.scheduled_change ?? null, renewalDate: status.renewal_date ?? null, endDate: status.cancel_at ?? null, + endedAt: status.ended_at, isCancelled: status.subscription_status === 'canceled', hasFunds: status.has_funds, agentHasFunds: From b864207cc859b6ad44ac82ea44e0d8e01eba50b1 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 00:51:02 -0400 Subject: [PATCH 3/7] test(billing): expect the served ended_at on legacy subscription info --- src/platform/billing/composables/useBillingContext.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/billing/composables/useBillingContext.test.ts b/src/platform/billing/composables/useBillingContext.test.ts index a296b8e38ce..1df5f65aebf 100644 --- a/src/platform/billing/composables/useBillingContext.test.ts +++ b/src/platform/billing/composables/useBillingContext.test.ts @@ -204,6 +204,7 @@ describe('useBillingContext', () => { scheduledChange: null, renewalDate: '2025-01-01T00:00:00Z', endDate: null, + endedAt: null, isCancelled: false, hasFunds: true, agentHasFunds: true, From e9dc3d8a75d0004fa377d824ba5c35dbf9028674 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 01:50:51 -0400 Subject: [PATCH 4/7] fix(billing): keep an ended plan row when the server serves no tier --- .../components/billingTab/planRow.test.ts | 17 +++++++++++++- .../billing/components/billingTab/planRow.ts | 22 ++++++++++++------- .../composables/useLegacyBilling.test.ts | 14 ++++++++++++ .../billing/composables/useLegacyBilling.ts | 12 +++++++++- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/platform/billing/components/billingTab/planRow.test.ts b/src/platform/billing/components/billingTab/planRow.test.ts index 83b874f2754..041402d662a 100644 --- a/src/platform/billing/components/billingTab/planRow.test.ts +++ b/src/platform/billing/components/billingTab/planRow.test.ts @@ -276,7 +276,22 @@ describe('derivePlanRow', () => { planName: null, endDate: '2026-09-01T00:00:00Z' }, - expected: { kind: 'unknown' } + expected: { + kind: 'ended', + planName: null, + cadence: 'monthly', + endedAt: '2026-09-01T00:00:00Z' + } + }, + { + case: 'an ended subscription_status with no plan name', + facts: { subscriptionStatus: 'ended', planName: null, duration: null }, + expected: { + kind: 'ended', + planName: null, + cadence: null, + endedAt: null + } } ])('maps $case', ({ facts, expected }) => { expect(derivePlanRow({ ...baseFacts, ...facts })).toEqual(expected) diff --git a/src/platform/billing/components/billingTab/planRow.ts b/src/platform/billing/components/billingTab/planRow.ts index b8b469a17fb..37d27996315 100644 --- a/src/platform/billing/components/billingTab/planRow.ts +++ b/src/platform/billing/components/billingTab/planRow.ts @@ -85,6 +85,15 @@ function endedDate(facts: PlanRowFacts): string | null { return facts.endedAt === undefined ? facts.endDate : facts.endedAt } +function endedRow(facts: PlanRowFacts): PlanRowState { + return { + kind: 'ended', + planName: facts.planName, + cadence: toCadence(facts.duration), + endedAt: endedDate(facts) + } +} + function salesManagedRow(facts: PlanRowFacts): PlanRowState | null { if (facts.planKind !== 'sales_managed') return null switch (facts.billingStatus) { @@ -111,12 +120,11 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { return { kind: 'activating', planName } } if (facts.subscriptionState === 'ended') { - return { - kind: 'ended', - planName, - cadence: toCadence(facts.duration), - endedAt: endedDate(facts) - } + return endedRow(facts) + } + switch (subscriptionStatus) { + case 'ended': + return endedRow(facts) } if (subscriptionStatus === null) { return { kind: 'noPlan', freeRuns: facts.freeRuns } @@ -144,8 +152,6 @@ export function derivePlanRow(facts: PlanRowFacts): PlanRowState { return endDate ? { kind: 'ending', planName, cadence, endsAt: endDate } : UNKNOWN - case 'ended': - return { kind: 'ended', planName, cadence, endedAt: endedDate(facts) } default: return UNKNOWN } diff --git a/src/platform/billing/composables/useLegacyBilling.test.ts b/src/platform/billing/composables/useLegacyBilling.test.ts index c3e650b571c..e646bf94a9b 100644 --- a/src/platform/billing/composables/useLegacyBilling.test.ts +++ b/src/platform/billing/composables/useLegacyBilling.test.ts @@ -99,6 +99,20 @@ describe('useLegacyBilling', () => { expect(useLegacyBilling().subscription.value).toBeNull() }) + it('keeps a tierless ended status without an invoice as a subscription', () => { + useInactiveStatus( + statusWith({ + is_active: false, + subscription_status: 'ended', + ended_at: '2026-08-20T00:00:00Z' + }) + ) + + expect(useLegacyBilling().subscription.value?.endedAt).toBe( + '2026-08-20T00:00:00Z' + ) + }) + it('is null when the billing status carries no renewal invoice', () => { useSubscription().subscriptionStatus.value = statusWith({}) diff --git a/src/platform/billing/composables/useLegacyBilling.ts b/src/platform/billing/composables/useLegacyBilling.ts index 8bb5ba64df4..ef0dcb55131 100644 --- a/src/platform/billing/composables/useLegacyBilling.ts +++ b/src/platform/billing/composables/useLegacyBilling.ts @@ -41,6 +41,15 @@ function datesFromStatus(status: BillingStatusResponse | null) { } } +function servesEndedSubscription(status: BillingStatusResponse | null) { + switch (status?.subscription_status) { + case 'ended': + return true + default: + return false + } +} + function fundsFromStatus( status: BillingStatusResponse | null, statusReadAuthoritative: boolean @@ -129,7 +138,8 @@ export function useLegacyBilling(): BillingState & BillingActions { if ( !legacyCanAccessSubscriptionFeatures.value && !subscriptionTier.value && - !status?.renewal_invoice + !status?.renewal_invoice && + !servesEndedSubscription(status) ) { return null } From fc1cfd6eb396f183d1a7514f54e6b15e17aca99c Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 02:08:19 -0400 Subject: [PATCH 5/7] fix(billing): keep a legacy subscription for a served ended subscription_state --- .../billing/composables/useLegacyBilling.test.ts | 14 ++++++++++++++ .../billing/composables/useLegacyBilling.ts | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/platform/billing/composables/useLegacyBilling.test.ts b/src/platform/billing/composables/useLegacyBilling.test.ts index e646bf94a9b..7a77e994add 100644 --- a/src/platform/billing/composables/useLegacyBilling.test.ts +++ b/src/platform/billing/composables/useLegacyBilling.test.ts @@ -113,6 +113,20 @@ describe('useLegacyBilling', () => { ) }) + it('keeps a tierless ended subscription_state without an invoice as a subscription', () => { + useInactiveStatus( + statusWith({ + is_active: false, + subscription_state: 'ended', + ended_at: '2026-08-20T00:00:00Z' + }) + ) + + expect(useLegacyBilling().subscription.value?.endedAt).toBe( + '2026-08-20T00:00:00Z' + ) + }) + it('is null when the billing status carries no renewal invoice', () => { useSubscription().subscriptionStatus.value = statusWith({}) diff --git a/src/platform/billing/composables/useLegacyBilling.ts b/src/platform/billing/composables/useLegacyBilling.ts index ef0dcb55131..4568bcccaaa 100644 --- a/src/platform/billing/composables/useLegacyBilling.ts +++ b/src/platform/billing/composables/useLegacyBilling.ts @@ -45,6 +45,10 @@ function servesEndedSubscription(status: BillingStatusResponse | null) { switch (status?.subscription_status) { case 'ended': return true + } + switch (status?.subscription_state) { + case 'ended': + return true default: return false } From 76bbced6cd25656daad98d4448fd48b556a96cd3 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 03:19:37 -0400 Subject: [PATCH 6/7] test(billing): keep one white button per Billing tab page on each surface --- .../dialogs/settings/BillingTab.test.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/platform/account/components/dialogs/settings/BillingTab.test.ts b/src/platform/account/components/dialogs/settings/BillingTab.test.ts index 16e9c4254ba..9d8c44ea965 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.test.ts +++ b/src/platform/account/components/dialogs/settings/BillingTab.test.ts @@ -1329,17 +1329,19 @@ describe('BillingTab', () => { surface: 'Cloud', isCloud: true, choosePlan: 'inverted', - addCredits: 'secondary' + addCredits: 'secondary', + planEndedBanners: 1 }, { surface: 'local ComfyUI', isCloud: false, choosePlan: 'secondary', - addCredits: 'inverted' + addCredits: 'inverted', + planEndedBanners: 0 } ])( 'keeps one white button on $surface when an ended plan is out of credits', - async ({ isCloud, choosePlan, addCredits }) => { + async ({ isCloud, choosePlan, addCredits, planEndedBanners }) => { distribution.isCloud = isCloud onTestFinished(() => { distribution.isCloud = false @@ -1355,6 +1357,15 @@ describe('BillingTab', () => { screen.getByRole('link', { name: 'Choose a plan' }) ).toHaveAttribute('data-variant', choosePlan) expect(addCreditsVariants()).toEqual([addCredits]) + expect(screen.queryAllByText(/^Your .*plan has ended$/)).toHaveLength( + planEndedBanners + ) + expect( + [ + ...screen.queryAllByRole('button'), + ...screen.queryAllByRole('link') + ].filter((el) => el.dataset.variant === 'inverted') + ).toHaveLength(1) } ) From 137b9ba24a152d69d1b8a2ecd47dba5888fea805 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 30 Oct 2026 03:40:52 -0400 Subject: [PATCH 7/7] fix(billing): grey the local credit banner Add credits on an ended plan --- .../dialogs/settings/BillingTab.test.ts | 39 +++++++++++++++++++ .../dialogs/settings/BillingTab.vue | 6 ++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/platform/account/components/dialogs/settings/BillingTab.test.ts b/src/platform/account/components/dialogs/settings/BillingTab.test.ts index 9d8c44ea965..92926a7a35f 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.test.ts +++ b/src/platform/account/components/dialogs/settings/BillingTab.test.ts @@ -1279,6 +1279,45 @@ describe('BillingTab', () => { expect(addCreditsVariants()).toEqual(['inverted', 'inverted']) }) + it.for([ + { signal: 'subscription_status', subscriptionStatus: 'ended' as const }, + { signal: 'subscription_state', subscriptionState: 'ended' as const } + ])( + 'keeps the Credits card the one white Add credits on local ComfyUI when $signal is ended and out of credits', + async (scenario) => { + vi.mocked(useFeatureFlags().flags).unifiedBillingSettingsEnabled = true + arrange({ + ...scenario, + balance: zeroBalance, + subscription: { + ...activeSubscription, + isActive: false, + hasFunds: false + } + }) + + await screen.findByTestId('billing-auto-top-up-status') + expect( + within(screen.getByTestId('billing-local-credit-banner')).getByRole( + 'button', + { name: 'Add credits' } + ) + ).toHaveAttribute('data-variant', 'secondary') + expect( + within(screen.getByTestId('billing-credits-card')).getByRole( + 'button', + { name: 'Add credits' } + ) + ).toHaveAttribute('data-variant', 'inverted') + expect( + [ + ...screen.queryAllByRole('button'), + ...screen.queryAllByRole('link') + ].filter((el) => el.dataset.variant === 'inverted') + ).toHaveLength(1) + } + ) + it('turns Add credits white at 0 while a top-up payment is processing and auto top-up is off', async () => { servedCheckouts(checkout('payment_processing')) arrange({ balance: zeroBalance }) diff --git a/src/platform/account/components/dialogs/settings/BillingTab.vue b/src/platform/account/components/dialogs/settings/BillingTab.vue index b81f223eb6e..e0bfe4082ac 100644 --- a/src/platform/account/components/dialogs/settings/BillingTab.vue +++ b/src/platform/account/components/dialogs/settings/BillingTab.vue @@ -24,7 +24,7 @@

@@ -258,6 +258,10 @@ const addCreditsVariant = computed(() => }) ) +const creditBannerAddCreditsVariant = computed(() => + planRow.value.kind === 'ended' ? 'secondary' : addCreditsVariant.value +) + const salesVariant = computed(() => billing.subscriptionStatus.value === 'ended' ? 'inverted' : 'secondary' )