From c5cb26faecad37c5316312fecec922391208d6e7 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Mon, 24 Aug 2026 18:14:04 +0000 Subject: [PATCH 1/4] fix(billing): let unsubscribed workspaces add credits on Local The Add credits entry points in the profile popover and the Credits settings tile were gated on canAccessSubscriptionFeatures, which is false for a workspace without an active subscription. On Local the subscribe CTA is also hidden, so such workspaces had no way to top up. Gate the buttons on the billing policy table instead: topUpAccess is 'allowed' for every Local state, and showTopUpCreditsDialog already enforces the same policy. The Cloud free-tier upsell keeps its previous behavior via showsSubscribeUpsellUI. --- .../components/CreditsTile.test.ts | 10 ++++ .../subscription/components/CreditsTile.vue | 4 +- .../CurrentUserPopoverWorkspace.test.ts | 50 +++++++++++++++++++ .../CurrentUserPopoverWorkspace.vue | 12 ++++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/src/platform/cloud/subscription/components/CreditsTile.test.ts b/src/platform/cloud/subscription/components/CreditsTile.test.ts index d5a7f8bbb62..ebc724c1931 100644 --- a/src/platform/cloud/subscription/components/CreditsTile.test.ts +++ b/src/platform/cloud/subscription/components/CreditsTile.test.ts @@ -367,6 +367,16 @@ describe('CreditsTile', () => { expect(screen.queryByText('Add credits')).toBeNull() }) + it('keeps add-credits available on local without an active subscription', async () => { + mockIsCloud.value = false + state.canAccessSubscriptionFeatures = false + state.balance = { amountMicros: 500 } + renderTile() + expect(screen.queryByText('Upgrade to add credits')).toBeNull() + await userEvent.click(screen.getByText('Add credits')) + expect(state.showTopUpCreditsDialog).toHaveBeenCalledOnce() + }) + it('shows no depletion notice or in-use badge while monthly credits remain', () => { activeProSubscription() const { container } = renderTile() diff --git a/src/platform/cloud/subscription/components/CreditsTile.vue b/src/platform/cloud/subscription/components/CreditsTile.vue index d6ca23d08ca..387b93b3eab 100644 --- a/src/platform/cloud/subscription/components/CreditsTile.vue +++ b/src/platform/cloud/subscription/components/CreditsTile.vue @@ -370,7 +370,9 @@ const showBar = computed( // including local/desktop) accounts have no workspace concept to gate on. const showActionButton = computed( () => - canAccessSubscriptionFeatures.value && + (billingPolicyCapabilities.value.topUpAccess === 'allowed' || + (billingPolicyCapabilities.value.showsSubscribeUpsellUI && + canAccessSubscriptionFeatures.value)) && !zeroState && !inactivePlan && (type.value !== 'workspace' || permissions.value.canTopUp) diff --git a/src/platform/workspace/components/CurrentUserPopoverWorkspace.test.ts b/src/platform/workspace/components/CurrentUserPopoverWorkspace.test.ts index 98328d9a6ea..4c4a0b6fa97 100644 --- a/src/platform/workspace/components/CurrentUserPopoverWorkspace.test.ts +++ b/src/platform/workspace/components/CurrentUserPopoverWorkspace.test.ts @@ -16,6 +16,8 @@ const state = vi.hoisted(() => ({ billingStatus: 'paid', canAccessSubscriptionFeatures: true, isFreeTier: false, + isTeamPlan: false, + tier: 'PRO' as 'PRO' | 'FREE' | null, isCancelled: false, planSlug: 'pro-monthly' as string | null, canTopUp: false, @@ -61,6 +63,8 @@ vi.mock('@/composables/billing/useBillingContext', () => ({ () => state.canAccessSubscriptionFeatures ), isFreeTier: computed(() => state.isFreeTier), + isTeamPlan: computed(() => state.isTeamPlan), + tier: computed(() => state.tier), subscription: computed(() => ({ isCancelled: state.isCancelled, planSlug: state.planSlug @@ -177,6 +181,8 @@ describe('CurrentUserPopoverWorkspace', () => { state.billingStatus = 'paid' state.canAccessSubscriptionFeatures = true state.isFreeTier = false + state.isTeamPlan = false + state.tier = 'PRO' state.isCancelled = false state.planSlug = 'pro-monthly' state.canTopUp = false @@ -343,6 +349,50 @@ describe('CurrentUserPopoverWorkspace', () => { ).not.toBeInTheDocument() }) + it('lets an owner add credits on Local without an active subscription', async () => { + const user = userEvent.setup() + state.isCloud = false + state.canAccessSubscriptionFeatures = false + state.tier = null + state.canTopUp = true + + renderComponent('personal') + + expect( + screen.queryByTestId('upgrade-to-add-credits-button') + ).not.toBeInTheDocument() + await user.click(screen.getByTestId('add-credits-button')) + + expect(state.showTopUpCreditsDialog).toHaveBeenCalledOnce() + }) + + it('offers add-credits instead of the upgrade upsell on the Local free tier', () => { + state.isCloud = false + state.isFreeTier = true + state.tier = 'FREE' + state.canTopUp = true + + renderComponent('personal') + + expect( + screen.queryByTestId('upgrade-to-add-credits-button') + ).not.toBeInTheDocument() + expect(screen.getByTestId('add-credits-button')).toBeInTheDocument() + }) + + it('keeps the upgrade upsell for the Cloud free tier', () => { + state.isFreeTier = true + state.tier = 'FREE' + state.canTopUp = true + + renderComponent('personal') + + expect( + screen.getByTestId('upgrade-to-add-credits-button') + ).toBeInTheDocument() + expect(screen.queryByTestId('add-credits-button')).not.toBeInTheDocument() + }) + it('keeps Resubscribe hidden on Local for a cancelled plan', () => { state.isCloud = false state.isCancelled = true diff --git a/src/platform/workspace/components/CurrentUserPopoverWorkspace.vue b/src/platform/workspace/components/CurrentUserPopoverWorkspace.vue index 3b6b53bc063..f759dadff28 100644 --- a/src/platform/workspace/components/CurrentUserPopoverWorkspace.vue +++ b/src/platform/workspace/components/CurrentUserPopoverWorkspace.vue @@ -91,7 +91,9 @@