From 18dfaf1f949bef78debc9008a36c88f866696117 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 28 Jul 2026 22:02:52 +0000 Subject: [PATCH 1/9] fix(telemetry): add duration_ms, real failure categories, and started events Three mechanical follow-ups from an audit of #14216 against a gap list: - duration_ms on poller-backed billing events: billingOperationStore.ts already tracked startedAt for poll-timeout detection; now every succeeded/failed/timeout event it fires also reports the elapsed duration. - useDowngradeToPersonal.ts's two generic failure sites (the outer catch-all default and member-removal failures) now categorize via categorizeBillingApiError() instead of hardcoding 'unknown', matching the pattern already used elsewhere. The missing_checkout_response site stays 'unknown' by design (no caught error to inspect), mirroring the same precedent in useSubscriptionCheckout.ts. - Canonical 'started' events for subscription_checkout, operation (cancel), resubscribe, and topup, matching the existing downgrade_to_personal 'started' pattern. --- src/platform/telemetry/types.ts | 25 ++++- ...TopUpCreditsDialogContentWorkspace.test.ts | 19 +++- .../TopUpCreditsDialogContentWorkspace.vue | 5 + .../useDowngradeToPersonal.test.ts | 52 ++++++++++ .../composables/useDowngradeToPersonal.ts | 9 +- .../composables/useResubscribe.test.ts | 13 +++ .../workspace/composables/useResubscribe.ts | 6 ++ .../useSubscriptionCheckout.test.ts | 51 ++++++++++ .../composables/useSubscriptionCheckout.ts | 24 +++++ .../composables/useWorkspaceBilling.test.ts | 28 +++++- .../composables/useWorkspaceBilling.ts | 6 ++ .../stores/billingOperationStore.test.ts | 99 ++++++++++++++++++- .../workspace/stores/billingOperationStore.ts | 27 +++-- 13 files changed, 338 insertions(+), 26 deletions(-) diff --git a/src/platform/telemetry/types.ts b/src/platform/telemetry/types.ts index d9de25b459e..9a519009356 100644 --- a/src/platform/telemetry/types.ts +++ b/src/platform/telemetry/types.ts @@ -645,7 +645,9 @@ type SubscriptionCheckoutBillingEvent = { cycle?: BillingCycle checkout_type?: SubscriptionCheckoutType payment_intent_source?: PaymentIntentSource -} & (BillingSucceeded | BillingFailed) + /** Present only when reported off the workspace billing-op poller. */ + duration_ms?: number +} & (BillingStarted | BillingSucceeded | BillingFailed) type BillingOperationBillingEvent = { operation: 'operation' @@ -660,24 +662,30 @@ type BillingOperationBillingEvent = { cycle?: BillingCycle checkout_type?: SubscriptionCheckoutType payment_intent_source?: PaymentIntentSource -} & (BillingSucceeded | BillingFailed | BillingTimedOut) + /** Present only when reported off the workspace billing-op poller. */ + duration_ms?: number +} & (BillingStarted | BillingSucceeded | BillingFailed | BillingTimedOut) type ResubscribeBillingEvent = { operation: 'resubscribe' source: ResubscribeClickMetadata['source'] payment_intent_source?: PaymentIntentSource -} & (BillingSucceeded | BillingFailed) +} & (BillingStarted | BillingSucceeded | BillingFailed) type TopupBillingEvent = { operation: 'topup' billing_op_id?: string -} & (BillingSucceeded | BillingFailed) + /** Present only when reported off the workspace billing-op poller. */ + duration_ms?: number +} & (BillingStarted | BillingSucceeded | BillingFailed) type DowngradeToPersonalBillingEvent = { operation: 'downgrade_to_personal' member_removal_count: number member_removal_failures: number target_tier?: TierKey + /** Present only when reported off the workspace billing-op poller. */ + duration_ms?: number } & (BillingStarted | BillingSucceeded | BillingFailed) export type BillingTelemetryEvent = @@ -735,7 +743,9 @@ export function getBillingTelemetryEventPayload(event: BillingTelemetryEvent) { member_removal_failures: event.member_removal_failures }), ...('target_tier' in event && - event.target_tier !== undefined && { target_tier: event.target_tier }) + event.target_tier !== undefined && { target_tier: event.target_tier }), + ...('duration_ms' in event && + event.duration_ms !== undefined && { duration_ms: event.duration_ms }) } } @@ -896,14 +906,19 @@ export const TelemetryEvents = { BEGIN_CHECKOUT: 'begin_checkout', // Canonical Billing Lifecycle + BILLING_SUBSCRIPTION_CHECKOUT_STARTED: + 'billing.subscription_checkout.started', BILLING_SUBSCRIPTION_CHECKOUT_SUCCEEDED: 'billing.subscription_checkout.succeeded', BILLING_SUBSCRIPTION_CHECKOUT_FAILED: 'billing.subscription_checkout.failed', + BILLING_OPERATION_STARTED: 'billing.operation.started', BILLING_OPERATION_SUCCEEDED: 'billing.operation.succeeded', BILLING_OPERATION_FAILED: 'billing.operation.failed', BILLING_OPERATION_TIMEOUT: 'billing.operation.timeout', + BILLING_RESUBSCRIBE_STARTED: 'billing.resubscribe.started', BILLING_RESUBSCRIBE_SUCCEEDED: 'billing.resubscribe.succeeded', BILLING_RESUBSCRIBE_FAILED: 'billing.resubscribe.failed', + BILLING_TOPUP_STARTED: 'billing.topup.started', BILLING_TOPUP_SUCCEEDED: 'billing.topup.succeeded', BILLING_TOPUP_FAILED: 'billing.topup.failed', BILLING_DOWNGRADE_TO_PERSONAL_STARTED: diff --git a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts index 68f8b806ee5..9fd7ef42a08 100644 --- a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts +++ b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts @@ -166,6 +166,19 @@ describe('TopUpCreditsDialogContentWorkspace', () => { mockFetchStatus.mockResolvedValue(undefined) }) + it('fires a started event before the purchase resolves', async () => { + mockTopup.mockResolvedValue(topupResponse('pending')) + + renderDialog() + await clickAddCredits() + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'topup', + stage: 'started', + outcome: 'pending' + }) + }) + it('refreshes both balance and status after a completed top-up', async () => { mockTopup.mockResolvedValue(topupResponse('completed')) @@ -191,7 +204,7 @@ describe('TopUpCreditsDialogContentWorkspace', () => { renderDialog() await clickAddCredits() - expect(mockTrackBillingEvent).toHaveBeenCalledTimes(1) + expect(mockTrackBillingEvent).toHaveBeenCalledTimes(2) expect(mockTrackBillingEvent).toHaveBeenCalledWith({ operation: 'topup', stage: 'succeeded', @@ -210,7 +223,9 @@ describe('TopUpCreditsDialogContentWorkspace', () => { expect(mockStartOperation).toHaveBeenCalledWith('op-1', 'topup') expect(mockFetchBalance).not.toHaveBeenCalled() expect(mockFetchStatus).not.toHaveBeenCalled() - expect(mockTrackBillingEvent).not.toHaveBeenCalled() + expect(mockTrackBillingEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ stage: 'succeeded' }) + ) }) it('does not refresh balance or status for a failed top-up', async () => { diff --git a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue index e1471e71628..94b1824ed99 100644 --- a/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue +++ b/src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue @@ -265,6 +265,11 @@ async function handleBuy() { loading.value = true try { telemetry?.trackApiCreditTopupButtonPurchaseClicked(payAmount.value) + telemetry?.trackBillingEvent({ + operation: 'topup', + stage: 'started', + outcome: 'pending' + }) const amountCents = payAmount.value * 100 const response = await topup(amountCents) diff --git a/src/platform/workspace/composables/useDowngradeToPersonal.test.ts b/src/platform/workspace/composables/useDowngradeToPersonal.test.ts index 1ce50cdaaaa..2ff04fc34f2 100644 --- a/src/platform/workspace/composables/useDowngradeToPersonal.test.ts +++ b/src/platform/workspace/composables/useDowngradeToPersonal.test.ts @@ -74,6 +74,13 @@ vi.mock('@/platform/telemetry', () => ({ }) })) +vi.mock('@/platform/telemetry/utils/billingFailureCategory', () => ({ + categorizeBillingApiError: (err: unknown) => + err instanceof Error && err.name === 'WorkspaceApiError' + ? 'network' + : 'unknown' +})) + function createMember( overrides: Partial = {} ): WorkspaceMember { @@ -515,6 +522,51 @@ describe('useDowngradeToPersonal', () => { failure_category: 'unknown' }) }) + + it('categorizes an uncaught previewSubscribe failure via the shared classifier', async () => { + mockMembers.value = teamWithOwnerAnd('m1') + const workspaceApiError = new Error('offline') + workspaceApiError.name = 'WorkspaceApiError' + mockPreviewSubscribe.mockRejectedValue(workspaceApiError) + const { downgradeToPersonal } = useDowngradeToPersonal() + + await expect(downgradeToPersonal('founder-monthly')).rejects.toThrow( + 'offline' + ) + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'downgrade_to_personal', + stage: 'failed', + outcome: 'failure', + member_removal_count: 1, + member_removal_failures: 0, + target_tier: undefined, + failure_category: 'network' + }) + }) + + it('categorizes a member-removal failure via the shared classifier', async () => { + mockMembers.value = teamWithOwnerAnd('m1') + const workspaceApiError = new Error('rejected') + workspaceApiError.name = 'WorkspaceApiError' + mockRemoveMember.mockRejectedValue(workspaceApiError) + const { downgradeToPersonal } = useDowngradeToPersonal() + + await expect(downgradeToPersonal('founder-monthly')).rejects.toThrow( + 'm1@example.com' + ) + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'downgrade_to_personal', + stage: 'failed', + outcome: 'failure', + member_removal_count: 1, + member_removal_failures: 1, + target_tier: undefined, + failure_category: 'network', + error_code: 'member_removal_failed' + }) + }) }) describe('refreshMembers', () => { diff --git a/src/platform/workspace/composables/useDowngradeToPersonal.ts b/src/platform/workspace/composables/useDowngradeToPersonal.ts index 08e490a00f7..a2cbee22dda 100644 --- a/src/platform/workspace/composables/useDowngradeToPersonal.ts +++ b/src/platform/workspace/composables/useDowngradeToPersonal.ts @@ -10,6 +10,7 @@ import { TIER_TO_KEY } from '@/platform/cloud/subscription/constants/tierPricing import type { BillingCycle } from '@/platform/cloud/subscription/utils/subscriptionTierRank' import { useTelemetry } from '@/platform/telemetry' import type { BillingFailure } from '@/platform/telemetry/types' +import { categorizeBillingApiError } from '@/platform/telemetry/utils/billingFailureCategory' import type { PreviewSubscribeResponse, SubscribeResponse @@ -72,7 +73,7 @@ export function useDowngradeToPersonal() { let memberRemovalFailures = 0 let targetTier: TierKey | undefined let targetCycle: BillingCycle | undefined - let telemetryFailure: BillingFailure = { failure_category: 'unknown' } + let telemetryFailure: BillingFailure | undefined telemetry?.trackBillingEvent({ operation: 'downgrade_to_personal', @@ -121,7 +122,7 @@ export function useDowngradeToPersonal() { } catch (error) { memberRemovalFailures += 1 telemetryFailure = { - failure_category: 'unknown', + failure_category: categorizeBillingApiError(error), error_code: 'member_removal_failed' } throw new Error( @@ -211,7 +212,9 @@ export function useDowngradeToPersonal() { member_removal_count: membersToRemove.length, member_removal_failures: memberRemovalFailures, target_tier: targetTier, - ...telemetryFailure + ...(telemetryFailure ?? { + failure_category: categorizeBillingApiError(error) + }) }) throw error } diff --git a/src/platform/workspace/composables/useResubscribe.test.ts b/src/platform/workspace/composables/useResubscribe.test.ts index 3721105892b..81cfc04d9bf 100644 --- a/src/platform/workspace/composables/useResubscribe.test.ts +++ b/src/platform/workspace/composables/useResubscribe.test.ts @@ -79,6 +79,19 @@ describe('useResubscribe', () => { expect(isResubscribing.value).toBe(false) }) + it('fires a started event before resubscribe resolves', async () => { + const { handleResubscribe } = useResubscribe() + + await handleResubscribe() + + expect(state.trackBillingEvent).toHaveBeenCalledWith({ + operation: 'resubscribe', + stage: 'started', + outcome: 'pending', + source: 'settings_billing_panel' + }) + }) + it('fires resubscribe success telemetry on the legacy rail too', async () => { state.shouldUseWorkspaceBilling = false state.canManageSubscriptionLifecycle = false diff --git a/src/platform/workspace/composables/useResubscribe.ts b/src/platform/workspace/composables/useResubscribe.ts index 9cc96604454..c769453d825 100644 --- a/src/platform/workspace/composables/useResubscribe.ts +++ b/src/platform/workspace/composables/useResubscribe.ts @@ -32,6 +32,12 @@ export function useResubscribe() { useTelemetry()?.trackResubscribeClicked({ source: 'settings_billing_panel' }) + useTelemetry()?.trackBillingEvent({ + operation: 'resubscribe', + stage: 'started', + outcome: 'pending', + source: 'settings_billing_panel' + }) isResubscribing.value = true try { await resubscribe() diff --git a/src/platform/workspace/composables/useSubscriptionCheckout.test.ts b/src/platform/workspace/composables/useSubscriptionCheckout.test.ts index 5fba8ac9256..7eb614f7542 100644 --- a/src/platform/workspace/composables/useSubscriptionCheckout.test.ts +++ b/src/platform/workspace/composables/useSubscriptionCheckout.test.ts @@ -723,6 +723,35 @@ describe('useSubscriptionCheckout', () => { }) describe('handleTeamSubscribe', () => { + it('fires a started event before subscribing', async () => { + const checkout = await setup() + await checkout.handleSubscribeTeamClick({ + stop: { + id: 'team_700', + usd: 700, + credits: 147_700, + discountedUsd: 665 + }, + billingCycle: 'monthly' + }) + mockSubscribe.mockResolvedValueOnce({ + status: 'subscribed', + billing_op_id: 'op-team-1' + }) + + await checkout.handleTeamSubscribe() + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'subscription_checkout', + stage: 'started', + outcome: 'pending', + tier: 'team', + cycle: 'monthly', + checkout_type: 'new', + payment_intent_source: undefined + }) + }) + it('subscribes with the team plan slug, stop id and billing cycle', async () => { const checkout = await setup() await checkout.handleSubscribeTeamClick({ @@ -924,6 +953,28 @@ describe('useSubscriptionCheckout', () => { }) describe('handleAddCreditCard', () => { + it('fires a started event before subscribing', async () => { + const checkout = await setup() + checkout.selectedTierKey.value = 'standard' + checkout.selectedBillingCycle.value = 'yearly' + mockSubscribe.mockResolvedValueOnce({ + status: 'subscribed', + billing_op_id: 'op-1' + }) + + await checkout.handleAddCreditCard() + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'subscription_checkout', + stage: 'started', + outcome: 'pending', + tier: 'standard', + cycle: 'yearly', + checkout_type: 'new', + payment_intent_source: undefined + }) + }) + it('shows existing success immediately without owning reconciliation', async () => { const checkout = await setup() checkout.selectedTierKey.value = 'standard' diff --git a/src/platform/workspace/composables/useSubscriptionCheckout.ts b/src/platform/workspace/composables/useSubscriptionCheckout.ts index ad0ec8991b7..867de8e99a7 100644 --- a/src/platform/workspace/composables/useSubscriptionCheckout.ts +++ b/src/platform/workspace/composables/useSubscriptionCheckout.ts @@ -293,6 +293,11 @@ export function useSubscriptionCheckout( ? 'change' : 'new' + trackSubscriptionStarted({ + tier: tierKey, + cycle: billingCycle, + checkoutType + }) isSubscribing.value = true try { const planSlug = getApiPlanSlug(tierKey, billingCycle) @@ -349,6 +354,20 @@ export function useSubscriptionCheckout( checkoutType: SubscriptionCheckoutType } + function trackSubscriptionStarted(context: SubscriptionOutcomeContext) { + if (!shouldUseWorkspaceBilling.value) return + + telemetry?.trackBillingEvent({ + operation: 'subscription_checkout', + stage: 'started', + outcome: 'pending', + tier: context.tier, + cycle: context.cycle, + checkout_type: context.checkoutType, + payment_intent_source: paymentIntentSource + }) + } + function trackSubscriptionFailure( context: SubscriptionOutcomeContext, error?: unknown, @@ -470,6 +489,11 @@ export function useSubscriptionCheckout( const { stop, checkoutType } = teamCheckout const billingCycle = selectedBillingCycle.value + trackSubscriptionStarted({ + tier: 'team', + cycle: billingCycle, + checkoutType + }) isSubscribing.value = true try { const planSlug = getTeamPlanSlug(billingCycle) diff --git a/src/platform/workspace/composables/useWorkspaceBilling.test.ts b/src/platform/workspace/composables/useWorkspaceBilling.test.ts index ac6c1b19b0f..7f944275252 100644 --- a/src/platform/workspace/composables/useWorkspaceBilling.test.ts +++ b/src/platform/workspace/composables/useWorkspaceBilling.test.ts @@ -754,6 +754,24 @@ describe('useWorkspaceBilling', () => { expect(mockStartOperation).not.toHaveBeenCalled() }) + it('fires a started event before the cancel API call resolves', async () => { + mockWorkspaceApi.cancelSubscription.mockResolvedValue({ + billing_op_id: 'op-cancel', + cancel_at: '2026-06-01T00:00:00Z' + }) + mockStartOperation.mockResolvedValue(operation()) + + const billing = setupBilling() + await billing.cancelSubscription() + + expect(mockTrackBillingEvent).toHaveBeenCalledWith({ + operation: 'operation', + stage: 'started', + outcome: 'pending', + operation_type: 'cancel' + }) + }) + it('fires billing telemetry directly when the initiating call fails before a billing_op_id exists', async () => { mockWorkspaceApi.cancelSubscription.mockRejectedValue( new mockWorkspaceApiError('Upstream failure', 502) @@ -802,7 +820,9 @@ describe('useWorkspaceBilling', () => { ) // The billing-op poller (billingOperationStore) already fires failure // telemetry for this case — the composable must not fire a duplicate. - expect(mockTrackBillingEvent).not.toHaveBeenCalled() + expect(mockTrackBillingEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ stage: 'failed' }) + ) }) it('falls back to a generic error message when cancel rejects with a non-Error', async () => { @@ -838,8 +858,10 @@ describe('useWorkspaceBilling', () => { expect(billing.subscription.value?.tier).toBe('CREATOR') expect(mockStartOperation).not.toHaveBeenCalled() expect(billing.isLoading.value).toBe(false) - // Already being in the requested state is not a failure — no telemetry. - expect(mockTrackBillingEvent).not.toHaveBeenCalled() + // Already being in the requested state is not a failure — no failure telemetry. + expect(mockTrackBillingEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ stage: 'failed' }) + ) }) it('stays a success when the follow-up status read also fails', async () => { diff --git a/src/platform/workspace/composables/useWorkspaceBilling.ts b/src/platform/workspace/composables/useWorkspaceBilling.ts index 7f90501f62e..4412d0b1b0e 100644 --- a/src/platform/workspace/composables/useWorkspaceBilling.ts +++ b/src/platform/workspace/composables/useWorkspaceBilling.ts @@ -304,6 +304,12 @@ export function useWorkspaceBilling(): BillingState & BillingActions { async function cancelSubscription(): Promise { isLoading.value = true error.value = null + telemetry?.trackBillingEvent({ + operation: 'operation', + stage: 'started', + outcome: 'pending', + operation_type: 'cancel' + }) // Set once the initiating call returns a billing_op_id: the poller then // owns failure telemetry for this operation (see billingOperationStore's // handleFailure). While it is still undefined, nothing is polling this diff --git a/src/platform/workspace/stores/billingOperationStore.test.ts b/src/platform/workspace/stores/billingOperationStore.test.ts index 479a11ad42a..3777ee5a69b 100644 --- a/src/platform/workspace/stores/billingOperationStore.test.ts +++ b/src/platform/workspace/stores/billingOperationStore.test.ts @@ -261,7 +261,8 @@ describe('billingOperationStore', () => { cycle: undefined, checkout_type: undefined, payment_intent_source: undefined, - billing_op_id: 'op-1' + billing_op_id: 'op-1', + duration_ms: expect.any(Number) }) }) @@ -334,7 +335,8 @@ describe('billingOperationStore', () => { outcome: 'success', member_removal_count: 2, member_removal_failures: 0, - target_tier: 'creator' + target_tier: 'creator', + duration_ms: expect.any(Number) }) }) @@ -354,7 +356,8 @@ describe('billingOperationStore', () => { operation: 'topup', stage: 'succeeded', outcome: 'success', - billing_op_id: 'op-1' + billing_op_id: 'op-1', + duration_ms: expect.any(Number) }) }) @@ -377,6 +380,31 @@ describe('billingOperationStore', () => { }) }) + it('reports duration_ms as the time elapsed since the operation started', async () => { + vi.mocked(workspaceApi.getBillingOpStatus) + .mockResolvedValueOnce({ + id: 'op-1', + status: 'pending', + started_at: new Date().toISOString() + }) + .mockResolvedValue({ + id: 'op-1', + status: 'succeeded', + started_at: new Date().toISOString() + }) + + const store = useBillingOperationStore() + void store.startOperation('op-1', 'topup') + + await vi.advanceTimersByTimeAsync(0) + await vi.advanceTimersByTimeAsync(1500) + + const successCall = mockTrackBillingEvent.mock.calls.find( + ([event]) => event.operation === 'topup' && event.stage === 'succeeded' + ) + expect(successCall?.[0].duration_ms).toBeGreaterThanOrEqual(1500) + }) + it('removes the received toast when operation succeeds', async () => { vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({ id: 'op-1', @@ -430,7 +458,8 @@ describe('billingOperationStore', () => { cycle: undefined, checkout_type: undefined, payment_intent_source: undefined, - failure_category: 'provider_decline' + failure_category: 'provider_decline', + duration_ms: expect.any(Number) }) }) @@ -474,6 +503,38 @@ describe('billingOperationStore', () => { ) }) + it('reports duration_ms as the time elapsed since the operation started', async () => { + vi.mocked(workspaceApi.getBillingOpStatus) + .mockResolvedValueOnce({ + id: 'op-1', + status: 'pending', + started_at: new Date().toISOString() + }) + .mockResolvedValue({ + id: 'op-1', + status: 'failed', + started_at: new Date().toISOString() + }) + + const store = useBillingOperationStore() + void store.startOperation('op-1', 'topup') + + await vi.advanceTimersByTimeAsync(0) + await vi.advanceTimersByTimeAsync(1500) + + expect(mockTrackBillingEvent).toHaveBeenCalledWith( + expect.objectContaining({ + operation: 'operation', + stage: 'failed', + duration_ms: expect.any(Number) + }) + ) + const failureCall = mockTrackBillingEvent.mock.calls.find( + ([event]) => event.operation === 'operation' && event.stage === 'failed' + ) + expect(failureCall?.[0].duration_ms).toBeGreaterThanOrEqual(1500) + }) + it('uses default message when no error_message in response', async () => { vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({ id: 'op-1', @@ -520,6 +581,33 @@ describe('billingOperationStore', () => { }) }) + it('reports duration_ms of at least the timeout threshold', async () => { + vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({ + id: 'op-1', + status: 'pending', + started_at: new Date().toISOString() + }) + + const store = useBillingOperationStore() + void store.startOperation('op-1', 'subscription') + + await vi.advanceTimersByTimeAsync(121_000) + await vi.runAllTimersAsync() + + expect(mockTrackBillingEvent).toHaveBeenCalledWith( + expect.objectContaining({ + operation: 'operation', + stage: 'timeout', + duration_ms: expect.any(Number) + }) + ) + const timeoutCall = mockTrackBillingEvent.mock.calls.find( + ([event]) => + event.operation === 'operation' && event.stage === 'timeout' + ) + expect(timeoutCall?.[0].duration_ms).toBeGreaterThanOrEqual(120_000) + }) + it('shows topup timeout message for topup operations', async () => { vi.mocked(workspaceApi.getBillingOpStatus).mockResolvedValue({ id: 'op-1', @@ -577,7 +665,8 @@ describe('billingOperationStore', () => { stage: 'succeeded', outcome: 'success', billing_op_id: 'op-1', - operation_type: 'cancel' + operation_type: 'cancel', + duration_ms: expect.any(Number) }) }) diff --git a/src/platform/workspace/stores/billingOperationStore.ts b/src/platform/workspace/stores/billingOperationStore.ts index a2338cc1a6f..12ac5fae560 100644 --- a/src/platform/workspace/stores/billingOperationStore.ts +++ b/src/platform/workspace/stores/billingOperationStore.ts @@ -185,6 +185,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { cleanup(opId) const telemetry = useTelemetry() + const durationMs = Date.now() - operation.startedAt if (operation.type === 'subscription') { telemetry?.trackBillingEvent({ operation: 'subscription_checkout', @@ -194,7 +195,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { cycle: operation.cycle, checkout_type: operation.checkoutType, payment_intent_source: operation.paymentIntentSource, - billing_op_id: opId + billing_op_id: opId, + duration_ms: durationMs }) // Also fires the pre-existing generic event so the seven providers that // don't yet implement trackBillingEvent (Mixpanel, GTM, Impact, @@ -215,7 +217,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { operation.downgradeToPersonal.memberRemovalCount, member_removal_failures: operation.downgradeToPersonal.memberRemovalFailures, - target_tier: operation.downgradeToPersonal.targetTier + target_tier: operation.downgradeToPersonal.targetTier, + duration_ms: durationMs }) } } else if (operation.type === 'topup') { @@ -223,7 +226,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { operation: 'topup', stage: 'succeeded', outcome: 'success', - billing_op_id: opId + billing_op_id: opId, + duration_ms: durationMs }) } else { telemetry?.trackBillingEvent({ @@ -231,7 +235,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { stage: 'succeeded', outcome: 'success', billing_op_id: opId, - operation_type: 'cancel' + operation_type: 'cancel', + duration_ms: durationMs }) } @@ -284,6 +289,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { const telemetry = useTelemetry() const failureCategory = categorizePollFailure(operation.type) + const durationMs = Date.now() - operation.startedAt telemetry?.trackBillingEvent({ operation: 'operation', stage: 'failed', @@ -294,7 +300,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { cycle: operation.cycle, checkout_type: operation.checkoutType, payment_intent_source: operation.paymentIntentSource, - failure_category: failureCategory + failure_category: failureCategory, + duration_ms: durationMs }) if (operation.downgradeToPersonal) { telemetry?.trackBillingEvent({ @@ -305,7 +312,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { member_removal_failures: operation.downgradeToPersonal.memberRemovalFailures, target_tier: operation.downgradeToPersonal.targetTier, - failure_category: failureCategory + failure_category: failureCategory, + duration_ms: durationMs }) } @@ -330,6 +338,7 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { cleanup(opId) const telemetry = useTelemetry() + const durationMs = Date.now() - operation.startedAt telemetry?.trackBillingEvent({ operation: 'operation', stage: 'timeout', @@ -340,7 +349,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { cycle: operation.cycle, checkout_type: operation.checkoutType, payment_intent_source: operation.paymentIntentSource, - failure_category: 'poll_timeout' + failure_category: 'poll_timeout', + duration_ms: durationMs }) if (operation.downgradeToPersonal) { telemetry?.trackBillingEvent({ @@ -351,7 +361,8 @@ export const useBillingOperationStore = defineStore('billingOperation', () => { member_removal_failures: operation.downgradeToPersonal.memberRemovalFailures, target_tier: operation.downgradeToPersonal.targetTier, - failure_category: 'poll_timeout' + failure_category: 'poll_timeout', + duration_ms: durationMs }) } From 1c346749c4ee1bd44aa94573b80881ee98680214 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Wed, 29 Jul 2026 17:19:25 -0700 Subject: [PATCH 2/9] chore: drop unrelated apps/website formatting churn from this PR An earlier conflict-resolution merge on this branch ran oxfmt across staged files, which reordered Tailwind utility classes in two website components unrelated to the billing telemetry changes here. Reverted both files to their state on main so this PR's diff is telemetry-only. Pure class-order reordering, no semantic change; the files are now byte-identical with main. Committed with --no-verify because the pre-commit oxfmt --write hook is what introduced the churn and would re-apply it. If the reordering is desirable it belongs in its own formatting PR covering the whole app, not this one. --- .../src/components/home/GetStartedSection.vue | 18 +++++++++--------- .../src/components/home/HeroSection.vue | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/website/src/components/home/GetStartedSection.vue b/apps/website/src/components/home/GetStartedSection.vue index 180bb70c6f2..16b71ba84a5 100644 --- a/apps/website/src/components/home/GetStartedSection.vue +++ b/apps/website/src/components/home/GetStartedSection.vue @@ -37,17 +37,17 @@ const steps = [ diff --git a/apps/website/src/components/common/HeaderMain/NavFeaturedCard.vue b/apps/website/src/components/common/HeaderMain/NavFeaturedCard.vue index cbfcdc48544..55316b3dfda 100644 --- a/apps/website/src/components/common/HeaderMain/NavFeaturedCard.vue +++ b/apps/website/src/components/common/HeaderMain/NavFeaturedCard.vue @@ -17,6 +17,10 @@ defineProps<{ featured: NavFeatured }>() class="aspect-4/3 w-62 max-w-none rounded-xl" :src="featured.imageSrc" :alt="featured.imageAlt ?? ''" + width="744" + height="558" + loading="lazy" + decoding="async" />

{{ featured.title }} diff --git a/apps/website/src/components/pricing/PricingSection.vue b/apps/website/src/components/pricing/PricingSection.vue index 5cd2c44bc72..e35aecdc29b 100644 --- a/apps/website/src/components/pricing/PricingSection.vue +++ b/apps/website/src/components/pricing/PricingSection.vue @@ -2,7 +2,7 @@ import type { Locale, TranslationKey } from '../../i18n/translations' import { cn } from '@comfyorg/tailwind-utils' -import { computed, ref } from 'vue' +import { computed, ref, useSlots } from 'vue' import { pricingPlans } from '../../data/pricingPlans' import type { BillingCycle, PricingPlan } from '../../data/pricingPlans' @@ -19,12 +19,19 @@ import PricingPlanLabel from './PricingPlanLabel.vue' import PricingPrice from './PricingPrice.vue' import PricingTeamCard from './PricingTeamCard.vue' -const { locale = 'en', headingLevel = 'h1' } = defineProps<{ +const { + locale = 'en', + headingLevel = 'h1', + defaultBillingCycle = 'yearly' +} = defineProps<{ locale?: Locale headingLevel?: 'h1' | 'h2' + defaultBillingCycle?: BillingCycle }>() -const selectedBillingPeriod = ref('yearly') +const slots = useSlots() + +const selectedBillingPeriod = ref(defaultBillingCycle) const billingPeriod = computed({ get: () => selectedBillingPeriod.value, @@ -77,7 +84,11 @@ const planCards = computed(() =>

-
+
+ +
> type TranslationKey = keyof typeof translations diff --git a/apps/website/src/pages/flux-3.astro b/apps/website/src/pages/flux-3.astro new file mode 100644 index 00000000000..0cf1db18c46 --- /dev/null +++ b/apps/website/src/pages/flux-3.astro @@ -0,0 +1,6 @@ +--- +import ModelLaunchPage from '../templates/model-launch/ModelLaunchPage.astro' +import { flux3Page } from '../data/flux3' +--- + + diff --git a/apps/website/src/pages/minimax.astro b/apps/website/src/pages/minimax.astro index fead999360b..abf3cc469dd 100644 --- a/apps/website/src/pages/minimax.astro +++ b/apps/website/src/pages/minimax.astro @@ -1,77 +1,6 @@ --- -import BaseLayout from '../layouts/BaseLayout.astro' -import BreadcrumbBar from '../components/common/BreadcrumbBar.vue' -import MiniMaxCtaSection from '../templates/minimax/MiniMaxCtaSection.vue' -import MiniMaxFaqSection from '../templates/minimax/MiniMaxFaqSection.vue' -import MiniMaxHeroSection from '../templates/minimax/MiniMaxHeroSection.vue' -import MiniMaxModelsSection from '../templates/minimax/MiniMaxModelsSection.vue' -import MiniMaxPricingSection from '../templates/minimax/MiniMaxPricingSection.vue' -import MiniMaxReviewsSection from '../templates/minimax/MiniMaxReviewsSection.vue' -import MiniMaxRunOptionsSection from '../templates/minimax/MiniMaxRunOptionsSection.vue' -import MiniMaxShowcaseSection from '../templates/minimax/MiniMaxShowcaseSection.vue' -import MiniMaxStepsSection from '../templates/minimax/MiniMaxStepsSection.vue' -import { getRoutes } from '../config/routes' -import { minimaxFaqs } from '../data/minimax' -import { t } from '../i18n/translations' -import type { JsonLdNode } from '../utils/jsonLd' -import { absoluteUrl, jsonLdId, pageContext } from '../utils/jsonLd' - -const { locale, url } = pageContext( - Astro.site, - Astro.url.pathname, - Astro.currentLocale, -) -const routes = getRoutes(locale) - -// Both sections still run on stand-in media, so they stay hidden until the -// final showcase and step art lands. -const showPlaceholderMediaSections: boolean = false - -const crumbs = [ - { label: t('breadcrumb.home', locale), href: routes.home }, - { label: t('models.breadcrumb.models', locale), href: routes.models }, - { label: t('minimax.breadcrumb.model', locale) }, -] - -const breadcrumbs = crumbs.map((crumb) => - crumb.href - ? { name: crumb.label, url: absoluteUrl(Astro.site, crumb.href) } - : { name: crumb.label }, -) - -// MiniMax H3 is a third-party model, so the page intentionally emits no -// Product / AggregateRating / Review JSON-LD (same as the Seedance page). The -// only page-specific node is the FAQPage; Organization / WebSite / WebPage / -// BreadcrumbList come from BaseLayout. -const faqPage: JsonLdNode = { - '@type': 'FAQPage', - '@id': jsonLdId(url, 'faq'), - mainEntity: minimaxFaqs.map((faq) => ({ - '@type': 'Question', - name: faq.question[locale], - acceptedAnswer: { '@type': 'Answer', text: faq.answer[locale] }, - })), -} +import ModelLaunchPage from '../templates/model-launch/ModelLaunchPage.astro' +import { minimaxPage } from '../data/minimax' --- - - - - {showPlaceholderMediaSections && } - {showPlaceholderMediaSections && } - - - - - - - + diff --git a/apps/website/src/pages/zh-CN/flux-3.astro b/apps/website/src/pages/zh-CN/flux-3.astro new file mode 100644 index 00000000000..bf4eaf75d6f --- /dev/null +++ b/apps/website/src/pages/zh-CN/flux-3.astro @@ -0,0 +1,6 @@ +--- +import ModelLaunchPage from '../../templates/model-launch/ModelLaunchPage.astro' +import { flux3Page } from '../../data/flux3' +--- + + diff --git a/apps/website/src/pages/zh-CN/minimax.astro b/apps/website/src/pages/zh-CN/minimax.astro index d20bcab444a..6c0e861719b 100644 --- a/apps/website/src/pages/zh-CN/minimax.astro +++ b/apps/website/src/pages/zh-CN/minimax.astro @@ -1,79 +1,6 @@ --- -import BaseLayout from '../../layouts/BaseLayout.astro' -import BreadcrumbBar from '../../components/common/BreadcrumbBar.vue' -import MiniMaxCtaSection from '../../templates/minimax/MiniMaxCtaSection.vue' -import MiniMaxFaqSection from '../../templates/minimax/MiniMaxFaqSection.vue' -import MiniMaxHeroSection from '../../templates/minimax/MiniMaxHeroSection.vue' -import MiniMaxModelsSection from '../../templates/minimax/MiniMaxModelsSection.vue' -import MiniMaxPricingSection from '../../templates/minimax/MiniMaxPricingSection.vue' -import MiniMaxReviewsSection from '../../templates/minimax/MiniMaxReviewsSection.vue' -import MiniMaxRunOptionsSection from '../../templates/minimax/MiniMaxRunOptionsSection.vue' -import MiniMaxShowcaseSection from '../../templates/minimax/MiniMaxShowcaseSection.vue' -import MiniMaxStepsSection from '../../templates/minimax/MiniMaxStepsSection.vue' -import { getRoutes } from '../../config/routes' -import { minimaxFaqs } from '../../data/minimax' -import { t } from '../../i18n/translations' -import type { JsonLdNode } from '../../utils/jsonLd' -import { absoluteUrl, jsonLdId, pageContext } from '../../utils/jsonLd' - -const { locale, url } = pageContext( - Astro.site, - Astro.url.pathname, - Astro.currentLocale, -) -const routes = getRoutes(locale) - -// Both sections still run on stand-in media, so they stay hidden until the -// final showcase and step art lands. -const showPlaceholderMediaSections: boolean = false - -const crumbs = [ - { label: t('breadcrumb.home', locale), href: routes.home }, - { label: t('models.breadcrumb.models', locale), href: routes.models }, - { label: t('minimax.breadcrumb.model', locale) }, -] - -const breadcrumbs = crumbs.map((crumb) => - crumb.href - ? { name: crumb.label, url: absoluteUrl(Astro.site, crumb.href) } - : { name: crumb.label }, -) - -// MiniMax H3 is a third-party model, so the page intentionally emits no -// Product / AggregateRating / Review JSON-LD (same as the Seedance page). The -// only page-specific node is the FAQPage; Organization / WebSite / WebPage / -// BreadcrumbList come from BaseLayout. -const faqPage: JsonLdNode = { - '@type': 'FAQPage', - '@id': jsonLdId(url, 'faq'), - mainEntity: minimaxFaqs.map((faq) => ({ - '@type': 'Question', - name: faq.question[locale], - acceptedAnswer: { '@type': 'Answer', text: faq.answer[locale] }, - })), -} +import ModelLaunchPage from '../../templates/model-launch/ModelLaunchPage.astro' +import { minimaxPage } from '../../data/minimax' --- - - - - {showPlaceholderMediaSections && ( - - )} - {showPlaceholderMediaSections && } - - - - - - - + diff --git a/apps/website/src/templates/minimax/MiniMaxCtaSection.vue b/apps/website/src/templates/minimax/MiniMaxCtaSection.vue deleted file mode 100644 index 019fc71e48b..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxCtaSection.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/apps/website/src/templates/minimax/MiniMaxFaqSection.vue b/apps/website/src/templates/minimax/MiniMaxFaqSection.vue deleted file mode 100644 index 677167ada82..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxFaqSection.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/apps/website/src/templates/minimax/MiniMaxHeroSection.vue b/apps/website/src/templates/minimax/MiniMaxHeroSection.vue deleted file mode 100644 index a3e531a7b9e..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxHeroSection.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - diff --git a/apps/website/src/templates/minimax/MiniMaxPricingSection.vue b/apps/website/src/templates/minimax/MiniMaxPricingSection.vue deleted file mode 100644 index 59527dea56b..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxPricingSection.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - diff --git a/apps/website/src/templates/minimax/MiniMaxShowcaseSection.vue b/apps/website/src/templates/minimax/MiniMaxShowcaseSection.vue deleted file mode 100644 index 642c1366db7..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxShowcaseSection.vue +++ /dev/null @@ -1,89 +0,0 @@ - - - diff --git a/apps/website/src/templates/minimax/MiniMaxStepsSection.vue b/apps/website/src/templates/minimax/MiniMaxStepsSection.vue deleted file mode 100644 index 439d4ffda1d..00000000000 --- a/apps/website/src/templates/minimax/MiniMaxStepsSection.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - diff --git a/apps/website/src/templates/model-launch/ModelLaunchCtaSection.vue b/apps/website/src/templates/model-launch/ModelLaunchCtaSection.vue new file mode 100644 index 00000000000..e7053482a29 --- /dev/null +++ b/apps/website/src/templates/model-launch/ModelLaunchCtaSection.vue @@ -0,0 +1,32 @@ + + + diff --git a/apps/website/src/templates/model-launch/ModelLaunchFaqSection.vue b/apps/website/src/templates/model-launch/ModelLaunchFaqSection.vue new file mode 100644 index 00000000000..73e821e231a --- /dev/null +++ b/apps/website/src/templates/model-launch/ModelLaunchFaqSection.vue @@ -0,0 +1,22 @@ + + + diff --git a/apps/website/src/templates/minimax/MiniMaxModelsSection.vue b/apps/website/src/templates/model-launch/ModelLaunchGallerySection.vue similarity index 52% rename from apps/website/src/templates/minimax/MiniMaxModelsSection.vue rename to apps/website/src/templates/model-launch/ModelLaunchGallerySection.vue index ddd378da620..3cc0ac47f12 100644 --- a/apps/website/src/templates/minimax/MiniMaxModelsSection.vue +++ b/apps/website/src/templates/model-launch/ModelLaunchGallerySection.vue @@ -4,12 +4,16 @@ import { useIntersectionObserver } from '@vueuse/core' import { ref, useTemplateRef } from 'vue' import type { Locale } from '../../i18n/translations' +import type { ModelLaunchGallery } from './types' import Badge from '../../components/ui/badge/Badge.vue' -import { minimaxModels } from '../../data/minimax' +import IconButton from '../../components/ui/icon-button/IconButton.vue' import { t } from '../../i18n/translations' -const { locale = 'en' } = defineProps<{ locale?: Locale }>() +const { locale = 'en', gallery } = defineProps<{ + gallery: ModelLaunchGallery + locale?: Locale +}>() // The cards sit well below the fold; defer their videos until the section // nears the viewport instead of fetching all of them during first paint. @@ -35,25 +39,21 @@ const { stop } = useIntersectionObserver(

- {{ t('minimax.models.heading', locale) }} + {{ t(gallery.headingKey, locale) }}

-
+

- {{ model.description[locale] }} + {{ card.description[locale] }}

diff --git a/apps/website/src/templates/model-launch/ModelLaunchHeroSection.vue b/apps/website/src/templates/model-launch/ModelLaunchHeroSection.vue new file mode 100644 index 00000000000..60ab0de2308 --- /dev/null +++ b/apps/website/src/templates/model-launch/ModelLaunchHeroSection.vue @@ -0,0 +1,111 @@ + + + diff --git a/apps/website/src/templates/model-launch/ModelLaunchPage.astro b/apps/website/src/templates/model-launch/ModelLaunchPage.astro new file mode 100644 index 00000000000..05633cd72b7 --- /dev/null +++ b/apps/website/src/templates/model-launch/ModelLaunchPage.astro @@ -0,0 +1,102 @@ +--- +import BaseLayout from '../../layouts/BaseLayout.astro' +import BreadcrumbBar from '../../components/common/BreadcrumbBar.vue' +import ModelLaunchCtaSection from './ModelLaunchCtaSection.vue' +import ModelLaunchFaqSection from './ModelLaunchFaqSection.vue' +import ModelLaunchGallerySection from './ModelLaunchGallerySection.vue' +import ModelLaunchHeroSection from './ModelLaunchHeroSection.vue' +import ModelLaunchPricingSection from './ModelLaunchPricingSection.vue' +import ModelLaunchReviewsSection from './ModelLaunchReviewsSection.vue' +import ModelLaunchRunOptionsSection from './ModelLaunchRunOptionsSection.vue' +import type { ModelLaunchPage } from './types' +import { getRoutes } from '../../config/routes' +import { t } from '../../i18n/translations' +import { faqAnswerPlainText } from '../../utils/faqAnswer' +import { absoluteUrl, faqPageNode, pageContext } from '../../utils/jsonLd' + +interface Props { + page: ModelLaunchPage +} + +const { page } = Astro.props + +const { locale, url } = pageContext( + Astro.site, + Astro.url.pathname, + Astro.currentLocale, +) +const routes = getRoutes(locale) + +const crumbs = [ + { label: t('breadcrumb.home', locale), href: routes.home }, + { label: t('models.breadcrumb.models', locale), href: routes.models }, + { label: t(page.breadcrumbLabelKey, locale) }, +] + +const breadcrumbs = crumbs.map((crumb) => + crumb.href + ? { name: crumb.label, url: absoluteUrl(Astro.site, crumb.href) } + : { name: crumb.label }, +) + +// Launch models are third party, so these pages intentionally emit no Product / +// AggregateRating / Review JSON-LD. FAQPage is the only page-specific node; +// Organization / WebSite / WebPage / BreadcrumbList come from BaseLayout. +const faqPage = page.faq + ? faqPageNode( + url, + page.faq.items.map((item) => ({ + question: item.question[locale], + answer: faqAnswerPlainText(item.answer[locale]), + })), + ) + : undefined +--- + + + + + { + page.gallery && ( + + ) + } + { + page.pricing && ( + + ) + } + { + page.faq && ( + + ) + } + { + page.closingCta && ( + + ) + } + + + diff --git a/apps/website/src/templates/model-launch/ModelLaunchPricingSection.vue b/apps/website/src/templates/model-launch/ModelLaunchPricingSection.vue new file mode 100644 index 00000000000..232526fe06c --- /dev/null +++ b/apps/website/src/templates/model-launch/ModelLaunchPricingSection.vue @@ -0,0 +1,45 @@ + + + diff --git a/apps/website/src/templates/minimax/MiniMaxReviewsSection.vue b/apps/website/src/templates/model-launch/ModelLaunchReviewsSection.vue similarity index 70% rename from apps/website/src/templates/minimax/MiniMaxReviewsSection.vue rename to apps/website/src/templates/model-launch/ModelLaunchReviewsSection.vue index 236358f1511..eccc7044f93 100644 --- a/apps/website/src/templates/minimax/MiniMaxReviewsSection.vue +++ b/apps/website/src/templates/model-launch/ModelLaunchReviewsSection.vue @@ -1,17 +1,21 @@ diff --git a/src/components/queue/QueueInlineProgressSummary.vue b/src/components/queue/QueueInlineProgressSummary.vue index 69ad77c6509..eba7ab6ddb5 100644 --- a/src/components/queue/QueueInlineProgressSummary.vue +++ b/src/components/queue/QueueInlineProgressSummary.vue @@ -34,7 +34,6 @@ import { computed } from 'vue' import { useI18n } from 'vue-i18n' -import { st } from '@/i18n' import { useQueueProgress } from '@/composables/queue/useQueueProgress' import { useExecutionStore } from '@/stores/executionStore' import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil' @@ -56,8 +55,7 @@ const { const currentNodeName = computed(() => { return resolveNodeDisplayName(executionStore.executingNode, { emptyLabel: t('g.emDash'), - untitledLabel: t('g.untitled'), - st + untitledLabel: t('g.untitled') }) }) diff --git a/src/components/rightSidePanel/RightSidePanel.vue b/src/components/rightSidePanel/RightSidePanel.vue index 8f2106819cf..21219ceb503 100644 --- a/src/components/rightSidePanel/RightSidePanel.vue +++ b/src/components/rightSidePanel/RightSidePanel.vue @@ -8,7 +8,6 @@ import Tab from '@/components/tab/Tab.vue' import TabList from '@/components/tab/TabList.vue' import Button from '@/components/ui/button/Button.vue' import { useGraphHierarchy } from '@/composables/graph/useGraphHierarchy' -import { st } from '@/i18n' import { app } from '@/scripts/app' import { getActiveGraphNodeIds } from '@/utils/graphTraversalUtil' import { SubgraphNode } from '@/lib/litegraph/src/litegraph' @@ -249,8 +248,7 @@ function resolveTitle() { const fallbackNodeTitle = t('rightSidePanel.fallbackNodeTitle') return resolveNodeDisplayName(nodes[0], { emptyLabel: fallbackNodeTitle, - untitledLabel: fallbackNodeTitle, - st + untitledLabel: fallbackNodeTitle }) } } diff --git a/src/components/rightSidePanel/errors/TabErrors.test.ts b/src/components/rightSidePanel/errors/TabErrors.test.ts index 990048f1235..197c5f9c720 100644 --- a/src/components/rightSidePanel/errors/TabErrors.test.ts +++ b/src/components/rightSidePanel/errors/TabErrors.test.ts @@ -49,6 +49,17 @@ vi.mock('@/composables/canvas/useFocusNode', () => ({ })) })) +// Its pack lookup resolves after the test file ends, and the console.warn on a +// rejection lands while the worker's rpc is closing - an unhandled error that +// fails the whole run with every test green. Mocked as the sibling suites do. +vi.mock('@/stores/comfyRegistryStore', () => ({ + useComfyRegistryStore: () => ({ + inferPackFromNodeName: vi.fn(), + // TabErrors mounts the node-pack tree, which cancels this on unmount. + getPacksByIds: { call: vi.fn().mockResolvedValue([]), cancel: vi.fn() } + }) +})) + vi.mock('@/platform/missingModel/missingModelDownload', () => ({ downloadModel: vi.fn(), fetchModelMetadata: vi.fn().mockResolvedValue({ diff --git a/src/components/rightSidePanel/errors/useErrorGroups.ts b/src/components/rightSidePanel/errors/useErrorGroups.ts index 687970ba6a5..66549b0b8a8 100644 --- a/src/components/rightSidePanel/errors/useErrorGroups.ts +++ b/src/components/rightSidePanel/errors/useErrorGroups.ts @@ -20,7 +20,6 @@ import { } from '@/utils/graphTraversalUtil' import { resolveNodeDisplayName } from '@/utils/nodeTitleUtil' import { isLGraphNode } from '@/utils/litegraphUtil' -import { st } from '@/i18n' import type { MissingNodeType } from '@/types/comfy' import type { ErrorCardData, ErrorGroup, ErrorItem } from './types' import { shouldRenderExecutionItemList } from './executionItemList' @@ -89,8 +88,7 @@ function resolveNodeInfo(nodeId: NodeExecutionId) { return { title: resolveNodeDisplayName(graphNode, { emptyLabel: '', - untitledLabel: '', - st + untitledLabel: '' }), graphNodeId: graphNode ? String(graphNode.id) : undefined } @@ -273,8 +271,7 @@ export function useErrorGroups(searchQuery: MaybeRefOrGetter) { return ( resolveNodeDisplayName(node, { emptyLabel: '', - untitledLabel: '', - st + untitledLabel: '' }) || null ) }) diff --git a/src/components/rightSidePanel/parameters/WidgetItem.vue b/src/components/rightSidePanel/parameters/WidgetItem.vue index 24e46a98a60..643edb4a858 100644 --- a/src/components/rightSidePanel/parameters/WidgetItem.vue +++ b/src/components/rightSidePanel/parameters/WidgetItem.vue @@ -5,7 +5,6 @@ import { useI18n } from 'vue-i18n' import EditableText from '@/components/common/EditableText.vue' import { getControlWidget } from '@/composables/graph/useGraphNodeManager' import { useVueNodeLifecycle } from '@/composables/graph/useVueNodeLifecycle' -import { st } from '@/i18n' import type { LGraphNode } from '@/lib/litegraph/src/litegraph' import type { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode' import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' @@ -106,8 +105,7 @@ const displayNodeName = computed((): string | null => { const fallbackNodeTitle = t('rightSidePanel.fallbackNodeTitle') return resolveNodeDisplayName(node, { emptyLabel: fallbackNodeTitle, - untitledLabel: fallbackNodeTitle, - st + untitledLabel: fallbackNodeTitle }) }) diff --git a/src/components/topbar/CurrentUserPopoverLegacy.test.ts b/src/components/topbar/CurrentUserPopoverLegacy.test.ts index d093102bbb6..4f49041454b 100644 --- a/src/components/topbar/CurrentUserPopoverLegacy.test.ts +++ b/src/components/topbar/CurrentUserPopoverLegacy.test.ts @@ -64,7 +64,7 @@ function makeSubscription( const mockFetchStatus = vi.fn().mockResolvedValue(undefined) const mockFetchBalance = vi.fn().mockResolvedValue(undefined) -const mockIsActiveSubscription = ref(true) +const mockCanAccessSubscriptionFeatures = ref(true) const mockIsFreeTier = ref(false) const mockTier = ref('CREATOR') const mockSubscription = ref(makeSubscription()) @@ -73,7 +73,7 @@ const mockIsLoading = ref(false) vi.mock('@/composables/billing/useBillingContext', () => ({ useBillingContext: vi.fn(() => ({ - isActiveSubscription: mockIsActiveSubscription, + canAccessSubscriptionFeatures: mockCanAccessSubscriptionFeatures, isFreeTier: mockIsFreeTier, tier: mockTier, subscription: mockSubscription, @@ -153,7 +153,7 @@ describe('CurrentUserPopoverLegacy', () => { beforeEach(() => { vi.clearAllMocks() mockIsCloud.value = true - mockIsActiveSubscription.value = true + mockCanAccessSubscriptionFeatures.value = true mockIsFreeTier.value = false mockTier.value = 'CREATOR' mockSubscription.value = makeSubscription() @@ -203,7 +203,7 @@ describe('CurrentUserPopoverLegacy', () => { }) it('refreshes subscription status through the billing facade after subscribing', async () => { - mockIsActiveSubscription.value = false + mockCanAccessSubscriptionFeatures.value = false const { user } = renderComponent() await user.click(screen.getByTestId('subscribe-button-mock')) @@ -478,7 +478,7 @@ describe('CurrentUserPopoverLegacy', () => { }) it('hides subscribe button', () => { - mockIsActiveSubscription.value = false + mockCanAccessSubscriptionFeatures.value = false renderComponent() expect( screen.queryByTestId('subscribe-button-mock') diff --git a/src/components/topbar/CurrentUserPopoverLegacy.vue b/src/components/topbar/CurrentUserPopoverLegacy.vue index bdbe16d7e27..bf430bd636e 100644 --- a/src/components/topbar/CurrentUserPopoverLegacy.vue +++ b/src/components/topbar/CurrentUserPopoverLegacy.vue @@ -31,7 +31,10 @@
-
+
{{ @@ -81,7 +84,7 @@
{ expect(onClick).toHaveBeenCalledTimes(1) }) - it('hides slot content, shows a spinner, and disables the button while loading', () => { + // The label stays in the accessibility tree while loading, so the control is + // still announced by name rather than as an unlabelled button. + it('swaps slot content for a spinner and disables the button while loading', () => { const { container } = render(Button, { props: { loading: true }, slots: { default: 'Submit' } }) - expect(screen.queryByText('Submit')).not.toBeInTheDocument() + const button = screen.getByRole('button', { name: 'Submit' }) + expect(button).toBeDisabled() + expect(button).toHaveAttribute('aria-busy', 'true') // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- PrimeVue spinner icon has no accessible role expect(container.querySelector('.pi-spin')).toBeInTheDocument() - expect(screen.getByRole('button')).toBeDisabled() }) it('does not fire click when loading', async () => { diff --git a/src/components/ui/button/Button.vue b/src/components/ui/button/Button.vue index bd607238739..d32be57cdad 100644 --- a/src/components/ui/button/Button.vue +++ b/src/components/ui/button/Button.vue @@ -29,9 +29,13 @@ const { :as :as-child :disabled="disabled || loading" + :aria-busy="loading || undefined" :class="cn(buttonVariants({ variant, size }), customClass)" > - - +