From ac7f20c710917f724a21ffd1a2d3240fbdb38c3a Mon Sep 17 00:00:00 2001 From: Connor Byrne Date: Sat, 8 Aug 2026 21:57:07 -0700 Subject: [PATCH] fix(billing): don't show the subscribe paywall before billing status resolves canRunWorkflows is false from the first render: isInitialized starts false, subscription is null, and canAccessSubscriptionFeatures reads statusData?.is_active ?? false. Neither the cloud run button nor the linear controls read isInitialized, so the locked Subscribe to run button was the default render, asserted on no data at all. A paying subscriber whose status fetch is slow, failing, or scoped to the wrong workspace therefore saw a paywall over the Run button with no recovery path, which is FE-1540 and the six Pylon tickets behind it. showsSubscribeToRunPrompt only claims the user needs to subscribe once billing status has actually resolved. Entitlement is still enforced by the backend on execution, so failing open for the unresolved window is the safer direction. --- .../CloudRunButtonWrapper.test.ts | 38 ++++++++++++++----- .../ComfyRunButton/CloudRunButtonWrapper.vue | 4 +- src/composables/billing/types.ts | 1 + src/composables/billing/useBillingContext.ts | 5 +++ .../extensions/linearMode/LinearControls.vue | 12 ++++-- src/storybook/mocks/useBillingContext.ts | 3 ++ 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts b/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts index accd895a849..83b93c33fd0 100644 --- a/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts +++ b/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts @@ -6,6 +6,7 @@ import { nextTick, ref } from 'vue' import CloudRunButtonWrapper from './CloudRunButtonWrapper.vue' const mockCanRunWorkflows = ref(true) +const mockIsInitialized = ref(true) const mockBillingStatus = ref('paid') const state = vi.hoisted(() => ({ v1PaymentRecovery: true, @@ -19,15 +20,21 @@ const state = vi.hoisted(() => ({ updateDialog: vi.fn() })) -vi.mock('@/composables/billing/useBillingContext', () => ({ - useBillingContext: () => ({ - canRunWorkflows: mockCanRunWorkflows, - billingStatus: mockBillingStatus, - manageSubscription: state.manageSubscription, - fetchStatus: state.fetchStatus, - fetchBalance: state.fetchBalance - }) -})) +vi.mock('@/composables/billing/useBillingContext', async () => { + const { computed } = await import('vue') + return { + useBillingContext: () => ({ + canRunWorkflows: mockCanRunWorkflows, + showsSubscribeToRunPrompt: computed( + () => mockIsInitialized.value && !mockCanRunWorkflows.value + ), + billingStatus: mockBillingStatus, + manageSubscription: state.manageSubscription, + fetchStatus: state.fetchStatus, + fetchBalance: state.fetchBalance + }) + } +}) vi.mock('@/composables/useFeatureFlags', () => ({ useFeatureFlags: () => ({ @@ -89,6 +96,7 @@ function renderWrapper() { describe('CloudRunButtonWrapper', () => { beforeEach(() => { mockCanRunWorkflows.value = true + mockIsInitialized.value = true mockBillingStatus.value = 'paid' state.v1PaymentRecovery = true state.canManageSubscription = true @@ -104,6 +112,18 @@ describe('CloudRunButtonWrapper', () => { ).not.toBeInTheDocument() }) + it('keeps the run button while billing status is still resolving', () => { + mockCanRunWorkflows.value = false + mockIsInitialized.value = false + + render(CloudRunButtonWrapper) + + expect(screen.getByTestId('queue-button')).toBeInTheDocument() + expect( + screen.queryByTestId('subscribe-to-run-button') + ).not.toBeInTheDocument() + }) + it('locks the run button when the subscription is inactive', () => { mockCanRunWorkflows.value = false renderWrapper() diff --git a/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.vue b/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.vue index e0fba1aa9d0..f37970be4f8 100644 --- a/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.vue +++ b/src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.vue @@ -1,6 +1,6 @@