From dcda22abde8c27501a7871878bd116f6e96fb260 Mon Sep 17 00:00:00 2001 From: Dante Date: Wed, 30 Sep 2026 17:28:40 +0000 Subject: [PATCH] FE-3129 feat(billing): gate Members credit limits behind their own flag (#19641) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the Members credit column and "Set credit limit" action off `billing_control_enabled` onto a new `member_credit_limits_enabled` flag, so `billing_control_enabled` can ramp with only the billing banners. `billing_control_enabled` is off for 100% of prod users (Datadog RUM, 30 days). It gates two unrelated things: - Team lifecycle banners (out of credits, plan ending, scheduled plan change) and the Enterprise 2-week ending notice. Display-only, reuse live actions, no new API. Ready to ramp. - The Members credit column and "Set credit limit". `setMemberCreditLimit` only updates the local store (persistence is FE-1278), so a limit looks saved, disappears on reload, and caps nothing. Not shippable. One flag for both kept the banners parked behind the unfinished Spend Controls work. - **What**: - New `member_credit_limits_enabled` flag (strict boolean, default off), reported to RUM like the other flags. - `useWorkspaceUI.showCreditsColumn` and the `useMembersPanel` credit-limit menu item read the new flag. `billing_control_enabled` now gates only the banners. - Tests pin the split: `billing_control_enabled` alone no longer shows either Members surface (verified red against the old gating). - Storybook: add `PlanChangeOwner` and `EndingEnterpriseOwner` banner states; add the missing `canReactivatePlan` to the `useWorkspaceUI` mock, which made the existing `Ending*` stories throw. - `member_credit_limits_enabled` must be delivered by `/features` before it can be turned on. Nothing to do now since it stays off until Spend Controls ships. - Rollout after merge: ramp `billing_control_enabled` 10% → 50% → 100% and watch RUM, then remove the gate (BE-17912). Banner states reviewed with design: https://claude.ai/artifact/FoTcznmY138JjXb15s3rj5 | # | Step | Status | |---|------|--------| | 1 | Ramp `v1_payment_recovery` to 100% (fixes paused workspace falling through to "Subscribe to run") | PostHog | | **2** | **Split Members credit-limit surfaces onto their own flag (this PR)** | **this PR** | | 3 | Design check of banner states (Alex) | in review | | 4 | Ramp `billing_control_enabled` 10% → 100% | after 2 + 3 | | 5 | Remove `v1_payment_recovery` / `billing_control_enabled` gates | after ramps | | 6 | Turn on `member_credit_limits_enabled` with Spend Controls (FE-1278) | later | ```mermaid flowchart LR A[1 ramp v1_payment_recovery] --> E[5 remove gates] B[2 split flags - this PR]:::me --> D[4 ramp billing_control_enabled] C[3 design check] --> D D --> E F[FE-1278 persistence] --> G[6 enable member_credit_limits_enabled] B --> G classDef me fill:#3b5bdb,color:#fff ``` Real app (`pnpm dev:cloud` → testcloud), team workspace as owner, `billing_control_enabled` via `ff:` dev override. The workspace has one real member, so a second row (Alex Member) was injected into the members store to open the ⋯ menu; AS IS runs origin/main's `useWorkspaceUI`/`useMembersPanel`. **AS IS** — billing controls on: Members credit column + Set credit limit show alongside banners. AS IS **TO BE** — billing controls on, member credit limits off: banners show, Members has no credit column or Set credit limit. TO BE **TO BE, `member_credit_limits_enabled` on** — the Credits column and Set credit limit return. TO BE flag on - Fixes FE-3129 (cherry picked from commit 6392fab11df8262d3320d86351574fcb4726412c) --- src/composables/__mocks__/useFeatureFlags.ts | 1 + src/composables/useFeatureFlags.ts | 9 +++++++++ src/platform/remoteConfig/types.ts | 1 + .../composables/useMembersPanel.test.ts | 19 ++++++++++++++++--- .../workspace/composables/useMembersPanel.ts | 2 +- .../composables/useWorkspaceUI.test.ts | 14 +++++++++++++- .../workspace/composables/useWorkspaceUI.ts | 2 +- src/storybook/mocks/useWorkspaceUI.ts | 9 +++++++-- 8 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/composables/__mocks__/useFeatureFlags.ts b/src/composables/__mocks__/useFeatureFlags.ts index 34d06fcae63..9940d3de0e2 100644 --- a/src/composables/__mocks__/useFeatureFlags.ts +++ b/src/composables/__mocks__/useFeatureFlags.ts @@ -30,6 +30,7 @@ const defaultFlags: FeatureFlags = { showSignInButton: undefined, unifiedCloudAuthEnabled: false, billingControlEnabled: false, + memberCreditLimitsEnabled: false, legacyBillingMigrationEnabled: false, embeddedCheckoutEnabled: false, billingSdkTopupEnabled: false, diff --git a/src/composables/useFeatureFlags.ts b/src/composables/useFeatureFlags.ts index 86842e1893a..ad0fbb66285 100644 --- a/src/composables/useFeatureFlags.ts +++ b/src/composables/useFeatureFlags.ts @@ -42,6 +42,7 @@ export enum ServerFeatureFlag { SHOW_SIGNIN_BUTTON = 'show_signin_button', UNIFIED_CLOUD_AUTH = 'unified_cloud_auth', BILLING_CONTROL_ENABLED = 'billing_control_enabled', + MEMBER_CREDIT_LIMITS_ENABLED = 'member_credit_limits_enabled', LEGACY_BILLING_MIGRATION_ENABLED = 'legacy_billing_migration_enabled', EMBEDDED_CHECKOUT_ENABLED = 'embedded_checked_enabled', BILLING_SDK_TOPUP_ENABLED = 'billing_sdk_topup_enabled', @@ -297,6 +298,12 @@ export function useFeatureFlags() { cachedBillingControlEnabled ) }, + get memberCreditLimitsEnabled() { + return resolveStrictBooleanFlag( + ServerFeatureFlag.MEMBER_CREDIT_LIMITS_ENABLED, + remoteConfig.value.member_credit_limits_enabled + ) + }, get legacyBillingMigrationEnabled() { return resolveAuthGatedFlag( ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED, @@ -430,6 +437,8 @@ export function startFeatureFlagTelemetry() { [ServerFeatureFlag.SHOW_SIGNIN_BUTTON]: flags.showSignInButton, [ServerFeatureFlag.UNIFIED_CLOUD_AUTH]: flags.unifiedCloudAuthEnabled, [ServerFeatureFlag.BILLING_CONTROL_ENABLED]: flags.billingControlEnabled, + [ServerFeatureFlag.MEMBER_CREDIT_LIMITS_ENABLED]: + flags.memberCreditLimitsEnabled, [ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED]: flags.legacyBillingMigrationEnabled, [ServerFeatureFlag.EMBEDDED_CHECKOUT_ENABLED]: diff --git a/src/platform/remoteConfig/types.ts b/src/platform/remoteConfig/types.ts index 1fcfd180962..d534cb33894 100644 --- a/src/platform/remoteConfig/types.ts +++ b/src/platform/remoteConfig/types.ts @@ -133,6 +133,7 @@ export type RemoteConfig = GetFeaturesResponses[200] & { billing_sdk_topup_enabled?: boolean billing_sdk_subscription_enabled?: boolean billing_control_enabled?: boolean + member_credit_limits_enabled?: boolean legacy_billing_migration_enabled?: boolean v1_payment_recovery?: boolean churnkey_app_id?: string diff --git a/src/platform/workspace/composables/useMembersPanel.test.ts b/src/platform/workspace/composables/useMembersPanel.test.ts index 445ddd6587a..4986469a821 100644 --- a/src/platform/workspace/composables/useMembersPanel.test.ts +++ b/src/platform/workspace/composables/useMembersPanel.test.ts @@ -454,7 +454,7 @@ describe('useMembersPanel', () => { workspaceMembers = [] workspacePendingInvites = [] updateWorkspaceStore() - vi.mocked(useFeatureFlags().flags).billingControlEnabled = true + vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = true mockMaxSeats.value = 73 mockOccupiedSeats.value = 0 mockCanAccessSubscriptionFeatures.value = true @@ -878,7 +878,20 @@ describe('useMembersPanel', () => { }) it('omits the credit-limit action when the flag is disabled', async () => { - vi.mocked(useFeatureFlags().flags).billingControlEnabled = false + vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false + const panel = await setup() + + expect(panel.memberMenuItems(createMember()).map((i) => i.label)).toEqual( + [ + 'workspacePanel.members.actions.changeRole', + 'workspacePanel.members.actions.removeMember' + ] + ) + }) + + it('omits the credit-limit action under billing controls alone', async () => { + vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false + vi.mocked(useFeatureFlags().flags).billingControlEnabled = true const panel = await setup() expect(panel.memberMenuItems(createMember()).map((i) => i.label)).toEqual( @@ -890,7 +903,7 @@ describe('useMembersPanel', () => { }) it('keeps the creator menu hidden when the flag is disabled', async () => { - vi.mocked(useFeatureFlags().flags).billingControlEnabled = false + vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false setOriginalOwner() const panel = await setup() diff --git a/src/platform/workspace/composables/useMembersPanel.ts b/src/platform/workspace/composables/useMembersPanel.ts index 7c5be135655..8fe3bd1959b 100644 --- a/src/platform/workspace/composables/useMembersPanel.ts +++ b/src/platform/workspace/composables/useMembersPanel.ts @@ -308,7 +308,7 @@ export function useMembersPanel() { roleMenuItem(member, 'member', t('workspaceSwitcher.roleMember')) ] }, - ...(flags.billingControlEnabled && member.role === 'member' + ...(flags.memberCreditLimitsEnabled && member.role === 'member' ? [creditLimitItem] : []), { diff --git a/src/platform/workspace/composables/useWorkspaceUI.test.ts b/src/platform/workspace/composables/useWorkspaceUI.test.ts index d4300169ca2..a387e9cd785 100644 --- a/src/platform/workspace/composables/useWorkspaceUI.test.ts +++ b/src/platform/workspace/composables/useWorkspaceUI.test.ts @@ -10,6 +10,7 @@ const mockIsActiveSubscription = vi.hoisted(() => ({ value: false })) const mockIsCancelled = vi.hoisted(() => ({ value: false })) const mockIsTeamPlan = vi.hoisted(() => ({ value: false })) const mockBillingControlEnabled = vi.hoisted(() => ({ value: false })) +const mockMemberCreditLimitsEnabled = vi.hoisted(() => ({ value: false })) vi.mock(import('@/platform/distribution/types'), () => ({ get isCloud() { @@ -40,6 +41,9 @@ vi.mock(import('@/composables/useFeatureFlags'), () => ({ flags: { get billingControlEnabled() { return mockBillingControlEnabled.value + }, + get memberCreditLimitsEnabled() { + return mockMemberCreditLimitsEnabled.value } } }) @@ -91,6 +95,7 @@ function resetStore() { mockIsCancelled.value = false mockIsTeamPlan.value = false mockBillingControlEnabled.value = false + mockMemberCreditLimitsEnabled.value = false mockIsCloud.value = true mockShouldUseWorkspaceBilling.value = true } @@ -286,10 +291,17 @@ describe('useWorkspaceUI', () => { expect(ui.uiConfig.value.showCreditsColumn).toBe(false) }) - it('adds the credits column when billing controls are enabled', async () => { + it('keeps the credits column hidden under billing controls alone', async () => { mockBillingControlEnabled.value = true const ui = await loadComposable() + expect(ui.uiConfig.value.showCreditsColumn).toBe(false) + }) + + it('adds the credits column when member credit limits are enabled', async () => { + mockMemberCreditLimitsEnabled.value = true + const ui = await loadComposable() + expect(ui.uiConfig.value.showCreditsColumn).toBe(true) expect(ui.uiConfig.value.membersGridCols).toBe( 'grid-cols-[38%_18%_30%_14%]' diff --git a/src/platform/workspace/composables/useWorkspaceUI.ts b/src/platform/workspace/composables/useWorkspaceUI.ts index 11a79f1f3d1..dd5b03cdb11 100644 --- a/src/platform/workspace/composables/useWorkspaceUI.ts +++ b/src/platform/workspace/composables/useWorkspaceUI.ts @@ -220,7 +220,7 @@ function useWorkspaceUIInternal() { const uiConfig = computed(() => { const base = getUIConfig(workspaceType.value, workspaceRole.value) const showCreditsColumn = - flags.billingControlEnabled && + flags.memberCreditLimitsEnabled && workspaceType.value === 'team' && workspaceRole.value === 'owner' if (!showCreditsColumn) return base diff --git a/src/storybook/mocks/useWorkspaceUI.ts b/src/storybook/mocks/useWorkspaceUI.ts index f40b6fa19db..fed6b11f91a 100644 --- a/src/storybook/mocks/useWorkspaceUI.ts +++ b/src/storybook/mocks/useWorkspaceUI.ts @@ -13,6 +13,7 @@ export interface WorkspaceUIMockState { canManageSubscriptionLifecycle: boolean canDowngradeToPersonal: boolean isSubscriptionCancelled: boolean + canReactivatePlan: boolean } const defaultState: WorkspaceUIMockState = { @@ -21,7 +22,8 @@ const defaultState: WorkspaceUIMockState = { canManageSubscription: true, canManageSubscriptionLifecycle: true, canDowngradeToPersonal: true, - isSubscriptionCancelled: false + isSubscriptionCancelled: false, + canReactivatePlan: true } const state = ref({ ...defaultState }) @@ -42,6 +44,9 @@ export function useWorkspaceUI() { state.value.canManageSubscriptionLifecycle, canDowngradeToPersonal: state.value.canDowngradeToPersonal })), - isSubscriptionCancelled: computed(() => state.value.isSubscriptionCancelled) + isSubscriptionCancelled: computed( + () => state.value.isSubscriptionCancelled + ), + canReactivatePlan: computed(() => state.value.canReactivatePlan) } }