+
From 9be5125512e7db70c6c324cdfa148734b2871c17 Mon Sep 17 00:00:00 2001
From: Maanil Verma
Date: Mon, 24 Aug 2026 22:47:48 +0530
Subject: [PATCH 07/14] refactor(billing): drop the redundant team-stop re-snap
and cover the fallback
The late-arrival re-snap watch was redundant: when the seeded slider value
matches no live stop, both selectedTeamStop and CreditSlider's own
selectedIndex already fall back to the default stop, so the display stays
correct without it. Remove the watch and add a test that swaps the API stops
for a disjoint set post-mount and asserts the default-stop credits render,
covering that fallback. Also remove an orphaned comment left in
UnifiedPricingTable when the shared ratio moved to tierPricing.
---
.../components/UnifiedPricingTable.vue | 2 -
.../settings/SettingsPlansSection.test.ts | 45 +++++++++++++++++++
.../dialogs/settings/SettingsPlansSection.vue | 12 ++---
3 files changed, 49 insertions(+), 10 deletions(-)
diff --git a/src/platform/workspace/components/UnifiedPricingTable.vue b/src/platform/workspace/components/UnifiedPricingTable.vue
index 41f928653ac..778c401eca8 100644
--- a/src/platform/workspace/components/UnifiedPricingTable.vue
+++ b/src/platform/workspace/components/UnifiedPricingTable.vue
@@ -480,8 +480,6 @@ const QUESTIONS_URL = 'https://portal.usepylon.com/comfy-org/forms/question'
const ENTERPRISE_URL = 'https://www.comfy.org/enterprise'
const PRICING_URL = 'https://www.comfy.org/pricing'
-// Videos-per-credit ratio (shared presentation constant).
-
interface BillingCycleOption {
label: string
value: BillingCycle
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
index 167c9ea320e..365fd1cc324 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
@@ -185,4 +185,49 @@ describe('SettingsPlansSection — API is the source of truth', () => {
).toBeDisabled()
expect(screen.getByRole('button', { name: 'Contact us' })).toBeDisabled()
})
+
+ it('shows the default stop credits when live stops replace the seeded set', async () => {
+ // Seed with one breakpoint set, then swap to a disjoint set: the previously
+ // seeded USD matches no new stop, so the display falls back to the API
+ // default stop (no stale/blank credits).
+ const { rerender } = renderSection({
+ teamCreditStops: {
+ default_stop_index: 0,
+ stops: [
+ {
+ id: 'team_200',
+ credits: 42_200,
+ monthly: { list_price_cents: 20_000, price_cents: 20_000 },
+ yearly: { list_price_cents: 20_000, price_cents: 18_000 }
+ }
+ ]
+ }
+ })
+ await userEvent.click(screen.getByRole('button', { name: 'Teams' }))
+ expect(screen.getByText('42,200')).toBeTruthy()
+
+ await rerender({
+ catalogPlans: CATALOG,
+ teamCreditStops: {
+ default_stop_index: 1,
+ stops: [
+ {
+ id: 'team_400',
+ credits: 84_400,
+ monthly: { list_price_cents: 40_000, price_cents: 40_000 },
+ yearly: { list_price_cents: 40_000, price_cents: 36_000 }
+ },
+ {
+ id: 'team_1200',
+ credits: 253_200,
+ monthly: { list_price_cents: 120_000, price_cents: 114_000 },
+ yearly: { list_price_cents: 120_000, price_cents: 108_000 }
+ }
+ ]
+ }
+ })
+
+ expect(await screen.findByText('253,200')).toBeTruthy()
+ expect(screen.queryByText('42,200')).toBeNull()
+ })
})
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
index 6b5243ef4a3..1544ffa1d48 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
@@ -253,7 +253,7 @@
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
index 1db4b44d493..f7cbea7ea48 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
@@ -74,6 +74,7 @@ function renderSection(
catalogPlans?: Plan[]
teamCreditStops?: TeamCreditStops | null
isLoading?: boolean
+ error?: string | null
} = {}
) {
return render(SettingsPlansSection, {
@@ -138,27 +139,32 @@ describe('SettingsPlansSection — API is the source of truth', () => {
expect(screen.queryByText('189,900')).toBeNull()
})
- it('shows the unavailable state for personal when the catalog is empty', () => {
+ it('shows the unavailable state and no prices when the personal catalog is empty', () => {
renderSection({ catalogPlans: [], teamCreditStops: null })
- expect(screen.getByText("We couldn't load your plan details.")).toBeTruthy()
+ expect(
+ screen.getByText('No plans are available right now. Check back soon.')
+ ).toBeTruthy()
expect(screen.queryByText(/\$\d+ Billed yearly/)).toBeNull()
expect(screen.queryByText('50,400')).toBeNull()
})
- it('shows the unavailable state for teams when stops are absent', async () => {
+ it('shows the unavailable state and no constant stop when team stops are absent', async () => {
renderSection({ teamCreditStops: null })
await userEvent.click(screen.getByRole('button', { name: 'Teams' }))
- expect(screen.getByText("We couldn't load your plan details.")).toBeTruthy()
+ expect(
+ screen.getByText('No plans are available right now. Check back soon.')
+ ).toBeTruthy()
// No constant-seeded slider stop.
expect(screen.queryByText('147,700')).toBeNull()
})
- it('emits retry from the unavailable state', async () => {
+ it('emits retry from the error state', async () => {
const { emitted } = renderSection({
catalogPlans: [],
- teamCreditStops: null
+ teamCreditStops: null,
+ error: 'network down'
})
await userEvent.click(screen.getByRole('button', { name: 'Try again' }))
@@ -236,4 +242,46 @@ describe('SettingsPlansSection — API is the source of truth', () => {
expect(await screen.findByText('253,200')).toBeTruthy()
expect(screen.queryByText('42,200')).toBeNull()
})
+
+ it('shows the empty-state copy (no retry) when the catalog loaded but is empty', () => {
+ renderSection({ catalogPlans: [], teamCreditStops: null, error: null })
+
+ expect(
+ screen.getByText('No plans are available right now. Check back soon.')
+ ).toBeTruthy()
+ // The empty state must NOT tell the user to retry a load that succeeded.
+ expect(screen.queryByText("We couldn't load your plan details.")).toBeNull()
+ expect(screen.queryByRole('button', { name: 'Try again' })).toBeNull()
+ })
+
+ it('shows the error copy and a working retry when the load failed', async () => {
+ const { emitted } = renderSection({
+ catalogPlans: [],
+ teamCreditStops: null,
+ error: 'network down'
+ })
+
+ expect(screen.getByText("We couldn't load your plan details.")).toBeTruthy()
+ expect(
+ screen.queryByText('No plans are available right now. Check back soon.')
+ ).toBeNull()
+ await userEvent.click(screen.getByRole('button', { name: 'Try again' }))
+ expect(emitted().retry).toBeTruthy()
+ })
+
+ it('keeps the cards visible during a refetch instead of flashing the spinner', async () => {
+ const { rerender } = renderSection()
+ expect(screen.getByText('$20')).toBeTruthy()
+
+ // Parent flips isLoading true on a refetch while cards are already shown.
+ await rerender({
+ catalogPlans: CATALOG,
+ teamCreditStops: TEAM_STOPS,
+ isLoading: true
+ })
+
+ // Cards stay; no full-section spinner replacement.
+ expect(screen.getByText('$20')).toBeTruthy()
+ expect(screen.queryByText('Loading')).toBeNull()
+ })
})
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
index 340a2640306..4e6c3dd61f2 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
@@ -33,7 +33,7 @@
@@ -131,7 +131,11 @@
-
+
@@ -232,7 +236,11 @@
-
+
()
const emit = defineEmits<{ retry: [] }>()
+// A load failure is retryable ('error'); a catalog that loaded with no plans is
+// a successful empty result ('empty', no retry).
+const unavailableVariant = computed<'empty' | 'error'>(() =>
+ error ? 'error' : 'empty'
+)
+
const { t, n } = useI18n()
const audience = ref<'personal' | 'teams'>('personal')
From 7456e147aacdc06420e2eabd9ef4ffa8044f4db3 Mon Sep 17 00:00:00 2001
From: Maanil Verma
Date: Tue, 25 Aug 2026 22:39:02 +0530
Subject: [PATCH 10/14] test(billing): drop comments that restate the hardening
test titles
---
.../components/dialogs/settings/SettingsPlansSection.test.ts | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
index f7cbea7ea48..30826c72e8b 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
@@ -249,7 +249,6 @@ describe('SettingsPlansSection — API is the source of truth', () => {
expect(
screen.getByText('No plans are available right now. Check back soon.')
).toBeTruthy()
- // The empty state must NOT tell the user to retry a load that succeeded.
expect(screen.queryByText("We couldn't load your plan details.")).toBeNull()
expect(screen.queryByRole('button', { name: 'Try again' })).toBeNull()
})
@@ -273,14 +272,12 @@ describe('SettingsPlansSection — API is the source of truth', () => {
const { rerender } = renderSection()
expect(screen.getByText('$20')).toBeTruthy()
- // Parent flips isLoading true on a refetch while cards are already shown.
await rerender({
catalogPlans: CATALOG,
teamCreditStops: TEAM_STOPS,
isLoading: true
})
- // Cards stay; no full-section spinner replacement.
expect(screen.getByText('$20')).toBeTruthy()
expect(screen.queryByText('Loading')).toBeNull()
})
From 2fa21354c98f0aa402edb16e14ff4c673da82e38 Mon Sep 17 00:00:00 2001
From: Maanil Verma
Date: Wed, 26 Aug 2026 15:46:49 +0530
Subject: [PATCH 11/14] fix(billing): drive the local plans state from the
workspace bootstrap
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The panel fetched the catalog through useBillingContext but read
plans/isLoading/error from the useBillingPlans singleton. Off-cloud,
shouldUseUnifiedPricing is `isCloud && ...` so it is false, and before the
workspace hydrates useBillingRouting resolves type to 'legacy' — so the
fetch landed on useLegacyBilling.fetchPlans(), an empty function that writes
neither state nor error. The singleton therefore stayed pristine and the
section computed 'empty': a slow bootstrap showed "No plans are available"
instead of a spinner, and a failed one (/api/workspaces 500) showed it
permanently, with no retry and zero catalog requests ever attempted.
The catalog is simply unreachable off-cloud until the workspace exists, so
the bootstrap is a precondition of it and has to drive this section. Rather
than move fetch/loading/error into useBillingContext — which would change
the shared adapter contract that cloud also depends on — the panel now reads
teamWorkspaceStore.initState/error alongside the singleton and folds the two
into the isLoading/error props the section already takes. Not-ready renders
the spinner; a failed bootstrap renders the error variant whose Retry
re-runs workspaceStore.initialize(), after which the billing context's own
workspace watch initializes billing and fetches the catalog. The empty and
fetch-failure paths are unchanged.
The old wiring test mocked both composables and had its mock write the
singleton it then asserted, so it could not see any of this. It is replaced
by a routing suite that runs the real useBillingContext/useBillingRouting/
useBillingPlans (and the real legacy adapter, whose no-op is the mechanism)
against a mocked workspaceApi and workspace store. Its two bootstrap cases
fail on the pre-fix panel.
---
.../PlanCreditsPanelContent.routing.test.ts | 254 ++++++++++++++++++
.../settings/PlanCreditsPanelContent.test.ts | 132 +--------
.../settings/PlanCreditsPanelContent.vue | 39 ++-
3 files changed, 289 insertions(+), 136 deletions(-)
create mode 100644 src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
new file mode 100644
index 00000000000..dfe7a61d836
--- /dev/null
+++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
@@ -0,0 +1,254 @@
+import userEvent from '@testing-library/user-event'
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { createI18n } from 'vue-i18n'
+
+import { ref } from 'vue'
+
+import { render, screen, waitFor } from '@testing-library/vue'
+
+import enMessages from '@/locales/en/main.json'
+import { useBillingPlans } from '@/platform/cloud/subscription/composables/useBillingPlans'
+import type {
+ BillingPlansResponse,
+ Plan
+} from '@/platform/workspace/api/workspaceApi'
+
+import PlanCreditsPanelContent from './PlanCreditsPanelContent.vue'
+
+// The panel's real defect was a routing one: it fetched through
+// useBillingContext (which lands on the legacy no-op before the workspace
+// hydrates) while reading state from the useBillingPlans singleton that only
+// the workspace adapter writes. These tests therefore run the REAL
+// useBillingContext / useBillingRouting / useBillingPlans and mock only what
+// this repo owns at its edges: the HTTP client and the workspace store's state.
+
+type InitState = 'uninitialized' | 'loading' | 'ready' | 'error'
+
+const workspace = vi.hoisted(() => ({
+ initialize: vi.fn(async () => {})
+}))
+
+// Reactive so a bootstrap that resolves mid-test re-drives the panel exactly as
+// the real store would.
+const state = {
+ initState: ref('ready'),
+ error: ref(null),
+ active: ref<{ id: string; type: string } | null>({
+ id: 'ws-1',
+ type: 'personal'
+ })
+}
+
+const api = vi.hoisted(() => ({
+ getBillingPlans: vi.fn(),
+ getBillingStatus: vi.fn(async () => ({
+ is_active: false,
+ has_funds: true,
+ team_credit_stop: null
+ })),
+ getBillingBalance: vi.fn(async () => ({ amount_micros: 0 }))
+}))
+
+vi.mock('@/platform/distribution/types', () => ({ isCloud: false }))
+
+// Siblings of the plans section; irrelevant here and each drags in the app graph.
+vi.mock('@/components/dialog/content/setting/CreditsPanel.vue', () => ({
+ default: { template: '' }
+}))
+vi.mock('@/components/dialog/content/setting/UsageLogsTable.vue', () => ({
+ default: { template: '', methods: { refresh: () => {} } }
+}))
+vi.mock(
+ '@/platform/cloud/subscription/components/SubscriptionFooterLinks.vue',
+ () => ({ default: { template: '' } })
+)
+vi.mock(
+ '@/platform/workspace/components/SubscriptionPanelContentWorkspace.vue',
+ () => ({ default: { template: '' } })
+)
+
+// The legacy adapter itself stays REAL — its no-op fetchPlans is the mechanism
+// under test — but its Firebase-backed collaborators are stubbed out.
+vi.mock('@/platform/cloud/subscription/composables/useSubscription', () => ({
+ useSubscription: () => ({
+ canAccessSubscriptionFeatures: ref(false),
+ subscriptionTier: ref(null),
+ subscriptionDuration: ref(null),
+ subscriptionStatus: ref(null),
+ isCancelled: ref(false),
+ fetchStatus: vi.fn(async () => {}),
+ manageSubscription: vi.fn(),
+ subscribe: vi.fn(),
+ subscribeDirect: vi.fn(),
+ showSubscriptionDialog: vi.fn()
+ })
+}))
+vi.mock('@/stores/authStore', () => ({
+ useAuthStore: () => ({ isLoggedIn: ref(true), balance: ref(null) })
+}))
+vi.mock('@/composables/auth/useAuthActions', () => ({
+ useAuthActions: () => ({ purchaseCredits: vi.fn(), fetchBalance: vi.fn() })
+}))
+
+vi.mock('@/platform/workspace/api/workspaceApi', () => ({
+ workspaceApi: api,
+ WorkspaceApiError: class extends Error {}
+}))
+
+vi.mock('@/platform/workspace/stores/teamWorkspaceStore', () => ({
+ useTeamWorkspaceStore: () => ({
+ get initState() {
+ return state.initState.value
+ },
+ get error() {
+ return state.error.value
+ },
+ get activeWorkspace() {
+ return state.active.value
+ },
+ get activeWorkspaceBillingRail() {
+ return undefined
+ },
+ get isPersonalWorkspace() {
+ return true
+ },
+ initialize: workspace.initialize,
+ updateActiveWorkspace: vi.fn(),
+ setWorkspaceBillingRail: vi.fn()
+ })
+}))
+
+function makePlan(
+ tier: Plan['tier'],
+ duration: Plan['duration'],
+ price_cents: number,
+ credits_cents: number
+): Plan {
+ return {
+ slug: `${tier.toLowerCase()}-${duration.toLowerCase()}`,
+ tier,
+ duration,
+ price_cents,
+ credits_cents,
+ max_seats: 1,
+ availability: { available: true },
+ seat_summary: {
+ seat_count: 1,
+ total_cost_cents: price_cents,
+ total_credits_cents: credits_cents
+ }
+ }
+}
+
+const CATALOG: BillingPlansResponse = {
+ plans: [makePlan('STANDARD', 'ANNUAL', 24000, 50400)]
+}
+
+function renderPanel() {
+ const i18n = createI18n({
+ legacy: false,
+ locale: 'en',
+ messages: { en: enMessages }
+ })
+ return render(PlanCreditsPanelContent, { global: { plugins: [i18n] } })
+}
+
+const EMPTY_COPY = 'No plans are available right now. Check back soon.'
+const ERROR_COPY = "We couldn't load your plan details."
+
+// useBillingPlans is a module singleton; reset the state each test rather than
+// resetting the module graph (a fresh graph deadlocks on the workspace).
+beforeEach(() => {
+ const billingPlans = useBillingPlans()
+ billingPlans.plans.value = []
+ billingPlans.teamCreditStops.value = null
+ billingPlans.currentPlanSlug.value = null
+ billingPlans.isLoading.value = false
+ billingPlans.error.value = null
+
+ state.initState.value = 'ready'
+ state.error.value = null
+ state.active.value = { id: 'ws-1', type: 'personal' }
+ workspace.initialize.mockReset()
+ workspace.initialize.mockImplementation(async () => {})
+ api.getBillingPlans.mockReset()
+ api.getBillingPlans.mockResolvedValue(CATALOG)
+})
+
+describe('PlanCreditsPanelContent — workspace bootstrap drives the plans state', () => {
+ it('shows the loading state until the workspace hydrates, then the catalog', async () => {
+ state.initState.value = 'loading'
+ state.active.value = null
+
+ renderPanel()
+
+ expect(await screen.findByText('Loading')).toBeTruthy()
+ expect(screen.queryAllByText(EMPTY_COPY)).toHaveLength(0)
+ expect(api.getBillingPlans).not.toHaveBeenCalled()
+
+ state.initState.value = 'ready'
+ state.active.value = { id: 'ws-1', type: 'personal' }
+
+ expect(await screen.findByText('$20')).toBeTruthy()
+ expect(screen.getByText('50,400')).toBeTruthy()
+ expect(screen.queryByText('Loading')).toBeNull()
+ expect(api.getBillingPlans).toHaveBeenCalledOnce()
+ })
+
+ it('shows a retryable error when the workspace bootstrap failed, and recovers', async () => {
+ state.initState.value = 'error'
+ state.error.value = new Error('workspaces unavailable')
+ state.active.value = null
+
+ renderPanel()
+
+ expect((await screen.findAllByText(ERROR_COPY)).length).toBeGreaterThan(0)
+ expect(screen.queryAllByText(EMPTY_COPY)).toHaveLength(0)
+
+ // Retry re-runs the workspace bootstrap; the billing context's workspace
+ // watch is what then fetches the catalog.
+ workspace.initialize.mockImplementation(async () => {
+ state.initState.value = 'ready'
+ state.active.value = { id: 'ws-1', type: 'personal' }
+ })
+
+ await userEvent.click(
+ screen.getAllByRole('button', { name: 'Try again' })[0]
+ )
+
+ expect(workspace.initialize).toHaveBeenCalledOnce()
+ await waitFor(() =>
+ expect(screen.getAllByText('$20').length).toBeGreaterThan(0)
+ )
+ })
+
+ it('shows the empty state without a retry for a successful but empty catalog', async () => {
+ api.getBillingPlans.mockResolvedValue({ plans: [] })
+
+ renderPanel()
+
+ expect((await screen.findAllByText(EMPTY_COPY)).length).toBeGreaterThan(0)
+ expect(screen.queryByText(ERROR_COPY)).toBeNull()
+ expect(screen.queryByRole('button', { name: 'Try again' })).toBeNull()
+ })
+
+ it('shows a retryable error when the catalog fetch fails, and recovers', async () => {
+ vi.spyOn(console, 'error').mockImplementation(() => undefined)
+ api.getBillingPlans.mockRejectedValueOnce(new Error('plans exploded'))
+
+ renderPanel()
+
+ expect((await screen.findAllByText(ERROR_COPY)).length).toBeGreaterThan(0)
+ expect(screen.queryAllByText(EMPTY_COPY)).toHaveLength(0)
+
+ await userEvent.click(
+ screen.getAllByRole('button', { name: 'Try again' })[0]
+ )
+
+ await waitFor(() =>
+ expect(screen.getAllByText('$20').length).toBeGreaterThan(0)
+ )
+ // Retry re-fetches the catalog rather than re-running the bootstrap.
+ expect(workspace.initialize).not.toHaveBeenCalled()
+ })
+})
diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.test.ts b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.test.ts
index c7ad1b57843..ae8be20e3da 100644
--- a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.test.ts
@@ -1,5 +1,5 @@
import userEvent from '@testing-library/user-event'
-import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { describe, expect, it, vi } from 'vitest'
import { createI18n } from 'vue-i18n'
import { ref } from 'vue'
@@ -7,7 +7,6 @@ import { ref } from 'vue'
import { render, screen, waitFor } from '@testing-library/vue'
import enMessages from '@/locales/en/main.json'
-import type { Plan } from '@/platform/workspace/api/workspaceApi'
import PlanCreditsPanelContent from './PlanCreditsPanelContent.vue'
@@ -155,132 +154,3 @@ describe('PlanCreditsPanelContent', () => {
)
})
})
-
-describe('PlanCreditsPanelContent — the fetch drives the rendered offer', () => {
- function makePlan(
- tier: Plan['tier'],
- duration: Plan['duration'],
- price_cents: number,
- credits_cents: number
- ): Plan {
- return {
- slug: `${tier.toLowerCase()}-${duration.toLowerCase()}`,
- tier,
- duration,
- price_cents,
- credits_cents,
- max_seats: 1,
- availability: { available: true },
- seat_summary: {
- seat_count: 1,
- total_cost_cents: price_cents,
- total_credits_cents: credits_cents
- }
- }
- }
-
- // Section rendered UNSTUBBED so the assertion is on real rendered values —
- // a stubbed section would pass with the wire cut (the round-1 failure).
- const wireStubs = {
- SubscriptionPanelContentWorkspace: {
- template: ''
- },
- CreditsPanel: {
- props: ['embedded'],
- template: ''
- },
- SubscriptionFooterLinks: {
- template: ''
- },
- UsageLogsTable: {
- template: '',
- methods: { refresh: refreshSpy }
- }
- }
-
- function renderWired({ cloud = false } = {}) {
- mockDistribution.cloud = cloud
- const i18n = createI18n({
- legacy: false,
- locale: 'en',
- messages: { en: enMessages }
- })
- return render(PlanCreditsPanelContent, {
- global: { plugins: [i18n], stubs: wireStubs }
- })
- }
-
- beforeEach(() => {
- billingState.plans.value = []
- billingState.teamCreditStops.value = null
- billingState.isLoading.value = false
- billingState.error.value = null
- billing.fetchPlans.mockReset()
- // fetchPlans populates the singleton the section reads — the real wire.
- billing.fetchPlans.mockImplementation(async () => {
- billingState.plans.value = [makePlan('STANDARD', 'ANNUAL', 24000, 50400)]
- })
- })
-
- it('fetches on mount off-cloud and renders the fetched catalog', async () => {
- renderWired({ cloud: false })
-
- expect(billing.fetchPlans).toHaveBeenCalledTimes(1)
- // The fetched STANDARD/ANNUAL row: $20/mo, 50,400 credits — from the fetch,
- // not a constant.
- expect(await screen.findByText('$20')).toBeTruthy()
- expect(screen.getByText('50,400')).toBeTruthy()
- })
-
- it('renders different numbers when the fetch returns different data', async () => {
- billing.fetchPlans.mockImplementation(async () => {
- billingState.plans.value = [makePlan('STANDARD', 'ANNUAL', 30000, 60000)]
- })
- renderWired({ cloud: false })
-
- expect(await screen.findByText('$25')).toBeTruthy()
- expect(screen.getByText('60,000')).toBeTruthy()
- expect(screen.queryByText('$20')).toBeNull()
- })
-
- it('renders the empty state when the fetch yields no catalog', async () => {
- billing.fetchPlans.mockImplementation(async () => {
- billingState.plans.value = []
- })
- renderWired({ cloud: false })
-
- expect(
- await screen.findByText(
- 'No plans are available right now. Check back soon.'
- )
- ).toBeTruthy()
- expect(screen.queryByText("We couldn't load your plan details.")).toBeNull()
- expect(screen.queryByText(/\$\d+ Billed yearly/)).toBeNull()
- })
-
- it('renders the error state when the fetch fails', async () => {
- billing.fetchPlans.mockImplementation(async () => {
- billingState.plans.value = []
- billingState.error.value = 'network down'
- })
- renderWired({ cloud: false })
-
- expect(
- await screen.findByText("We couldn't load your plan details.")
- ).toBeTruthy()
- expect(screen.getByRole('button', { name: 'Try again' })).toBeTruthy()
- expect(
- screen.queryByText('No plans are available right now. Check back soon.')
- ).toBeNull()
- })
-
- it('does not fetch or mount the section on cloud', () => {
- renderWired({ cloud: true })
-
- expect(billing.fetchPlans).not.toHaveBeenCalled()
- expect(screen.queryByText('$20')).toBeNull()
- expect(
- screen.getByRole('region', { name: 'Plan and credits overview' })
- ).toBeTruthy()
- })
-})
diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
index b2d9abb55e0..56b7c6cf89f 100644
--- a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
+++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
@@ -23,9 +23,9 @@
!isCloud && workspaceStore.initState !== 'ready'
+)
+const workspaceError = computed(() =>
+ !isCloud && workspaceStore.initState === 'error'
+ ? (workspaceStore.error?.message ?? t('subscription.planLoadError'))
+ : null
+)
+
+const isCatalogLoading = computed(
+ () =>
+ isLoadingPlans.value || (isWorkspacePending.value && !workspaceError.value)
+)
+const catalogError = computed(() => workspaceError.value ?? plansError.value)
+
+function retry() {
+ if (workspaceError.value) {
+ // The context's workspace watch initializes billing and fetches the
+ // catalog once a workspace appears. A repeat failure is already reported
+ // by the store and re-renders this same error state.
+ void workspaceStore.initialize().catch(() => undefined)
+ return
+ }
void fetchPlans()
}
// Off-cloud only: on cloud the local plans section never mounts, so no extra
// local fetch fires. Deduped across re-mounts by useBillingPlans.fetchPromise.
onMounted(() => {
- if (!isCloud) loadPlans()
+ if (!isCloud) void fetchPlans()
})
function openFullActivity() {
From fbeebc9df7cba3d38f5af5fc8536887db9e87d98 Mon Sep 17 00:00:00 2001
From: Maanil Verma
Date: Wed, 26 Aug 2026 15:47:46 +0530
Subject: [PATCH 12/14] fix(billing): surface a failed plans refetch over
cached cards
useBillingPlans keeps the previous plans alongside a fresh error so a failed
refetch does not flash the section to empty. That is the right call, but the
unavailable block only renders when there are no cards, so the failure was
invisible: stale prices with no indication they were stale and no way to
retry. Keep the cards and add a banner that states it and offers the retry.
Also drop the dead settingsPlans.checkoutCaption key and point the enterprise
CTA at the existing subscription.contactUs rather than its duplicate.
---
src/locales/en/main.json | 5 ++-
.../settings/SettingsPlansSection.test.ts | 16 ++++++++++
.../dialogs/settings/SettingsPlansSection.vue | 31 ++++++++++++++++++-
3 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/src/locales/en/main.json b/src/locales/en/main.json
index 4b7fdb6bb32..f278294f8bf 100644
--- a/src/locales/en/main.json
+++ b/src/locales/en/main.json
@@ -2672,9 +2672,7 @@
"creditsPerMonth": "{credits} credits per month",
"comingSharedWorkflows": "Shared workflows & assets",
"comingProjects": "Projects",
- "enterpriseCopy": "Need more members? Looking for more flexibility or custom features?",
- "contactUs": "Contact us",
- "checkoutCaption": "Checkout happens right here: payment details handled securely by Stripe. Prefer no plan? Keep topping up, anytime."
+ "enterpriseCopy": "Need more members? Looking for more flexibility or custom features?"
},
"credits": {
"activity": "Activity",
@@ -2891,6 +2889,7 @@
"whatsIncluded": "What's included:",
"planLoadError": "We couldn't load your plan details.",
"planLoadErrorRetry": "Try again",
+ "planLoadErrorStale": "We couldn't refresh your plan details. These prices may be out of date.",
"teamPlanName": "Team",
"teamPlanIncludes": "Your plan includes everything in {plan}, plus:",
"inactiveTeamTitle": "Inactive team subscription",
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
index cb9760acaa1..99e4c1849a2 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.test.ts
@@ -203,6 +203,22 @@ describe('SettingsPlansSection — API is the source of truth', () => {
expect(emitted().retry).toBeTruthy()
})
+ it('surfaces a retryable failure over cached cards on a refetch error', async () => {
+ const { emitted } = renderSection({ error: 'network down' })
+
+ // The cached catalog stays on screen rather than flashing to empty...
+ expect(screen.getByText('$20')).toBeTruthy()
+ // ...but the failure is stated and retryable, not silent.
+ expect(
+ screen.getByText(
+ "We couldn't refresh your plan details. These prices may be out of date."
+ )
+ ).toBeTruthy()
+
+ await userEvent.click(screen.getByRole('button', { name: 'Try again' }))
+ expect(emitted().retry).toBeTruthy()
+ })
+
it('shows a spinner and no prices while loading', () => {
renderSection({ isLoading: true, catalogPlans: [], teamCreditStops: null })
diff --git a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
index e436ad41e96..70d824bfb17 100644
--- a/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
+++ b/src/platform/workspace/components/dialogs/settings/SettingsPlansSection.vue
@@ -30,6 +30,28 @@
+
+
+
+
+ {{ t('subscription.planLoadErrorStale') }}
+
+
+
+
@@ -386,6 +408,13 @@ const personalCards = computed(() =>
})
)
+// An error alongside a non-empty catalog means a refetch failed over cached
+// rows; the unavailable block never renders then, so the banner is the only
+// place that failure can surface.
+const hasStaleError = computed(
+ () => Boolean(error) && personalCards.value.length > 0
+)
+
// Team stops come from the API only — no TEAM_PLAN_CREDIT_STOPS fallback (D3).
const teamStops = computed(() => {
const apiStops = teamCreditStops?.stops
From ed69eb28ba36299cc5f854f324c0a6a66a9e4d49 Mon Sep 17 00:00:00 2001
From: Maanil Verma
Date: Wed, 26 Aug 2026 16:11:46 +0530
Subject: [PATCH 13/14] fix(billing): fetch the local catalog through its own
state owner
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Live proof of the previous commit surfaced the other half of the same split:
after a plans fetch failed, Try again produced no request at all. The retry
called useBillingContext().fetchPlans(), which picks an adapter by billing
rail — and off-cloud any rail that is not 'workspace' resolves to
useLegacyBilling.fetchPlans(), an empty function. So the retry silently did
nothing while the section, which reads the useBillingPlans singleton, kept
rendering the stale error.
The section reads its plans/isLoading/error from useBillingPlans, so it now
calls that singleton's fetch directly: one owner for both the fetch and the
state it drives, with no rail-sensitive indirection in between. The read is
unchanged in substance — workspaceApi.getBillingPlans still resolves through
FE-1584's workspaceApiUrl to the cloud origin — and cloud is untouched, since
the local section never mounts there.
The mount-time fetch becomes a watch on the workspace, which is the actual
precondition: it fires as soon as one lands rather than firing once against
whatever was hydrated at mount and never again.
Verified live on a build of this branch against a real backend: workspace
bootstrap 500 (spinner during the store's backoff, then the error copy, Retry
recovers to cards with exactly one catalog request), a 6s-delayed bootstrap
(loading, never the empty copy), an empty-but-successful catalog (empty copy
on both tabs, no retry), and a plans 500 (error, Retry recovers).
---
.../PlanCreditsPanelContent.routing.test.ts | 23 +++++++
.../settings/PlanCreditsPanelContent.vue | 69 +++++++++++--------
2 files changed, 62 insertions(+), 30 deletions(-)
diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
index dfe7a61d836..7bd8e77227c 100644
--- a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
+++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.routing.test.ts
@@ -222,6 +222,29 @@ describe('PlanCreditsPanelContent — workspace bootstrap drives the plans state
)
})
+ it('retries the bootstrap when the wallet resolved to no workspace at all', async () => {
+ // initState says 'ready' but no workspace landed, so routing is still
+ // 'legacy' and a plain refetch would hit the no-op forever.
+ state.initState.value = 'ready'
+ state.active.value = null
+
+ renderPanel()
+
+ expect((await screen.findAllByText(ERROR_COPY)).length).toBeGreaterThan(0)
+
+ workspace.initialize.mockImplementation(async () => {
+ state.active.value = { id: 'ws-1', type: 'personal' }
+ })
+ await userEvent.click(
+ screen.getAllByRole('button', { name: 'Try again' })[0]
+ )
+
+ expect(workspace.initialize).toHaveBeenCalledOnce()
+ await waitFor(() =>
+ expect(screen.getAllByText('$20').length).toBeGreaterThan(0)
+ )
+ })
+
it('shows the empty state without a retry for a successful but empty catalog', async () => {
api.getBillingPlans.mockResolvedValue({ plans: [] })
diff --git a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
index 56b7c6cf89f..9a9278fb2c1 100644
--- a/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
+++ b/src/platform/workspace/components/dialogs/settings/PlanCreditsPanelContent.vue
@@ -51,7 +51,7 @@