Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 收紧取消订阅状态与并发操作
liugaowei2e6825d74f50
diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsxindex ef6f7854f2..d6e0448f30 100644--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx@@ -87,7 +87,8 @@ const SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES: BillingSubscription['status'][] ='UNPAID','PAUSED',];-const SUBSCRIPTION_CANCELLABLE_STATUSES = SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES;+const SUBSCRIPTION_CANCELLABLE_STATUSES: BillingSubscription['status'][] =+ SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.filter((status) => status !== 'INCOMPLETE');// This list only controls which card action opens the plan-change flow. It is// intentionally separate from the new-purchase guard above: INCOMPLETE still@@ -1064,6 +1065,7 @@ function SubscriptionOverviewCard({<PendingPlanChangeBannerpending={pendingPlanChange}targetName={pendingTargetName}+ disabled={actionDisabled}onResume={onResumePending}onUndo={onCancelPending}/>@@ -1075,11 +1077,13 @@ function SubscriptionOverviewCard({function PendingPlanChangeBanner({pending,targetName,+ disabled,onResume,onUndo,}: {pending: BillingPendingPlanChange;targetName: string | null;+ disabled: boolean;onResume: () => void;onUndo: () => void;}) {@@ -1109,7 +1113,8 @@ function PendingPlanChangeBanner({<buttontype="button"onClick={onUndo}- className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)]"+ disabled={disabled}+ className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40">{t('billing.planChange.undo')}</button>@@ -1117,7 +1122,8 @@ function PendingPlanChangeBanner({<buttontype="button"onClick={onResume}- className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)]"+ disabled={disabled}+ className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40">{t('billing.planChange.resume')}</button>diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsxindex 621a9192c5..aaba4e8251 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx@@ -1366,8 +1366,8 @@ describe('BillingPage plan change', () => {expect(screen.queryByText('billing.settings.subscriptionCard.cancelAction')).toBeNull();});- it.each(['CANCELED', 'INCOMPLETE_EXPIRED'] as const)(- 'does not offer cancellation for a terminal %s subscription',+ it.each(['INCOMPLETE', 'CANCELED', 'INCOMPLETE_EXPIRED'] as const)(+ 'does not offer renewal cancellation for a %s subscription',async (status) => {const billing = billingMocks();billing.getCurrentSubscription = vi.fn(async () => ({@@ -1403,8 +1403,22 @@ describe('BillingPage plan change', () => {await act(async () => resolveConfirm(false));});- it('keeps the loading cancellation accessible and disables refresh during the request', async () => {- const billing = install(billingMocks());+ it('keeps the loading cancellation accessible and disables competing actions', async () => {+ const billing = billingMocks();+ billing.getCurrentSubscription = vi.fn(async () => ({+ subscription: activeSubscription({+ planChangeId: 'plan_change_pending',+ changeType: 'DOWNGRADE',+ status: 'SCHEDULED',+ quotedAmountMinor: null,+ quotedCurrency: null,+ quoteExpiresAt: null,+ effectiveAt: '2026-08-01T00:00:00.000Z',+ paymentAction: null,+ targetPlan: null,+ }),+ }));+ install(billing);const canceled = { ...activeSubscription(), cancelAtPeriodEnd: true };let resolveCancellation!: (subscription: BillingSubscription) => void;billing.cancelCurrentSubscription.mockReturnValueOnce(@@ -1427,6 +1441,10 @@ describe('BillingPage plan change', () => {expect(refreshButton.hasAttribute('disabled')).toBe(true);fireEvent.click(refreshButton);expect(billing.getCurrentSubscription).toHaveBeenCalledTimes(1);+ const undoButton = screen.getByText('billing.planChange.undo').closest('button')!;+ expect(undoButton.hasAttribute('disabled')).toBe(true);+ fireEvent.click(undoButton);+ expect(billing.cancelPlanChange).not.toHaveBeenCalled();await act(async () => resolveCancellation(canceled));});