Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(desktop): 供应商页 Cindy AI 按套餐状态切换余额主动作 (#3634)

Dash5eb4b0b56201
diff --git a/apps/desktop/src/main/mcp-integrations/browser-real-profile/__tests__/snapshot.test.ts b/apps/desktop/src/main/mcp-integrations/browser-real-profile/__tests__/snapshot.test.ts
index e64b4faae1..0b9deba3ce 100644
--- a/apps/desktop/src/main/mcp-integrations/browser-real-profile/__tests__/snapshot.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/browser-real-profile/__tests__/snapshot.test.ts
@@ -23,6 +23,16 @@ import { REAL_MANAGED_PROFILE } from '../../browser-managed-config.js';
import { REAL_PROFILE_READ_DENIED } from '../../../../shared/browserBackend.js';
import { RealProfileError, type InstalledChromium } from '../types.js';
+describe('node:sqlite main-process packaging', () => {
+ it('keeps node:sqlite external so Vite does not stub it as a browser module', () => {
+ const viteConfig = fs.readFileSync(
+ path.resolve(__dirname, '..', '..', '..', '..', '..', 'vite.main.config.ts'),
+ 'utf8',
+ );
+ expect(viteConfig).toContain("'node:sqlite'");
+ });
+});
+
const tempDirs: string[] = [];
function makeTempDir(): string {
diff --git a/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx b/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx
index 1083fdf7df..02e9f8ac0c 100644
--- a/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/providersSectionAssetModule.test.tsx
@@ -2,8 +2,9 @@
/**
* ProvidersSection — Cindy AI 卡片的「账户资产模块」不变量:
- * 1. 个人云账号 + 拿到余额 → 标题行下方出现「可用余额 + 金额 + 查看用量 + 余额充值」,
- * 两个动作分别深链到计费页与计费页的充值意图。
+ * 1. 个人云账号 + 拿到余额 → 标题行下方出现「可用余额 + 金额 + 查看用量」;右侧一颗
+ * Black Pill 按套餐状态切换:非套餐购买套餐、还能升就升级、升满后才余额充值。
+ * 查看用量始终在。
* 2. 企业账号 → 整块不渲染(不是灰置、不给占位)。
* 3. 凭据同步失败 → 故障说明 + 重试,且**不显示「已连接」**(凭据没同步上,说已连接是假的)。
* 4. 正常态版面上不出现「重试 / 重新获取凭据 / 轮换密钥」这类按钮 —— 它们退进「···」菜单。
@@ -16,23 +17,32 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { ProviderView } from '@cindy/model-providers';
-const { providersState, authState, creditUsageState, modelAccessState, apiKeyState } = vi.hoisted(
- () => ({
- providersState: { providers: [] as unknown[], order: [] as string[] },
- authState: {
- mode: 'cloud' as 'cloud' | 'local' | 'signed-out',
- user: { membershipKind: 'personal' } as { membershipKind: 'personal' | 'org' } | null,
- dataOwnerId: 'account-1' as string | null,
- },
- creditUsageState: { available: null as string | null },
- modelAccessState: {
- state: 'ok' as 'ok' | 'failed' | 'unsupported' | 'idle' | 'syncing' | 'disabled',
- source: 'server' as string | null,
- accountTier: null as 'free' | 'paid' | 'not_applicable' | null,
- },
- apiKeyState: { key: 'sk-live-abcd1234ef2a', hasSavedKey: true },
- }),
-);
+const {
+ providersState,
+ authState,
+ creditUsageState,
+ modelAccessState,
+ apiKeyState,
+ primaryActionState,
+} = vi.hoisted(() => ({
+ providersState: { providers: [] as unknown[], order: [] as string[] },
+ authState: {
+ mode: 'cloud' as 'cloud' | 'local' | 'signed-out',
+ user: { membershipKind: 'personal' } as { membershipKind: 'personal' | 'org' } | null,
+ dataOwnerId: 'account-1' as string | null,
+ },
+ creditUsageState: { available: null as string | null },
+ modelAccessState: {
+ state: 'ok' as 'ok' | 'failed' | 'unsupported' | 'idle' | 'syncing' | 'disabled',
+ source: 'server' as string | null,
+ accountTier: null as 'free' | 'paid' | 'not_applicable' | null,
+ },
+ apiKeyState: { key: 'sk-live-abcd1234ef2a', hasSavedKey: true },
+ primaryActionState: {
+ value: 'buy-plan' as 'buy-plan' | 'upgrade-plan' | 'topup' | null,
+ lastEnabled: false,
+ },
+}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
@@ -62,6 +72,13 @@ vi.mock('@/hooks/useModelAccessCreditUsage', () => ({
: null,
}));
+vi.mock('@/hooks/useXdAssetPrimaryAction', () => ({
+ useXdAssetPrimaryAction: (enabled: boolean) => {
+ primaryActionState.lastEnabled = enabled;
+ return enabled ? primaryActionState.value : null;
+ },
+}));
+
vi.mock('@/hooks/useModelAccessStatus', () => ({
useModelAccessStatus: () => ({ ...modelAccessState, endpoint: null }),
}));
@@ -188,6 +205,8 @@ beforeEach(() => {
modelAccessState.source = 'server';
modelAccessState.accountTier = null;
apiKeyState.hasSavedKey = true;
+ primaryActionState.value = 'buy-plan';
+ primaryActionState.lastEnabled = false;
(window as unknown as { electronAPI: unknown }).electronAPI = {
maker: {
scanLocalCli: vi.fn(async () => ({ detections: [] })),
@@ -215,9 +234,7 @@ describe('ProvidersSection — Cindy AI 账户资产模块', () => {
expect(badge.textContent).toBe('settings.providers.xd.accountTier.free');
const assetModule = screen.getByTestId('cindy-ai-asset-module');
expect(assetModule.contains(badge)).toBe(false);
- expect(badge.previousElementSibling?.textContent).toBe(
- 'settings.providers.models.modelCount',
- );
+ expect(badge.previousElementSibling?.textContent).toBe('settings.providers.models.modelCount');
expect(screen.getByTestId('provider-detail-metadata').contains(badge)).toBe(true);
cleanup();
@@ -233,37 +250,78 @@ describe('ProvidersSection — Cindy AI 账户资产模块', () => {
expect(screen.queryByTestId('cindy-ai-free-tier-badge')).toBeNull();
});
- it('个人云账号:显示可用余额 + 两个动作,并深链到计费页 / 充值意图', async () => {
+ it('非套餐用户:查看用量始终在,右边购买套餐,不显示充值', async () => {
renderSection();
expect(await screen.findByText('billing.balance.title')).toBeTruthy();
- // 金额走 money.ts 的格式化 + BILLING_CURRENCY,不在这里自己拼字符串。
expect(screen.getByText('cny:18.42')).toBeTruthy();
+ expect(primaryActionState.lastEnabled).toBe(true);
fireEvent.click(screen.getByText('settings.providers.xd.asset.viewUsage'));
await waitFor(() =>
expect(screen.getByTestId('search').textContent).toBe('/settings?tab=billing'),
);
- fireEvent.click(screen.getByText('billing.settings.topupCard.action'));
+ fireEvent.click(screen.getByText('settings.providers.xd.asset.buyPlan'));
await waitFor(() =>
- expect(screen.getByTestId('search').textContent).toBe('/settings?tab=billing&intent=topup'),
+ expect(screen.getByTestId('search').textContent).toBe(
+ '/settings?tab=billing&intent=subscribe',
+ ),
);
- // Black Pill(最高强调档)必须用 pure 对(DESIGN.md §4 button/cta):
- // --accent-cta-bg-pure + --accent-pure-cta-fg;--accent-cta-bg 在默认 Light
- // 下是 #262626,差一档,回归防再犯。
- const topupButton = screen.getByText('billing.settings.topupCard.action').closest('button');
- expect(topupButton?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');
- expect(topupButton?.style.color).toBe('var(--accent-pure-cta-fg)');
+ const buyPlan = screen.getByText('settings.providers.xd.asset.buyPlan').closest('button');
+ expect(buyPlan?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');
+ expect(buyPlan?.style.color).toBe('var(--accent-pure-cta-fg)');
const usageButton = screen.getByText('settings.providers.xd.asset.viewUsage').closest('button');
expect(usageButton?.style.backgroundColor).toBe('var(--settings-btn-secondary-bg)');
expect(usageButton?.style.color).toBe('var(--settings-btn-secondary-text)');
+ expect(screen.queryByText('billing.settings.topupCard.action')).toBeNull();
+ expect(screen.queryByText('settings.providers.xd.asset.upgradePlan')).toBeNull();
const assetModule = screen.getByTestId('cindy-ai-asset-module');
expect(assetModule.children).toHaveLength(2);
});
+ it('有套餐还能升级:查看用量始终在,右边升级套餐,不显示充值', async () => {
+ primaryActionState.value = 'upgrade-plan';
+ renderSection();
+
+ expect(await screen.findByText('settings.providers.xd.asset.viewUsage')).toBeTruthy();
+ expect(screen.getByText('settings.providers.xd.asset.upgradePlan')).toBeTruthy();
+ expect(screen.queryByText('settings.providers.xd.asset.buyPlan')).toBeNull();
+ expect(screen.queryByText('billing.settings.topupCard.action')).toBeNull();
+
+ const upgrade = screen.getByText('settings.providers.xd.asset.upgradePlan').closest('button');
+ expect(upgrade?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');
+ expect(upgrade?.style.color).toBe('var(--accent-pure-cta-fg)');
+
+ fireEvent.click(screen.getByText('settings.providers.xd.asset.upgradePlan'));
+ await waitFor(() =>
+ expect(screen.getByTestId('search').textContent).toBe(
+ '/settings?tab=billing&intent=plan-change',
+ ),
+ );
+ });
+
+ it('升满以后:查看用量始终在,右边才是余额充值', async () => {
+ primaryActionState.value = 'topup';
+ renderSection();
+
+ expect(await screen.findByText('settings.providers.xd.asset.viewUsage')).toBeTruthy();
+ expect(screen.getByText('billing.settings.topupCard.action')).toBeTruthy();
+ expect(screen.queryByText('settings.providers.xd.asset.buyPlan')).toBeNull();
+ expect(screen.queryByText('settings.providers.xd.asset.upgradePlan')).toBeNull();
+
+ const topup = screen.getByText('billing.settings.topupCard.action').closest('button');
+ expect(topup?.style.backgroundColor).toBe('var(--accent-cta-bg-pure)');
+ expect(topup?.style.color).toBe('var(--accent-pure-cta-fg)');
+
+ fireEvent.click(screen.getByText('billing.settings.topupCard.action'));
+ await waitFor(() =>
+ expect(screen.getByTestId('search').textContent).toBe('/settings?tab=billing&intent=topup'),
+ );
+ });
+
it('正常态版面上没有重试 / 轮换 / 重新获取凭据按钮(它们退进「···」菜单)', async () => {
renderSection();
diff --git a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
index daa453bd60..509438469f 100644
--- a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx
@@ -41,6 +41,7 @@ import { useApiKey } from '@/hooks/useApiKey';
import { extractIpcError } from '@/utils/ipcError';
import { useModelAccessStatus } from '@/hooks/useModelAccessStatus';
import { useModelAccessCreditUsage } from '@/hooks/useModelAccessCreditUsage';
+import { useXdAssetPrimaryAction } from '@/hooks/useXdAssetPrimaryAction';
import { useReducedMotion } from '@/hooks/useReducedMotion';
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { useSignInToCindy } from '@/hooks/useSignInToCindy';
@@ -854,18 +855,19 @@ function XaiAssetModule({ connected }: { connected: boolean }) {
{t('settings.providers.xai.asset.resetsAt', { at: resetLabel })}
</p>
)}
- {hasWeekly && (usage.productUsage ?? []).map((product) => (
- <p
- key={product.product}
- className="mt-1 text-12 leading-tight tabular-nums"
- style={{ color: 'var(--text-secondary)' }}
- >
- {t('settings.providers.xai.asset.productLine', {
- product: formatXaiProductLabel(product.product),
- percent: Math.round(product.usagePercent),
- })}
- </p>
- ))}
+ {hasWeekly &&
+ (usage.productUsage ?? []).map((product) => (
+ <p
+ key={product.product}
+ className="mt-1 text-12 leading-tight tabular-nums"
+ style={{ color: 'var(--text-secondary)' }}
+ >
+ {t('settings.providers.xai.asset.productLine', {
+ product: formatXaiProductLabel(product.product),
+ percent: Math.round(product.usagePercent),
+ })}
+ </p>
+ ))}
</div>
<div className="flex shrink-0 items-center pt-3.5">
<button
@@ -1211,7 +1213,8 @@ function BuiltinApiKeyHeader({
// 脱敏 key / 轮换 / 重新获取这三件用户几乎不碰的事,而给「我还剩多少钱、去哪充」:
// - 标题行右端只留一个「···」溢出菜单(与所有供应商共用 DetailHeader 那一个),
// 凭证管理三项 + 只读脱敏 key 收在里面,各自保留原有的二次确认;
-// - 标题行下方是账户资产模块(1px 发丝线分隔):可用余额 + 查看用量 + 余额充值;
+// - 标题行下方是账户资产模块(1px 发丝线分隔):可用余额 + 查看用量始终在;
+// 右侧一颗 Black Pill 按套餐状态切换购买 / 升级 / 充值(升满后才充值);
// - 故障恢复(重试)只在凭据同步失败时浮现,正常态版面上没有重试按钮。
// ---------------------------------------------------------------------------
@@ -1251,6 +1254,7 @@ function XdGatewayHeader({
syncState: syncStatus.state,
available: creditUsage?.available ?? null,
});
+ const primaryAction = useXdAssetPrimaryAction(assetState.kind === 'balance');
// 凭据一律由服务端自动下发(个人 / 已接入企业),**无手填入口**(2026-07-17 定案)。
const serverManaged = syncStatus.state === 'ok' && syncStatus.source === 'server';
@@ -1317,8 +1321,8 @@ function XdGatewayHeader({
}, [hasSavedKey, key, t]);
const goToBilling = useCallback(
- (intent?: 'topup') => {
- navigate(intent ? '/settings?tab=billing&intent=topup' : '/settings?tab=billing');
+ (intent?: 'topup' | 'subscribe' | 'plan-change') => {
+ navigate(intent ? `/settings?tab=billing&intent=${intent}` : '/settings?tab=billing');
},
[navigate],
);
@@ -1433,16 +1437,28 @@ function XdGatewayHeader({
)}
</p>
</div>
- {/* 余额充值是主动作;查看用量为同区块内的次动作。 */}
+ {/* 一屏一颗 Black Pill。查看用量始终是次动作;右侧按套餐状态切换。 */}
<div className="flex shrink-0 items-center gap-3">
<PillButton
label={t('settings.providers.xd.asset.viewUsage')}
onClick={() => goToBilling()}
/>
- <CtaPillButton
- label={t('billing.settings.topupCard.action')}
- onClick={() => goToBilling('topup')}
- />
+ {primaryAction === 'buy-plan' ? (
+ <CtaPillButton
+ label={t('settings.providers.xd.asset.buyPlan')}
+ onClick={() => goToBilling('subscribe')}
+ />
+ ) : primaryAction === 'upgrade-plan' ? (
+ <CtaPillButton
+ label={t('settings.providers.xd.asset.upgradePlan')}
+ onClick={() => goToBilling('plan-change')}
+ />
+ ) : primaryAction === 'topup' ? (
+ <CtaPillButton
+ label={t('billing.settings.topupCard.action')}
+ onClick={() => goToBilling('topup')}
+ />
+ ) : null}
</div>
</>
)}
@@ -2640,9 +2656,9 @@ export function ProvidersSection() {
)}
</div>
)}
- {effectiveSelected.id === MANAGED_OLLAMA_PROVIDER_ID && (
- <OllamaProviderDetail onChanged={refetch} />
- )}
+ {effectiveSelected.id === MANAGED_OLLAMA_PROVIDER_ID && (
+ <OllamaProviderDetail onChanged={refetch} />
+ )}
</>
</>
) : (
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/providerAssetModule.test.ts b/apps/desktop/src/renderer/components/settings/__tests__/providerAssetModule.test.ts
index aa92f2c128..50c29913dc 100644
--- a/apps/desktop/src/renderer/components/settings/__tests__/providerAssetModule.test.ts
+++ b/apps/desktop/src/renderer/components/settings/__tests__/providerAssetModule.test.ts
@@ -1,6 +1,13 @@
import { describe, expect, it } from 'vitest';
-import { resolveXdAssetModuleState } from '../providerAssetModule';
+import type { BillingCatalog, BillingSubscription } from '../../../../shared/billing';
+import {
+ canUpgradeBillingPlan,
+ hasBlockingBillingSubscription,
+ isBillingPlanChangeEligible,
+ resolveXdAssetActionLayout,
+ resolveXdAssetModuleState,
+} from '../providerAssetModule';
const OK = {
billingAccessible: true,
@@ -52,3 +59,284 @@ describe('resolveXdAssetModuleState', () => {
});
});
});
+
+describe('hasBlockingBillingSubscription', () => {
+ function sub(status: BillingSubscription['status']): BillingSubscription {
+ return { status } as BillingSubscription;
+ }
+
+ it('TRIALING / ACTIVE / PAST_DUE / UNPAID / PAUSED 视为已有生效订阅', () => {
+ expect(hasBlockingBillingSubscription(sub('TRIALING'))).toBe(true);
+ expect(hasBlockingBillingSubscription(sub('ACTIVE'))).toBe(true);
+ expect(hasBlockingBillingSubscription(sub('PAST_DUE'))).toBe(true);
+ expect(hasBlockingBillingSubscription(sub('UNPAID'))).toBe(true);
+ expect(hasBlockingBillingSubscription(sub('PAUSED'))).toBe(true);
+ });
+
+ it('未完成首购、已取消、空值都不阻断', () => {
+ expect(hasBlockingBillingSubscription(null)).toBe(false);
+ expect(hasBlockingBillingSubscription(undefined)).toBe(false);
+ expect(hasBlockingBillingSubscription(sub('INCOMPLETE'))).toBe(false);
+ expect(hasBlockingBillingSubscription(sub('INCOMPLETE_EXPIRED'))).toBe(false);
+ expect(hasBlockingBillingSubscription(sub('CANCELED'))).toBe(false);
+ });
+});
+
+const plusMonth: BillingSubscription = {
+ subscriptionId: 'sub_1',
+ status: 'ACTIVE',
+ provider: 'stripe',
+ currentPeriodStartAt: null,
+ currentPeriodEndAt: null,
+ entitlementValidUntil: null,
+ cancelAtPeriodEnd: false,
+ effectivePlan: {
+ version: 1,
+ product: { code: 'plus', kind: 'SUBSCRIPTION', level: 1 },
+ offer: { code: 'plus_month', interval: 'MONTH' },
+ terms: { amount: '9', currency: 'usd', creditAmount: '100', rolloverCap: '0' },
+ capturedAt: '2026-01-01T00:00:00.000Z',
+ },
+ purchaseAttemptId: null,
+ paymentAction: null,
+};
+
+function monthOffer(code: string, provider = 'stripe') {
+ return {
+ code,
+ interval: 'MONTH' as const,
+ currency: 'usd',
+ amount: '20',
+ minAmount: null,
+ maxAmount: null,
+ creditAmount: '250',
+ rolloverCap: '0',
+ purchaseOptions: [
+ {
+ id: `listing_${code}`,
+ provider,
+ capability: 'PROVIDER_MANAGED_SUBSCRIPTION' as const,
+ paymentAction: 'REDIRECT' as const,
+ },
+ ],
+ };
+}
+
+const plusAndMaxCatalog: BillingCatalog = {
+ products: [
+ {
+ code: 'plus',
+ name: 'Plus',
+ kind: 'SUBSCRIPTION',
+ level: 1,
+ sortOrder: 1,
+ offers: [monthOffer('plus_month')],
+ },
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [monthOffer('max_month')],
+ },
+ ],
+};
+
+const maxOnlyCatalog: BillingCatalog = {
+ products: [
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [monthOffer('max_month')],
+ },
+ ],
+};
+
+describe('canUpgradeBillingPlan', () => {
+ it('非套餐或未完成首购 → 不能升级', () => {
+ expect(canUpgradeBillingPlan(null, plusAndMaxCatalog)).toBe(false);
+ expect(canUpgradeBillingPlan({ ...plusMonth, status: 'INCOMPLETE' }, plusAndMaxCatalog)).toBe(
+ false,
+ );
+ });
+
+ it('ACTIVE 月付且目录有更高等级可购档 → 可升级', () => {
+ expect(canUpgradeBillingPlan(plusMonth, plusAndMaxCatalog)).toBe(true);
+ });
+
+ it('已经是最高档 → 升满,不能再升级', () => {
+ const maxed: BillingSubscription = {
+ ...plusMonth,
+ effectivePlan: plusMonth.effectivePlan && {
+ ...plusMonth.effectivePlan,
+ product: { ...plusMonth.effectivePlan.product, code: 'max', level: 2 },
+ offer: { ...plusMonth.effectivePlan.offer, code: 'max_month' },
+ },
+ };
+ expect(canUpgradeBillingPlan(maxed, plusAndMaxCatalog)).toBe(false);
+ expect(canUpgradeBillingPlan(maxed, maxOnlyCatalog)).toBe(false);
+ });
+
+ it('年付 / 取消待到期 / 非 ACTIVE 不能走更改套餐', () => {
+ expect(
+ canUpgradeBillingPlan(
+ {
+ ...plusMonth,
+ effectivePlan: plusMonth.effectivePlan && {
+ ...plusMonth.effectivePlan,
+ offer: { ...plusMonth.effectivePlan.offer, interval: 'YEAR' },
+ },
+ },
+ plusAndMaxCatalog,
+ ),
+ ).toBe(false);
+ expect(
+ canUpgradeBillingPlan({ ...plusMonth, cancelAtPeriodEnd: true }, plusAndMaxCatalog),
+ ).toBe(false);
+ expect(canUpgradeBillingPlan({ ...plusMonth, status: 'PAST_DUE' }, plusAndMaxCatalog)).toBe(
+ false,
+ );
+ });
+
+ it('目录还没回来且符合更改套餐入口 → 未知,不提前判死', () => {
+ expect(canUpgradeBillingPlan(plusMonth, null)).toBe(null);
+ expect(isBillingPlanChangeEligible(plusMonth)).toBe(true);
+ });
+
+ it('更高档不可购买时不算能升级', () => {
+ const comingSoon: BillingCatalog = {
+ products: [
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [
+ {
+ ...monthOffer('max_month'),
+ salesState: 'COMING_SOON',
+ purchasable: false,
+ unavailableReason: 'OFFER_COMING_SOON',
+ },
+ ],
+ },
+ ],
+ };
+ expect(canUpgradeBillingPlan(plusMonth, comingSoon)).toBe(false);
+ });
+
+ it('更高档只有桌面接不住的渠道时不算能升级', () => {
+ const unknownProvider: BillingCatalog = {
+ products: [
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [monthOffer('max_month', 'futurepay')],
+ },
+ ],
+ };
+ expect(canUpgradeBillingPlan(plusMonth, unknownProvider)).toBe(false);
+ });
+
+ it('更高档只有一次性支付能力时不算能升级', () => {
+ const oneTimeOnly: BillingCatalog = {
+ products: [
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [
+ {
+ ...monthOffer('max_month'),
+ purchaseOptions: [
+ {
+ id: 'listing_max_month',
+ provider: 'stripe',
+ capability: 'ONE_TIME_PAYMENT',
+ paymentAction: 'REDIRECT',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ expect(canUpgradeBillingPlan(plusMonth, oneTimeOnly)).toBe(false);
+ });
+
+ it('更高档同时有接得住和接不住的选项时仍可升级', () => {
+ const mixed: BillingCatalog = {
+ products: [
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [
+ {
+ ...monthOffer('max_month'),
+ purchaseOptions: [
+ {
+ id: 'listing_max_future',
+ provider: 'futurepay',
+ capability: 'PROVIDER_MANAGED_SUBSCRIPTION',
+ paymentAction: 'REDIRECT',
+ },
+ {
+ id: 'listing_max_month',
+ provider: 'stripe',
+ capability: 'PROVIDER_MANAGED_SUBSCRIPTION',
+ paymentAction: 'REDIRECT',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ expect(canUpgradeBillingPlan(plusMonth, mixed)).toBe(true);
+ });
+});
+
+describe('resolveXdAssetActionLayout', () => {
+ it('订阅还没回来 → 先不画右侧主动作', () => {
+ expect(resolveXdAssetActionLayout({ hasBlockingSubscription: null, canUpgrade: null })).toEqual(
+ { primary: null },
+ );
+ });
+
+ it('非套餐 → 购买套餐,不看目录', () => {
+ expect(
+ resolveXdAssetActionLayout({ hasBlockingSubscription: false, canUpgrade: true }),
+ ).toEqual({ primary: 'buy-plan' });
+ });
+
+ it('有套餐且还能升级 → 升级套餐', () => {
+ expect(resolveXdAssetActionLayout({ hasBlockingSubscription: true, canUpgrade: true })).toEqual(
+ { primary: 'upgrade-plan' },
+ );
+ });
+
+ it('升满或无法改档 → 余额充值', () => {
+ expect(
+ resolveXdAssetActionLayout({ hasBlockingSubscription: true, canUpgrade: false }),
+ ).toEqual({ primary: 'topup' });
+ });
+
+ it('有套餐但升级资格还未知 → 先不画右侧主动作', () => {
+ expect(resolveXdAssetActionLayout({ hasBlockingSubscription: true, canUpgrade: null })).toEqual(
+ { primary: null },
+ );
+ });
+});
diff --git a/apps/desktop/src/renderer/components/settings/providerAssetModule.ts b/apps/desktop/src/renderer/components/settings/providerAssetModule.ts
index 588ab08e19..de765d3c55 100644
--- a/apps/desktop/src/renderer/components/settings/providerAssetModule.ts
+++ b/apps/desktop/src/renderer/components/settings/providerAssetModule.ts
@@ -1,7 +1,7 @@
/**
* 供应商详情头下方「账户资产模块」的状态判定(纯函数,与渲染分离)。
*
- * 这个槽位是通用的:网关账号填「可用余额 + 充值」,将来订阅账号可以填「当前套餐 +
+ * 这个槽位是通用的:网关账号填「可用余额 + 动作」,将来订阅账号可以填「当前套餐 +
* 用量」。目前只有 Cindy AI 网关一种填充,判定逻辑先集中在这里,避免把三种互斥
* 状态(不渲染 / 故障 / 有余额)散进 JSX 的嵌套三元里。
*
@@ -15,9 +15,19 @@
* 「不渲染」与「故障」的分野是这份判定存在的理由:把两者合成一个空态会让确实有钱
* 的用户看不到恢复入口,把两者都给重试又会让 org 账号看到一个永远重试不出结果的
* 按钮。
+ *
+ * 余额块的动作布局另走 `resolveXdAssetActionLayout`:查看用量始终在;右侧只留一颗
+ * Black Pill —— 非套餐买套餐,还能升就升级,已经升满(或没法改套餐)才轮到余额充值。
*/
+import { BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES } from '../../../shared/billing';
+import type {
+ BillingCatalog,
+ BillingCatalogOffer,
+ BillingSubscription,
+} from '../../../shared/billing';
import type { ModelAccessStatus } from '../../../shared/modelAccess';
+import { isSupportedPurchaseOption } from '../../features/billing/purchaseSupport';
export type ProviderAssetModuleState =
{ kind: 'hidden' } | { kind: 'fault' } | { kind: 'balance'; available: string };
@@ -31,6 +41,94 @@ export interface XdAssetModuleInput {
available: string | null;
}
+export function hasBlockingBillingSubscription(
+ subscription: BillingSubscription | null | undefined,
+): boolean {
+ return (
+ subscription != null &&
+ BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(subscription.status)
+ );
+}
+
+export type XdAssetPrimaryAction = 'buy-plan' | 'upgrade-plan' | 'topup';
+
+export type XdAssetActionLayout = { primary: XdAssetPrimaryAction | null };
+
+/**
+ * 计费页「更改套餐」入口同一组门槛:ACTIVE、未取消待到期、月付。年付 / 非 ACTIVE /
+ * 取消待到期都无法在客户端改档,右侧改走余额充值。
+ */
+export function isBillingPlanChangeEligible(
+ subscription: BillingSubscription | null | undefined,
+): boolean {
+ return (
+ subscription != null &&
+ subscription.status === 'ACTIVE' &&
+ !subscription.cancelAtPeriodEnd &&
+ subscription.effectivePlan?.offer.interval === 'MONTH' &&
+ typeof subscription.provider === 'string' &&
+ subscription.provider.length > 0
+ );
+}
+
+function catalogOfferPurchasable(offer: BillingCatalogOffer): boolean {
+ const projected =
+ offer.salesState !== undefined &&
+ offer.purchasable !== undefined &&
+ offer.unavailableReason !== undefined;
+ if (!projected) return offer.purchaseOptions.length > 0;
+ return offer.purchasable === true && offer.purchaseOptions.length > 0;
+}
+
+/**
+ * 当前套餐在目录里是否还有更高等级、同周期、同渠道、可购买的订阅档。
+ * `catalog === null` 表示还没拿到目录:符合更改套餐入口时返回 `null`(未知),
+ * 否则可以直接否定。
+ */
+export function canUpgradeBillingPlan(
+ subscription: BillingSubscription | null | undefined,
+ catalog: BillingCatalog | null,
+): boolean | null {
+ if (!hasBlockingBillingSubscription(subscription) || !subscription?.effectivePlan) {
+ return false;
+ }
+ if (!isBillingPlanChangeEligible(subscription)) return false;
+ if (catalog == null) return null;
+
+ const current = subscription.effectivePlan;
+ const provider = subscription.provider;
+ if (!provider) return false;
+
+ return catalog.products.some((product) => {
+ if (product.kind !== 'SUBSCRIPTION') return false;
+ if (product.level == null || product.level <= current.product.level) return false;
+ return product.offers.some((offer) => {
+ if (offer.interval !== current.offer.interval) return false;
+ if (offer.code === current.offer.code) return false;
+ if (!catalogOfferPurchasable(offer)) return false;
+ return offer.purchaseOptions.some(
+ (option) =>
+ option.provider === provider && isSupportedPurchaseOption(option, 'SUBSCRIPTION'),
+ );
+ });
+ });
+}
+
+/**
+ * 右侧主动作决议。订阅还没回来时不猜(`primary: null`),避免已订用户闪一下「购买套餐」。
+ * 确认没有生效订阅 → 购买;确认还能升级 → 升级;确认升满或无法改档 → 充值。
+ */
+export function resolveXdAssetActionLayout(input: {
+ hasBlockingSubscription: boolean | null;
+ canUpgrade: boolean | null;
+}): XdAssetActionLayout {
+ if (input.hasBlockingSubscription == null) return { primary: null };
+ if (!input.hasBlockingSubscription) return { primary: 'buy-plan' };
+ if (input.canUpgrade === true) return { primary: 'upgrade-plan' };
+ if (input.canUpgrade === false) return { primary: 'topup' };
+ return { primary: null };
+}
+
export function resolveXdAssetModuleState(input: XdAssetModuleInput): ProviderAssetModuleState {
const { billingAccessible, syncState, available } = input;
// 企业账号 / 未登录 / local:整个余额与充值面都不属于这个账号,连故障态都不该有。
diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsx
index 2ebb1581be..bacfbb2584 100644
--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx
+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx
@@ -30,15 +30,15 @@ import { Spinner } from '@/components/ui/spinner';
import { useAuth } from '@/contexts/AuthContext';
import { cn } from '@/lib/utils';
import { extractIpcError } from '@/utils/ipcError';
-import type {
- BillingCatalog,
- BillingCatalogOffer,
- BillingCatalogOfferUnavailableReason,
- BillingCatalogProduct,
- BillingPaymentOrder,
- BillingPendingPlanChange,
- BillingPurchaseOption,
- BillingSubscription,
+import {
+ BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES,
+ type BillingCatalog,
+ type BillingCatalogOffer,
+ type BillingCatalogOfferUnavailableReason,
+ type BillingCatalogProduct,
+ type BillingPaymentOrder,
+ type BillingPendingPlanChange,
+ type BillingSubscription,
} from '../../../shared/billing';
import type {
ModelAccessBalance,
@@ -48,6 +48,12 @@ import type {
} from '../../../shared/modelAccess';
import { AlipayIcon } from './AlipayIcon';
import { billingApi } from './api';
+import {
+ isSupportedBillingProvider,
+ isSupportedPurchaseOption,
+ type SupportedBillingProvider,
+ type SupportedPurchaseOption,
+} from './purchaseSupport';
import { BillingCheckoutDialog } from './BillingCheckoutDialog';
import { BILLING_CURRENCY, formatBillingAmount as formatMoney } from './money';
import {
@@ -70,11 +76,6 @@ type SubscriptionProductEntry = {
defaultOffer: CatalogOfferEntry;
};
-type SupportedBillingProvider = 'alipay' | 'stripe';
-type SupportedPurchaseOption = BillingPurchaseOption & {
- provider: SupportedBillingProvider;
-};
-
type PurchaseKind = BillingCatalogProduct['kind'];
type BalanceIssue = 'NOT_PROVISIONED' | 'NOT_SUPPORTED' | 'UNAVAILABLE' | null;
type CurrentPlanFacts = {
@@ -88,25 +89,8 @@ type CurrentPlanFacts = {
resumable: boolean;
};
-const SUPPORTED_BILLING_PROVIDERS = new Set<SupportedBillingProvider>(['alipay', 'stripe']);
-const SUPPORTED_PAYMENT_ACTIONS = new Set<BillingPurchaseOption['paymentAction']>([
- 'QR_CODE',
- 'REDIRECT',
-]);
-const SUPPORTED_SUBSCRIPTION_CAPABILITIES = new Set<BillingPurchaseOption['capability']>([
- 'MERCHANT_INITIATED_MANDATE',
- 'PROVIDER_MANAGED_SUBSCRIPTION',
-]);
-
// 未完成首购只属于当前 checkout 会话,不能展示为当前套餐或阻断重新购买。
-const SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES: BillingSubscription['status'][] = [
- 'TRIALING',
- 'ACTIVE',
- 'PAST_DUE',
- 'UNPAID',
- 'PAUSED',
-];
-const SUBSCRIPTION_CANCELLABLE_STATUSES = SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES;
+const SUBSCRIPTION_CANCELLABLE_STATUSES = BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES;
const PLAN_CHANGE_ENTRY_STATUSES: BillingSubscription['status'][] = ['ACTIVE'];
@@ -267,17 +251,6 @@ function catalogOfferUnavailableReason(
return entry.offer.unavailableReason ?? 'NO_AVAILABLE_PAYMENT_CHANNEL';
}
-function isSupportedPurchaseOption(
- option: BillingPurchaseOption,
- productKind: BillingCatalogProduct['kind'],
-): option is SupportedPurchaseOption {
- if (!SUPPORTED_BILLING_PROVIDERS.has(option.provider as SupportedBillingProvider)) return false;
- if (!SUPPORTED_PAYMENT_ACTIONS.has(option.paymentAction)) return false;
- return productKind === 'CREDIT_TOPUP'
- ? option.capability === 'ONE_TIME_PAYMENT'
- : SUPPORTED_SUBSCRIPTION_CAPABILITIES.has(option.capability);
-}
-
function currencyFractionDigits(currency: string): number {
try {
return (
@@ -373,11 +346,13 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
}, [resetSelection]);
/**
- * 深链 `?tab=billing&intent=topup` —— 别处(供应商设置页的账户资产模块)想触发
- * 充值时唯一的入口。充值弹窗依赖本 section 的目录 / 选项 / checkout 会话状态,
- * 跨 feature 直接复用会把这一大摊状态拉到调用方,所以外部只投递意图、由这里
- * 打开弹窗。消费即从 URL 摘除(replace,防返回/刷新重复弹窗),与
- * ProvidersSection 的 `?connect` 同款契约。
+ * 深链 `?tab=billing&intent=topup|subscribe|plan-change` —— 供应商设置页账户资产
+ * 模块的入口。弹窗依赖本 section 的目录 / 订阅 / checkout 状态,跨 feature 只投递
+ * 意图。消费即从 URL 摘除(replace,防返回/刷新重复弹窗),与 ProvidersSection 的
+ * `?connect` 同款契约。
+ *
+ * topup 立即打开:充值弹窗自己会等目录。subscribe / plan-change 等目录和订阅都回来
+ * 再开,避免先弹出可购买再变成 blocked,或 plan-change 入口还没算出来就空弹。
*/
const [searchParams, setSearchParams] = useSearchParams();
useEffect(() => {
@@ -431,13 +406,14 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
try {
const subscription = (await billingApi.getCurrentSubscription()).subscription;
setCurrentSubscription(
- subscription && SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(subscription.status)
+ subscription &&
+ BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(subscription.status)
? subscription
: null,
);
} catch {
const completedFallback =
- fallback && SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(fallback.status)
+ fallback && BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(fallback.status)
? fallback
: null;
setCurrentSubscription(completedFallback);
@@ -484,10 +460,7 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
// state and the XD catalog are separate snapshots, so returning to Cindy must refresh
// both explicitly; the app-wide focus refresh is throttled and cannot provide this
// entitlement boundary.
- void Promise.allSettled([
- loadBillingState(),
- refreshXdModelsAfterEntitlementChange(),
- ]);
+ void Promise.allSettled([loadBillingState(), refreshXdModelsAfterEntitlementChange()]);
};
const onVisible = () => {
if (document.visibilityState === 'visible') refreshAfterPortal();
@@ -590,7 +563,7 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
const subscriptionPurchaseBlocked =
currentSubscription !== null &&
- SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(currentSubscription.status);
+ BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES.includes(currentSubscription.status);
const currentSubscriptionOfferCode = subscriptionPurchaseBlocked
? (currentSubscription.effectivePlan?.offer.code ?? null)
: null;
@@ -717,11 +690,10 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
const currentPlan = currentSubscription?.effectivePlan ?? null;
const pendingPlanChange = currentSubscription?.pendingPlanChange ?? null;
- const currentProvider =
- currentSubscription?.provider &&
- SUPPORTED_BILLING_PROVIDERS.has(currentSubscription.provider as SupportedBillingProvider)
- ? (currentSubscription.provider as SupportedBillingProvider)
- : null;
+ const subscriptionProvider = currentSubscription?.provider;
+ const currentProvider = isSupportedBillingProvider(subscriptionProvider)
+ ? subscriptionProvider
+ : null;
const currentPlanCandidate = useMemo<PlanChangeCandidate | null>(() => {
if (!currentPlan) return null;
const catalogProduct = catalog?.products.find(
@@ -926,25 +898,57 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null
}));
}, [subscriptionOffers, showPlanChangeEntry, currentPlan, currentProvider]);
- const openPurchaseDialog = (kind: PurchaseKind) => {
- resetSelection();
- if (kind === 'SUBSCRIPTION') {
- const defaultProduct =
- subscriptionProducts.find((product) =>
- isSubscriptionOfferSelectable(product.defaultOffer, currentSubscriptionOfferCode),
- ) ??
- subscriptionProducts[0] ??
- null;
- setSelectedProductCode(defaultProduct?.product.code ?? null);
- if (defaultProduct) {
- selectSubscriptionOffer(defaultProduct.defaultOffer);
+ const openPurchaseDialog = useCallback(
+ (kind: PurchaseKind) => {
+ resetSelection();
+ if (kind === 'SUBSCRIPTION') {
+ const defaultProduct =
+ subscriptionProducts.find((product) =>
+ isSubscriptionOfferSelectable(product.defaultOffer, currentSubscriptionOfferCode),
+ ) ??
+ subscriptionProducts[0] ??
+ null;
+ setSelectedProductCode(defaultProduct?.product.code ?? null);
+ if (defaultProduct) {
+ selectSubscriptionOffer(defaultProduct.defaultOffer);
+ }
+ setSubscriptionDialogOpen(true);
+ } else {
+ setSelectedProductCode(null);
+ setTopupDialogOpen(true);
}
- setSubscriptionDialogOpen(true);
- } else {
- setSelectedProductCode(null);
- setTopupDialogOpen(true);
+ },
+ [currentSubscriptionOfferCode, resetSelection, selectSubscriptionOffer, subscriptionProducts],
+ );
+
+ useEffect(() => {
+ const intent = searchParams.get('intent');
+ if (intent !== 'subscribe' && intent !== 'plan-change') return;
+ if (loadingCatalog || loadingSubscription) return;
+ // 目录或订阅请求失败时 loading 也会结束。此时还不知道能不能打开对应弹窗,
+ // 不能把 intent 摘掉 —— 用户点刷新成功后才能重放。加载成功但没有改档入口
+ // 才消费 plan-change(落地计费页,重放也不会弹出)。
+ if (catalogError || subscriptionError) return;
+ const next = new URLSearchParams(searchParams);
+ next.delete('intent');
+ setSearchParams(next, { replace: true });
+ if (intent === 'subscribe') {
+ openPurchaseDialog('SUBSCRIPTION');
+ return;
}
- };
+ if (showPlanChangeEntry) {
+ setPlanChangeTargetOpen(true);
+ }
+ }, [
+ catalogError,
+ loadingCatalog,
+ loadingSubscription,
+ openPurchaseDialog,
+ searchParams,
+ setSearchParams,
+ showPlanChangeEntry,
+ subscriptionError,
+ ]);
const selectOffer = (offerCode: string) => {
if (selectedOfferCode === offerCode) return;
@@ -2036,9 +2040,7 @@ function BillingOfferDialog({
return (
<button
key={offer.code}
- ref={
- offer.code === initialTopupOfferCode ? primaryFocusRef : undefined
- }
+ ref={offer.code === initialTopupOfferCode ? primaryFocusRef : undefined}
type="button"
onClick={() => onSelectOffer(offer.code)}
disabled={currentPlan || unavailableReason !== null}
@@ -2259,9 +2261,7 @@ function SubscriptionProductAccordion({
{singleOfferEntry ? (
<button
ref={
- productActive &&
- !singleOfferCurrentPlan &&
- singleOfferUnavailableReason === null
+ productActive && !singleOfferCurrentPlan && singleOfferUnavailableReason === null
? initialFocusRef
: undefined
}
@@ -2390,9 +2390,7 @@ function SubscriptionProductAccordion({
<button
key={offer.code}
ref={
- offerActive && !currentPlan && !unavailable
- ? initialFocusRef
- : undefined
+ offerActive && !currentPlan && !unavailable ? initialFocusRef : undefined
}
type="button"
onClick={() => onSelectOffer(offer.code)}
diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
index 4a1af46e84..cb23c1bd84 100644
--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx
@@ -30,7 +30,7 @@ const modelCatalogMocks = vi.hoisted(() => ({
const authState = vi.hoisted(() => ({ dataOwnerId: 'account-fixture' as string | null }));
/**
- * 计费页只用 useSearchParams 消费 `?intent=topup` 深链,不需要真的挂 Router:
+ * 计费页只用 useSearchParams 消费 `?intent=topup|subscribe|plan-change` 深链,不需要真的挂 Router:
* 用一个可读写的 URLSearchParams 替身,既能驱动深链分支,也能断言参数被摘除。
*/
const routerState = vi.hoisted(() => ({ search: '' as string }));
@@ -917,6 +917,40 @@ describe('BillingPage remote catalog rendering', () => {
expect(screen.queryByText('Configured top-up')).toBeNull();
});
+ it('深链 ?intent=subscribe 等目录与订阅加载完再打开购买弹窗,并摘掉参数', async () => {
+ routerState.search = 'tab=billing&intent=subscribe';
+
+ render(<BillingPage />);
+
+ expect(await screen.findByText('Configured subscription')).toBeTruthy();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBeNull();
+ expect(new URLSearchParams(routerState.search).get('tab')).toBe('billing');
+ });
+
+ it('深链 ?intent=subscribe 在目录加载失败时保留参数,刷新成功后再打开购买弹窗', async () => {
+ routerState.search = 'tab=billing&intent=subscribe';
+ vi.mocked(window.electronAPI.billing.getCatalog).mockRejectedValueOnce(
+ new Error('catalog unavailable'),
+ );
+
+ render(<BillingPage />);
+
+ await waitFor(() =>
+ expect(
+ screen
+ .getByRole('button', { name: 'billing.actions.refreshCatalog' })
+ .hasAttribute('disabled'),
+ ).toBe(false),
+ );
+ expect(screen.queryByRole('dialog')).toBeNull();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBe('subscribe');
+
+ fireEvent.click(screen.getByText('billing.actions.refreshCatalog'));
+
+ expect(await screen.findByText('Configured subscription')).toBeTruthy();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBeNull();
+ });
+
it('shows server-visible unavailable offers and only enables purchasable offers', async () => {
render(<BillingPage />);
@@ -1100,9 +1134,8 @@ describe('BillingPage remote catalog rendering', () => {
currency: 'USD',
}).format(250);
expect(
- within(alternativeOffer).getByText(
- `billing.credits:{"amount":"${alternativeCredits}"}`,
- ).className,
+ within(alternativeOffer).getByText(`billing.credits:{"amount":"${alternativeCredits}"}`)
+ .className,
).toContain('text-12');
expect(within(dialog).queryByText('plus_month_more')).toBeNull();
expect(currentPlan).toHaveProperty('disabled', true);
@@ -1196,9 +1229,7 @@ describe('BillingPage remote catalog rendering', () => {
const dialog = await screen.findByRole('dialog');
const defaultOffer = within(dialog).getByText('$9.00').closest('button')!;
- await waitFor(() =>
- expect(document.activeElement).toBe(defaultOffer),
- );
+ await waitFor(() => expect(document.activeElement).toBe(defaultOffer));
const proProduct = within(dialog).getByRole('button', { name: /Pro/ });
const futureProduct = within(dialog).getByRole('button', { name: /Coming Soon/ });
expect(proProduct).toHaveProperty('disabled', false);
@@ -2247,6 +2278,60 @@ describe('BillingPage plan change', () => {
expect(modelCatalogMocks.refreshBuiltinProviderModels).toHaveBeenCalledWith('xd');
});
+ it('深链 ?intent=plan-change 在有更改入口时打开目标弹窗并摘掉参数', async () => {
+ routerState.search = 'tab=billing&intent=plan-change';
+ install(billingMocks());
+
+ render(<BillingPage />);
+
+ expect(await screen.findByText('billing.planChange.targetTitle')).toBeTruthy();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBeNull();
+ expect(new URLSearchParams(routerState.search).get('tab')).toBe('billing');
+ });
+
+ it('深链 ?intent=plan-change 在没有更改入口时只落地计费页、不弹窗', async () => {
+ routerState.search = 'tab=billing&intent=plan-change';
+ const billing = billingMocks();
+ billing.getCurrentSubscription = vi.fn(async () => ({
+ subscription: activeSubscription(null, 'YEAR'),
+ }));
+ install(billing);
+
+ render(<BillingPage />);
+
+ await screen.findByText('billing.settings.subscriptionCard.manageAction');
+ expect(screen.queryByText('billing.planChange.targetTitle')).toBeNull();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBeNull();
+ });
+
+ it('深链 ?intent=plan-change 在订阅加载失败时保留参数,刷新成功后再打开目标弹窗', async () => {
+ routerState.search = 'tab=billing&intent=plan-change';
+ const billing = billingMocks();
+ billing.getCurrentSubscription = vi
+ .fn()
+ .mockRejectedValueOnce(new Error('subscription status unavailable'))
+ .mockResolvedValueOnce({ subscription: activeSubscription() });
+ install(billing);
+
+ render(<BillingPage />);
+
+ expect(await screen.findByText('billing.settings.subscriptionCard.unavailable')).toBeTruthy();
+ await waitFor(() =>
+ expect(
+ screen
+ .getByRole('button', { name: 'billing.actions.refreshCatalog' })
+ .hasAttribute('disabled'),
+ ).toBe(false),
+ );
+ expect(screen.queryByText('billing.planChange.targetTitle')).toBeNull();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBe('plan-change');
+
+ fireEvent.click(screen.getByText('billing.actions.refreshCatalog'));
+
+ expect(await screen.findByText('billing.planChange.targetTitle')).toBeTruthy();
+ expect(new URLSearchParams(routerState.search).get('intent')).toBeNull();
+ });
+
it('quotes the selected same-Product monthly Offer', async () => {
const billing = billingMocks();
billing.getCatalog = vi.fn(async () => ({
diff --git a/apps/desktop/src/renderer/features/billing/purchaseSupport.ts b/apps/desktop/src/renderer/features/billing/purchaseSupport.ts
new file mode 100644
index 0000000000..4b5587dfa3
--- /dev/null
+++ b/apps/desktop/src/renderer/features/billing/purchaseSupport.ts
@@ -0,0 +1,43 @@
+import type { BillingCatalogProduct, BillingPurchaseOption } from '../../../shared/billing';
+
+export type SupportedBillingProvider = 'alipay' | 'stripe';
+
+export type SupportedPurchaseOption = BillingPurchaseOption & {
+ provider: SupportedBillingProvider;
+};
+
+export const SUPPORTED_BILLING_PROVIDERS = new Set<SupportedBillingProvider>(['alipay', 'stripe']);
+
+const SUPPORTED_PAYMENT_ACTIONS = new Set<BillingPurchaseOption['paymentAction']>([
+ 'QR_CODE',
+ 'REDIRECT',
+]);
+
+const SUPPORTED_SUBSCRIPTION_CAPABILITIES = new Set<BillingPurchaseOption['capability']>([
+ 'MERCHANT_INITIATED_MANDATE',
+ 'PROVIDER_MANAGED_SUBSCRIPTION',
+]);
+
+export function isSupportedBillingProvider(
+ provider: string | undefined,
+): provider is SupportedBillingProvider {
+ return (
+ typeof provider === 'string' &&
+ SUPPORTED_BILLING_PROVIDERS.has(provider as SupportedBillingProvider)
+ );
+}
+
+/**
+ * Desktop 实际接得住的购买选项。目录里可能出现未来渠道、或订阅商品挂上
+ * `ONE_TIME_PAYMENT`:计费页会滤掉,升级 CTA 必须用同一判据,否则会把人带进空弹窗。
+ */
+export function isSupportedPurchaseOption(
+ option: BillingPurchaseOption,
+ productKind: BillingCatalogProduct['kind'],
+): option is SupportedPurchaseOption {
+ if (!isSupportedBillingProvider(option.provider)) return false;
+ if (!SUPPORTED_PAYMENT_ACTIONS.has(option.paymentAction)) return false;
+ return productKind === 'CREDIT_TOPUP'
+ ? option.capability === 'ONE_TIME_PAYMENT'
+ : SUPPORTED_SUBSCRIPTION_CAPABILITIES.has(option.capability);
+}
diff --git a/apps/desktop/src/renderer/hooks/__tests__/useXdAssetPrimaryAction.test.ts b/apps/desktop/src/renderer/hooks/__tests__/useXdAssetPrimaryAction.test.ts
new file mode 100644
index 0000000000..9a8a7369c2
--- /dev/null
+++ b/apps/desktop/src/renderer/hooks/__tests__/useXdAssetPrimaryAction.test.ts
@@ -0,0 +1,148 @@
+// @vitest-environment jsdom
+
+import { act, renderHook, waitFor } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import type { BillingCatalog, BillingSubscription } from '../../../shared/billing';
+
+const mocks = vi.hoisted(() => ({
+ getCurrentSubscription: vi.fn(),
+ getCatalog: vi.fn(),
+ auth: {
+ dataOwnerId: 'acc-1' as string | null,
+ mode: 'cloud' as const,
+ user: { membershipKind: 'personal' as const },
+ },
+}));
+
+vi.mock('../../features/billing/api', () => ({
+ billingApi: {
+ getCurrentSubscription: mocks.getCurrentSubscription,
+ getCatalog: mocks.getCatalog,
+ },
+}));
+
+vi.mock('../../contexts/AuthContext', () => ({
+ useAuth: () => mocks.auth,
+}));
+
+import { useXdAssetPrimaryAction } from '../useXdAssetPrimaryAction';
+
+function deferred<T>() {
+ let resolve!: (value: T) => void;
+ const promise = new Promise<T>((next) => {
+ resolve = next;
+ });
+ return { promise, resolve };
+}
+
+const plusMonth: BillingSubscription = {
+ subscriptionId: 'sub_1',
+ status: 'ACTIVE',
+ provider: 'stripe',
+ currentPeriodStartAt: null,
+ currentPeriodEndAt: null,
+ entitlementValidUntil: null,
+ cancelAtPeriodEnd: false,
+ effectivePlan: {
+ version: 1,
+ product: { code: 'plus', kind: 'SUBSCRIPTION', level: 1 },
+ offer: { code: 'plus_month', interval: 'MONTH' },
+ terms: { amount: '9', currency: 'usd', creditAmount: '100', rolloverCap: '0' },
+ capturedAt: '2026-01-01T00:00:00.000Z',
+ },
+ purchaseAttemptId: null,
+ paymentAction: null,
+};
+
+const plusAndMaxCatalog: BillingCatalog = {
+ products: [
+ {
+ code: 'plus',
+ name: 'Plus',
+ kind: 'SUBSCRIPTION',
+ level: 1,
+ sortOrder: 1,
+ offers: [
+ {
+ code: 'plus_month',
+ interval: 'MONTH',
+ currency: 'usd',
+ amount: '9',
+ minAmount: null,
+ maxAmount: null,
+ creditAmount: '100',
+ rolloverCap: '0',
+ purchaseOptions: [
+ {
+ id: 'listing_plus_month',
+ provider: 'stripe',
+ capability: 'PROVIDER_MANAGED_SUBSCRIPTION',
+ paymentAction: 'REDIRECT',
+ },
+ ],
+ },
+ ],
+ },
+ {
+ code: 'max',
+ name: 'Max',
+ kind: 'SUBSCRIPTION',
+ level: 2,
+ sortOrder: 2,
+ offers: [
+ {
+ code: 'max_month',
+ interval: 'MONTH',
+ currency: 'usd',
+ amount: '20',
+ minAmount: null,
+ maxAmount: null,
+ creditAmount: '250',
+ rolloverCap: '0',
+ purchaseOptions: [
+ {
+ id: 'listing_max_month',
+ provider: 'stripe',
+ capability: 'PROVIDER_MANAGED_SUBSCRIPTION',
+ paymentAction: 'REDIRECT',
+ },
+ ],
+ },
+ ],
+ },
+ ],
+};
+
+describe('useXdAssetPrimaryAction', () => {
+ beforeEach(() => {
+ mocks.auth.dataOwnerId = 'acc-1';
+ mocks.auth.mode = 'cloud';
+ mocks.auth.user = { membershipKind: 'personal' };
+ mocks.getCurrentSubscription.mockReset();
+ mocks.getCatalog.mockReset();
+ });
+
+ it('卸载后再挂载不会画出上一套套餐的 CTA', async () => {
+ mocks.getCurrentSubscription.mockResolvedValue({ subscription: null });
+ mocks.getCatalog.mockResolvedValue(plusAndMaxCatalog);
+
+ const first = renderHook(() => useXdAssetPrimaryAction(true));
+ await waitFor(() => expect(first.result.current).toBe('buy-plan'));
+ first.unmount();
+
+ const subscription = deferred<{ subscription: BillingSubscription | null }>();
+ const catalog = deferred<BillingCatalog>();
+ mocks.getCurrentSubscription.mockReturnValue(subscription.promise);
+ mocks.getCatalog.mockReturnValue(catalog.promise);
+
+ const second = renderHook(() => useXdAssetPrimaryAction(true));
+ expect(second.result.current).toBeNull();
+
+ await act(async () => {
+ subscription.resolve({ subscription: plusMonth });
+ catalog.resolve(plusAndMaxCatalog);
+ });
+ await waitFor(() => expect(second.result.current).toBe('upgrade-plan'));
+ });
+});
diff --git a/apps/desktop/src/renderer/hooks/useXdAssetPrimaryAction.ts b/apps/desktop/src/renderer/hooks/useXdAssetPrimaryAction.ts
new file mode 100644
index 0000000000..69b1f421f1
--- /dev/null
+++ b/apps/desktop/src/renderer/hooks/useXdAssetPrimaryAction.ts
@@ -0,0 +1,67 @@
+/**
+ * useXdAssetPrimaryAction — 供应商页余额块右侧那颗 Black Pill。
+ *
+ * 查看用量始终在;右侧只留一颗:
+ * 非套餐 → 购买套餐
+ * 目录里还有更高等级可改档 → 升级套餐
+ * 已经升满,或年付 / 非 ACTIVE / 取消待到期没法改档 → 余额充值
+ *
+ * 只在余额块真正渲染时启用。订阅请求失败按非套餐(出购买套餐):把已订用户推进
+ * 购买弹窗,计费页自己会用 purchaseBlocked 兜住。目录失败且仍符合更改套餐入口时
+ * 按可升级处理,避免把还能升的人直接推进充值。
+ *
+ * 不跨实例缓存决议。购买 / 升级 / 取消 / 恢复发生在计费页,回到供应商页会重新
+ * 挂载:缓存会在新请求回来前画出上一套套餐的 CTA。宁可短暂不画右侧按钮。
+ */
+
+import { useEffect, useState } from 'react';
+
+import { billingApi } from '../features/billing/api';
+import { useAuth } from '../contexts/AuthContext';
+import {
+ canUpgradeBillingPlan,
+ hasBlockingBillingSubscription,
+ resolveXdAssetActionLayout,
+ type XdAssetPrimaryAction,
+} from '../components/settings/providerAssetModule';
+
+export function useXdAssetPrimaryAction(enabled: boolean): XdAssetPrimaryAction | null {
+ const { dataOwnerId, mode, user } = useAuth();
+ const actionEnabled = enabled && mode === 'cloud' && user?.membershipKind === 'personal';
+ const [primary, setPrimary] = useState<XdAssetPrimaryAction | null>(null);
+
+ useEffect(() => {
+ if (!actionEnabled || !dataOwnerId) {
+ setPrimary(null);
+ return;
+ }
+ let cancelled = false;
+ setPrimary(null);
+
+ void Promise.all([
+ billingApi
+ .getCurrentSubscription()
+ .then((res) => res.subscription)
+ .catch(() => null),
+ billingApi.getCatalog().catch(() => null),
+ ]).then(([subscription, catalog]) => {
+ if (cancelled) return;
+ const hasBlocking = hasBlockingBillingSubscription(subscription);
+ const canUpgrade = canUpgradeBillingPlan(subscription, catalog);
+ const resolvedCanUpgrade = catalog == null && canUpgrade == null ? true : canUpgrade;
+ setPrimary(
+ resolveXdAssetActionLayout({
+ hasBlockingSubscription: hasBlocking,
+ canUpgrade: resolvedCanUpgrade,
+ }).primary,
+ );
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ }, [actionEnabled, dataOwnerId]);
+
+ if (!actionEnabled || !dataOwnerId) return null;
+ return primary;
+}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 4cb6799fe0..fa0c99cf71 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -850,59 +850,59 @@
"chatAttachmentsClearConfirmDescription": "Only files in the message attachment cache directory will be deleted; the message database will not be queried. Some attachments in message history may become unavailable, and this cannot be undone.",
"chatAttachmentsClearConfirmButton": "Clear attachment cache",
"chatAttachmentsCleared": "Message attachment cache cleaned up",
- "chatAttachmentsClearFailed": "Could not clean up the message attachment cache. Try again.",
- "dbSlimmingBackupDirectoryDialogTitle": "Choose database cleanup backup folder",
- "dbSlimmingLabel": "Database cleanup",
- "dbSlimmingDescription": "Scan history in soft-deleted and archived tasks not updated for the selected period, with an option to include active tasks. After confirmation, Cindy restarts and compacts the database before opening it. Files and generated media on disk are not deleted.",
- "dbSlimmingScanButton": "Scan database",
- "dbSlimmingScanLoading": "Scanning the database…",
- "dbSlimmingScanResultTitle": "Database scan results",
- "dbSlimmingExecutionLoading": "Preparing database cleanup. Cindy will restart shortly…",
- "dbSlimmingArchiveAgeLabel": "Clean tasks not updated for more than",
- "dbSlimmingArchiveAgeOption7Days": "7 days",
- "dbSlimmingArchiveAgeOption1": "1 month",
- "dbSlimmingArchiveAgeOption3": "3 months",
- "dbSlimmingArchiveAgeOption6": "6 months",
- "dbSlimmingIncludeActiveLabel": "Clean active task history",
- "dbSlimmingIncludeActiveDescription": "Also clean history from active tasks older than the selected period",
- "dbSlimmingIncludeActiveConfirmTitle": "Include active tasks in database cleanup?",
- "dbSlimmingIncludeActiveConfirmDescription": "An active task may still be running even when it is older than the selected period. Cleanup does not wait for it to stop, and messages it adds after the scan may also be removed. When enabled, active, archived, and soft-deleted tasks not updated for the selected period will be cleaned. History will be removed from eligible active tasks and their Agent context will be reset; task entries remain. A database backup can restore task and message data; without one, that data cannot be restored either. Records used to review or undo file changes from those messages are not included in the database backup and cannot be restored.",
- "dbSlimmingIncludeActiveConfirmButton": "Include active tasks",
- "dbSlimmingIncludeActiveCancelButton": "Keep active tasks",
- "dbSlimmingBackupLabel": "Back up database before cleanup",
- "dbSlimmingBackupDefaultLocation": "Database folder (keeps only the latest cleanup backup)",
- "dbSlimmingUseDefaultDirectoryButton": "Use default folder",
- "dbSlimmingChooseDirectoryButton": "Choose backup folder",
- "dbSlimmingBackupDirectoryFailed": "Could not choose a backup folder. Try again.",
- "dbSlimmingScanFailed": "Could not scan the database. Try again.",
- "dbSlimmingScheduleFailed": "Could not schedule database cleanup. Scan again and retry.",
- "dbSlimmingBackupMissing": "The latest cleanup backup could not be found.",
- "dbSlimmingBackupOpenFailed": "Could not open the cleanup backup location. Try again.",
- "dbSlimmingReportTasks": "Will clean {{deleted}} soft-deleted tasks and {{archived}} archived tasks",
- "dbSlimmingReportTasksWithActive": "Will clean {{active}} active tasks, {{deleted}} soft-deleted tasks, and {{archived}} archived tasks",
- "dbSlimmingReportMessages": "Estimated message content to clean: {{count}} messages (about {{size}})",
- "dbSlimmingReportSpace": "Database: {{database}}; temporary space needed: at least {{temporary}}; available: {{free}}",
- "dbSlimmingSpaceUnknown": "unknown",
- "dbSlimmingInsufficientSpace": "There is not enough disk space to safely create a working copy and compact the database.",
- "dbSlimmingConfirmButton": "Confirm database cleanup",
- "dbSlimmingConfirmTitle": "Restart and clean up the database?",
- "dbSlimmingConfirmDescriptionWithBackup": "Cindy will restart gracefully, then back up, clean history, compact, and verify the database before opening it. Data is cleaned only after the backup is written and verified.",
- "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy will restart gracefully, then clean and compact the database before opening it. No backup will be created, and cleaned history cannot be recovered.",
- "dbSlimmingRestartButton": "Restart and clean up database",
- "dbSlimmingResultCompleted": "Removed {{messages}} messages from {{tasks}} tasks and reduced the database by {{size}}.",
- "dbSlimmingOpenBackupButton": "Open cleanup backup",
- "dbSlimmingToastCompleted": "Database cleanup complete; freed {{size}}",
- "dbSlimmingHistoryCleared": "History has been cleared",
- "dbSlimmingFailure": {
- "backup-failed": "The database backup could not be created or retained. No history was cleaned.",
- "cleanup-failed": "Database cleanup did not finish. The original database is unchanged.",
- "database-in-use": "Another instance is using the database, so cleanup was not run.",
- "insufficient-space": "There was not enough disk space to clean up the database.",
- "integrity-check-failed": "The database integrity check failed. The original database was restored.",
- "replacement-failed": "The compacted database could not be installed. The original database was restored.",
- "recovery-failed": "Database recovery failed. Cindy stopped opening the database to protect the original data.",
- "unknown": "Database cleanup did not finish. Try again."
- },
+ "chatAttachmentsClearFailed": "Could not clean up the message attachment cache. Try again.",
+ "dbSlimmingBackupDirectoryDialogTitle": "Choose database cleanup backup folder",
+ "dbSlimmingLabel": "Database cleanup",
+ "dbSlimmingDescription": "Scan history in soft-deleted and archived tasks not updated for the selected period, with an option to include active tasks. After confirmation, Cindy restarts and compacts the database before opening it. Files and generated media on disk are not deleted.",
+ "dbSlimmingScanButton": "Scan database",
+ "dbSlimmingScanLoading": "Scanning the database…",
+ "dbSlimmingScanResultTitle": "Database scan results",
+ "dbSlimmingExecutionLoading": "Preparing database cleanup. Cindy will restart shortly…",
+ "dbSlimmingArchiveAgeLabel": "Clean tasks not updated for more than",
+ "dbSlimmingArchiveAgeOption7Days": "7 days",
+ "dbSlimmingArchiveAgeOption1": "1 month",
+ "dbSlimmingArchiveAgeOption3": "3 months",
+ "dbSlimmingArchiveAgeOption6": "6 months",
+ "dbSlimmingIncludeActiveLabel": "Clean active task history",
+ "dbSlimmingIncludeActiveDescription": "Also clean history from active tasks older than the selected period",
+ "dbSlimmingIncludeActiveConfirmTitle": "Include active tasks in database cleanup?",
+ "dbSlimmingIncludeActiveConfirmDescription": "An active task may still be running even when it is older than the selected period. Cleanup does not wait for it to stop, and messages it adds after the scan may also be removed. When enabled, active, archived, and soft-deleted tasks not updated for the selected period will be cleaned. History will be removed from eligible active tasks and their Agent context will be reset; task entries remain. A database backup can restore task and message data; without one, that data cannot be restored either. Records used to review or undo file changes from those messages are not included in the database backup and cannot be restored.",
+ "dbSlimmingIncludeActiveConfirmButton": "Include active tasks",
+ "dbSlimmingIncludeActiveCancelButton": "Keep active tasks",
+ "dbSlimmingBackupLabel": "Back up database before cleanup",
+ "dbSlimmingBackupDefaultLocation": "Database folder (keeps only the latest cleanup backup)",
+ "dbSlimmingUseDefaultDirectoryButton": "Use default folder",
+ "dbSlimmingChooseDirectoryButton": "Choose backup folder",
+ "dbSlimmingBackupDirectoryFailed": "Could not choose a backup folder. Try again.",
+ "dbSlimmingScanFailed": "Could not scan the database. Try again.",
+ "dbSlimmingScheduleFailed": "Could not schedule database cleanup. Scan again and retry.",
+ "dbSlimmingBackupMissing": "The latest cleanup backup could not be found.",
+ "dbSlimmingBackupOpenFailed": "Could not open the cleanup backup location. Try again.",
+ "dbSlimmingReportTasks": "Will clean {{deleted}} soft-deleted tasks and {{archived}} archived tasks",
+ "dbSlimmingReportTasksWithActive": "Will clean {{active}} active tasks, {{deleted}} soft-deleted tasks, and {{archived}} archived tasks",
+ "dbSlimmingReportMessages": "Estimated message content to clean: {{count}} messages (about {{size}})",
+ "dbSlimmingReportSpace": "Database: {{database}}; temporary space needed: at least {{temporary}}; available: {{free}}",
+ "dbSlimmingSpaceUnknown": "unknown",
+ "dbSlimmingInsufficientSpace": "There is not enough disk space to safely create a working copy and compact the database.",
+ "dbSlimmingConfirmButton": "Confirm database cleanup",
+ "dbSlimmingConfirmTitle": "Restart and clean up the database?",
+ "dbSlimmingConfirmDescriptionWithBackup": "Cindy will restart gracefully, then back up, clean history, compact, and verify the database before opening it. Data is cleaned only after the backup is written and verified.",
+ "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy will restart gracefully, then clean and compact the database before opening it. No backup will be created, and cleaned history cannot be recovered.",
+ "dbSlimmingRestartButton": "Restart and clean up database",
+ "dbSlimmingResultCompleted": "Removed {{messages}} messages from {{tasks}} tasks and reduced the database by {{size}}.",
+ "dbSlimmingOpenBackupButton": "Open cleanup backup",
+ "dbSlimmingToastCompleted": "Database cleanup complete; freed {{size}}",
+ "dbSlimmingHistoryCleared": "History has been cleared",
+ "dbSlimmingFailure": {
+ "backup-failed": "The database backup could not be created or retained. No history was cleaned.",
+ "cleanup-failed": "Database cleanup did not finish. The original database is unchanged.",
+ "database-in-use": "Another instance is using the database, so cleanup was not run.",
+ "insufficient-space": "There was not enough disk space to clean up the database.",
+ "integrity-check-failed": "The database integrity check failed. The original database was restored.",
+ "replacement-failed": "The compacted database could not be installed. The original database was restored.",
+ "recovery-failed": "Database recovery failed. Cindy stopped opening the database to protect the original data.",
+ "unknown": "Database cleanup did not finish. Try again."
+ },
"cleanupLabel": "Disk cleanup",
"cleanupDescription": "Scans for media files no session references anymore, oversized caches, and obsolete folders. Shows the numbers first and deletes only after you confirm; images in composer drafts and queued messages are protected automatically.",
"scanButton": "Scan",
@@ -1458,6 +1458,8 @@
"copyKeyFailed": "Copy failed, please try again later",
"asset": {
"viewUsage": "View usage",
+ "buyPlan": "Buy a plan",
+ "upgradePlan": "Upgrade plan",
"syncFailed": "Credential sync failed, so the balance is unavailable right now. Your saved model settings are unaffected."
}
},
@@ -4325,7 +4327,9 @@
"openAria": "Open PlayStation controller settings",
"entryDescription": "Scroll, talk, send, and switch tasks with a controller",
"connection": {
- "toggle": { "aria": "Let this Cindy use a PlayStation controller while it is in the foreground" },
+ "toggle": {
+ "aria": "Let this Cindy use a PlayStation controller while it is in the foreground"
+ },
"descriptions": {
"connecting": "Cindy is looking for a PlayStation controller.",
"connected": "Cindy listens to this controller while it is in the foreground.",
@@ -4342,7 +4346,9 @@
"openAria": "Open Switch controller settings",
"entryDescription": "Scroll, talk, send, and switch tasks with a controller",
"connection": {
- "toggle": { "aria": "Let this Cindy use a Switch controller while it is in the foreground" },
+ "toggle": {
+ "aria": "Let this Cindy use a Switch controller while it is in the foreground"
+ },
"descriptions": {
"connecting": "Cindy is looking for a Switch controller.",
"connected": "Cindy listens to this controller while it is in the foreground.",
@@ -4359,7 +4365,9 @@
"openAria": "Open generic controller settings",
"entryDescription": "Scroll, talk, send, and switch tasks with a controller",
"connection": {
- "toggle": { "aria": "Let this Cindy use a generic controller while it is in the foreground" },
+ "toggle": {
+ "aria": "Let this Cindy use a generic controller while it is in the foreground"
+ },
"descriptions": {
"connecting": "Cindy is looking for a controller.",
"connected": "Cindy listens to this controller while it is in the foreground.",
@@ -8206,7 +8214,13 @@
"showLess": "Show less",
"artifactLabel": "Artifact",
"formats": { "pdf": "PDF", "docx": "Word", "pptx": "PPT", "xlsx": "Excel" },
- "summary": { "pages": "{{count}} pages", "slides": "{{count}} slides", "sheets": "{{count}} sheets", "rows": "{{count}} rows", "bytes": "{{count}}" }
+ "summary": {
+ "pages": "{{count}} pages",
+ "slides": "{{count}} slides",
+ "sheets": "{{count}} sheets",
+ "rows": "{{count}} rows",
+ "bytes": "{{count}}"
+ }
},
"turnChanges": {
"title": "Changed {{count}} files",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c7aeb2e796..53a3feec79 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -850,59 +850,59 @@
"chatAttachmentsClearConfirmDescription": "メッセージ添付ファイルのキャッシュディレクトリ内のファイルだけを削除し、メッセージデータベースは参照しません。履歴内の一部の添付ファイルを開けなくなる場合があり、この操作は元に戻せません。",
"chatAttachmentsClearConfirmButton": "添付ファイルキャッシュを削除",
"chatAttachmentsCleared": "メッセージ添付ファイルのキャッシュをクリーンアップしました",
- "chatAttachmentsClearFailed": "メッセージ添付ファイルのキャッシュをクリーンアップできませんでした。もう一度お試しください。",
- "dbSlimmingBackupDirectoryDialogTitle": "データベースのクリーンアップ用バックアップ先を選択",
- "dbSlimmingLabel": "データベースのクリーンアップ",
- "dbSlimmingDescription": "選択した期間を超えて更新されていない論理削除済みおよびアーカイブ済みタスクの履歴をスキャンし、必要に応じてアクティブなタスクも対象に含めます。確認後に Cindy を再起動し、データベースを開く前に履歴を削除して圧縮します。ディスク上の添付ファイルや生成メディアは削除しません。",
- "dbSlimmingScanButton": "データベースをスキャン",
- "dbSlimmingScanLoading": "データベースをスキャンしています…",
- "dbSlimmingScanResultTitle": "データベースのスキャン結果",
- "dbSlimmingExecutionLoading": "データベースのクリーンアップを準備しています。Cindy はまもなく再起動します…",
- "dbSlimmingArchiveAgeLabel": "最終更新から次の期間を超えたタスクを整理",
- "dbSlimmingArchiveAgeOption7Days": "7 日",
- "dbSlimmingArchiveAgeOption1": "1 か月",
- "dbSlimmingArchiveAgeOption3": "3 か月",
- "dbSlimmingArchiveAgeOption6": "6 か月",
- "dbSlimmingIncludeActiveLabel": "アクティブなタスクの履歴も削除",
- "dbSlimmingIncludeActiveDescription": "選択した期間を超えたアクティブなタスクの履歴もクリーンアップします",
- "dbSlimmingIncludeActiveConfirmTitle": "アクティブなタスクもデータベースのクリーンアップ対象にしますか?",
- "dbSlimmingIncludeActiveConfirmDescription": "選択した期間を超えたアクティブなタスクでも、まだ実行中の可能性があります。クリーンアップはタスクの停止を待たず、スキャン後に追加されたメッセージも削除される場合があります。有効にすると、選択した期間を超えて更新されていないアクティブ、アーカイブ済み、論理削除済みのタスクがクリーンアップされます。対象のアクティブなタスクの履歴と Agent コンテキストは削除されますが、タスク自体は残ります。データベースのバックアップではタスクとメッセージのデータを復元できます。バックアップを作成しない場合、それらのデータも復元できません。それらのメッセージによるファイル変更のレビューや元に戻す操作に使う記録はデータベースのバックアップに含まれず、復元できません。",
- "dbSlimmingIncludeActiveConfirmButton": "アクティブなタスクを含める",
- "dbSlimmingIncludeActiveCancelButton": "アクティブなタスクを残す",
- "dbSlimmingBackupLabel": "クリーンアップ前にデータベースをバックアップ",
- "dbSlimmingBackupDefaultLocation": "データベースのフォルダ(最新のクリーンアップ用バックアップのみ保持)",
- "dbSlimmingUseDefaultDirectoryButton": "既定のフォルダを使用",
- "dbSlimmingChooseDirectoryButton": "バックアップ先を選択",
- "dbSlimmingBackupDirectoryFailed": "バックアップ先を選択できませんでした。もう一度お試しください。",
- "dbSlimmingScanFailed": "データベースをスキャンできませんでした。もう一度お試しください。",
- "dbSlimmingScheduleFailed": "データベースのクリーンアップを予約できませんでした。再スキャンしてお試しください。",
- "dbSlimmingBackupMissing": "最新のクリーンアップ用バックアップが見つかりません。",
- "dbSlimmingBackupOpenFailed": "クリーンアップ用バックアップの場所を開けませんでした。もう一度お試しください。",
- "dbSlimmingReportTasks": "論理削除タスク {{deleted}} 件、アーカイブ済みタスク {{archived}} 件を削除します",
- "dbSlimmingReportTasksWithActive": "アクティブなタスク {{active}} 件、論理削除済みタスク {{deleted}} 件、アーカイブ済みタスク {{archived}} 件をクリーンアップします",
- "dbSlimmingReportMessages": "削除予定のメッセージ内容:{{count}} 件(約 {{size}})",
- "dbSlimmingReportSpace": "データベース {{database}}、必要な一時領域は最低 {{temporary}}、空き容量 {{free}}",
- "dbSlimmingSpaceUnknown": "不明",
- "dbSlimmingInsufficientSpace": "作業コピーを安全に作成してデータベースを圧縮するための空き容量がありません。",
- "dbSlimmingConfirmButton": "データベースのクリーンアップを確認",
- "dbSlimmingConfirmTitle": "再起動してデータベースをクリーンアップしますか?",
- "dbSlimmingConfirmDescriptionWithBackup": "Cindy を正常に再起動し、次回起動時にデータベースを開く前にバックアップ、履歴削除、圧縮、整合性確認を行います。バックアップの書き込みと検証が完了するまでデータは削除しません。",
- "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy を正常に再起動し、次回起動時にデータベースを開く前に履歴を削除して圧縮します。今回はバックアップを作成しないため、削除した履歴は復元できません。",
- "dbSlimmingRestartButton": "再起動してデータベースをクリーンアップ",
- "dbSlimmingResultCompleted": "{{tasks}} 件のタスクから {{messages}} 件のメッセージを削除し、データベースを {{size}} 縮小しました。",
- "dbSlimmingOpenBackupButton": "クリーンアップ用バックアップを開く",
- "dbSlimmingToastCompleted": "データベースのクリーンアップが完了し、{{size}} 解放しました",
- "dbSlimmingHistoryCleared": "履歴は削除されました",
- "dbSlimmingFailure": {
- "backup-failed": "データベースのバックアップを作成または保持できなかったため、履歴は削除していません。",
- "cleanup-failed": "データベースのクリーンアップは完了しませんでした。元のデータベースは変更されていません。",
- "database-in-use": "別のインスタンスがデータベースを使用しているため、クリーンアップを実行しませんでした。",
- "insufficient-space": "空き容量が不足しているため、データベースのクリーンアップを実行しませんでした。",
- "integrity-check-failed": "整合性確認に失敗したため、元のデータベースを復元しました。",
- "replacement-failed": "圧縮後のデータベースを配置できなかったため、元のデータベースを復元しました。",
- "recovery-failed": "データベースの復元に失敗しました。元データを保護するため、Cindy はデータベースを開いていません。",
- "unknown": "データベースのクリーンアップは完了しませんでした。もう一度お試しください。"
- },
+ "chatAttachmentsClearFailed": "メッセージ添付ファイルのキャッシュをクリーンアップできませんでした。もう一度お試しください。",
+ "dbSlimmingBackupDirectoryDialogTitle": "データベースのクリーンアップ用バックアップ先を選択",
+ "dbSlimmingLabel": "データベースのクリーンアップ",
+ "dbSlimmingDescription": "選択した期間を超えて更新されていない論理削除済みおよびアーカイブ済みタスクの履歴をスキャンし、必要に応じてアクティブなタスクも対象に含めます。確認後に Cindy を再起動し、データベースを開く前に履歴を削除して圧縮します。ディスク上の添付ファイルや生成メディアは削除しません。",
+ "dbSlimmingScanButton": "データベースをスキャン",
+ "dbSlimmingScanLoading": "データベースをスキャンしています…",
+ "dbSlimmingScanResultTitle": "データベースのスキャン結果",
+ "dbSlimmingExecutionLoading": "データベースのクリーンアップを準備しています。Cindy はまもなく再起動します…",
+ "dbSlimmingArchiveAgeLabel": "最終更新から次の期間を超えたタスクを整理",
+ "dbSlimmingArchiveAgeOption7Days": "7 日",
+ "dbSlimmingArchiveAgeOption1": "1 か月",
+ "dbSlimmingArchiveAgeOption3": "3 か月",
+ "dbSlimmingArchiveAgeOption6": "6 か月",
+ "dbSlimmingIncludeActiveLabel": "アクティブなタスクの履歴も削除",
+ "dbSlimmingIncludeActiveDescription": "選択した期間を超えたアクティブなタスクの履歴もクリーンアップします",
+ "dbSlimmingIncludeActiveConfirmTitle": "アクティブなタスクもデータベースのクリーンアップ対象にしますか?",
+ "dbSlimmingIncludeActiveConfirmDescription": "選択した期間を超えたアクティブなタスクでも、まだ実行中の可能性があります。クリーンアップはタスクの停止を待たず、スキャン後に追加されたメッセージも削除される場合があります。有効にすると、選択した期間を超えて更新されていないアクティブ、アーカイブ済み、論理削除済みのタスクがクリーンアップされます。対象のアクティブなタスクの履歴と Agent コンテキストは削除されますが、タスク自体は残ります。データベースのバックアップではタスクとメッセージのデータを復元できます。バックアップを作成しない場合、それらのデータも復元できません。それらのメッセージによるファイル変更のレビューや元に戻す操作に使う記録はデータベースのバックアップに含まれず、復元できません。",
+ "dbSlimmingIncludeActiveConfirmButton": "アクティブなタスクを含める",
+ "dbSlimmingIncludeActiveCancelButton": "アクティブなタスクを残す",
+ "dbSlimmingBackupLabel": "クリーンアップ前にデータベースをバックアップ",
+ "dbSlimmingBackupDefaultLocation": "データベースのフォルダ(最新のクリーンアップ用バックアップのみ保持)",
+ "dbSlimmingUseDefaultDirectoryButton": "既定のフォルダを使用",
+ "dbSlimmingChooseDirectoryButton": "バックアップ先を選択",
+ "dbSlimmingBackupDirectoryFailed": "バックアップ先を選択できませんでした。もう一度お試しください。",
+ "dbSlimmingScanFailed": "データベースをスキャンできませんでした。もう一度お試しください。",
+ "dbSlimmingScheduleFailed": "データベースのクリーンアップを予約できませんでした。再スキャンしてお試しください。",
+ "dbSlimmingBackupMissing": "最新のクリーンアップ用バックアップが見つかりません。",
+ "dbSlimmingBackupOpenFailed": "クリーンアップ用バックアップの場所を開けませんでした。もう一度お試しください。",
+ "dbSlimmingReportTasks": "論理削除タスク {{deleted}} 件、アーカイブ済みタスク {{archived}} 件を削除します",
+ "dbSlimmingReportTasksWithActive": "アクティブなタスク {{active}} 件、論理削除済みタスク {{deleted}} 件、アーカイブ済みタスク {{archived}} 件をクリーンアップします",
+ "dbSlimmingReportMessages": "削除予定のメッセージ内容:{{count}} 件(約 {{size}})",
+ "dbSlimmingReportSpace": "データベース {{database}}、必要な一時領域は最低 {{temporary}}、空き容量 {{free}}",
+ "dbSlimmingSpaceUnknown": "不明",
+ "dbSlimmingInsufficientSpace": "作業コピーを安全に作成してデータベースを圧縮するための空き容量がありません。",
+ "dbSlimmingConfirmButton": "データベースのクリーンアップを確認",
+ "dbSlimmingConfirmTitle": "再起動してデータベースをクリーンアップしますか?",
+ "dbSlimmingConfirmDescriptionWithBackup": "Cindy を正常に再起動し、次回起動時にデータベースを開く前にバックアップ、履歴削除、圧縮、整合性確認を行います。バックアップの書き込みと検証が完了するまでデータは削除しません。",
+ "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy を正常に再起動し、次回起動時にデータベースを開く前に履歴を削除して圧縮します。今回はバックアップを作成しないため、削除した履歴は復元できません。",
+ "dbSlimmingRestartButton": "再起動してデータベースをクリーンアップ",
+ "dbSlimmingResultCompleted": "{{tasks}} 件のタスクから {{messages}} 件のメッセージを削除し、データベースを {{size}} 縮小しました。",
+ "dbSlimmingOpenBackupButton": "クリーンアップ用バックアップを開く",
+ "dbSlimmingToastCompleted": "データベースのクリーンアップが完了し、{{size}} 解放しました",
+ "dbSlimmingHistoryCleared": "履歴は削除されました",
+ "dbSlimmingFailure": {
+ "backup-failed": "データベースのバックアップを作成または保持できなかったため、履歴は削除していません。",
+ "cleanup-failed": "データベースのクリーンアップは完了しませんでした。元のデータベースは変更されていません。",
+ "database-in-use": "別のインスタンスがデータベースを使用しているため、クリーンアップを実行しませんでした。",
+ "insufficient-space": "空き容量が不足しているため、データベースのクリーンアップを実行しませんでした。",
+ "integrity-check-failed": "整合性確認に失敗したため、元のデータベースを復元しました。",
+ "replacement-failed": "圧縮後のデータベースを配置できなかったため、元のデータベースを復元しました。",
+ "recovery-failed": "データベースの復元に失敗しました。元データを保護するため、Cindy はデータベースを開いていません。",
+ "unknown": "データベースのクリーンアップは完了しませんでした。もう一度お試しください。"
+ },
"cleanupLabel": "ディスククリーンアップ",
"cleanupDescription": "どのセッションからも参照されていないメディアファイル、上限を超えたキャッシュ、不要になったフォルダをスキャンします。まず件数を表示し、確認後にのみ削除します。入力欄の下書きや送信待ちメッセージ内の画像は自動的に保護されます。",
"scanButton": "スキャン",
@@ -1458,6 +1458,8 @@
"copyKeyFailed": "コピーに失敗しました。後でもう一度お試しください",
"asset": {
"viewUsage": "使用量を見る",
+ "buyPlan": "プランを購入",
+ "upgradePlan": "プランをアップグレード",
"syncFailed": "認証情報の同期に失敗したため、残高を取得できません。保存済みのモデル設定には影響しません。"
}
},
@@ -8200,7 +8202,13 @@
"showLess": "折りたたむ",
"artifactLabel": "成果物",
"formats": { "pdf": "PDF", "docx": "Word", "pptx": "PPT", "xlsx": "Excel" },
- "summary": { "pages": "{{count}} ページ", "slides": "{{count}} 枚のスライド", "sheets": "{{count}} シート", "rows": "{{count}} 行", "bytes": "{{count}}" }
+ "summary": {
+ "pages": "{{count}} ページ",
+ "slides": "{{count}} 枚のスライド",
+ "sheets": "{{count}} シート",
+ "rows": "{{count}} 行",
+ "bytes": "{{count}}"
+ }
},
"turnChanges": {
"title": "{{count}} ファイルを変更",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 1cbd9bdc13..1220f24a33 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -850,59 +850,59 @@
"chatAttachmentsClearConfirmDescription": "메시지 첨부 파일 캐시 디렉터리의 파일만 삭제하며 메시지 데이터베이스는 조회하지 않습니다. 메시지 기록의 일부 첨부 파일을 열 수 없게 될 수 있으며 이 작업은 되돌릴 수 없습니다.",
"chatAttachmentsClearConfirmButton": "첨부 파일 캐시 정리",
"chatAttachmentsCleared": "메시지 첨부 파일 캐시를 정리했습니다",
- "chatAttachmentsClearFailed": "메시지 첨부 파일 캐시를 정리할 수 없습니다. 다시 시도해 주세요.",
- "dbSlimmingBackupDirectoryDialogTitle": "데이터베이스 정리 백업 폴더 선택",
- "dbSlimmingLabel": "데이터베이스 정리",
- "dbSlimmingDescription": "선택한 기간보다 오래 업데이트되지 않은 소프트 삭제 및 보관 작업의 기록을 검사하며, 활성 작업도 선택적으로 포함할 수 있습니다. 확인 후 Cindy를 다시 시작하고 데이터베이스를 열기 전에 기록을 정리하고 압축합니다. 디스크의 첨부 파일과 생성 미디어는 삭제하지 않습니다.",
- "dbSlimmingScanButton": "데이터베이스 검사",
- "dbSlimmingScanLoading": "데이터베이스를 검사하는 중…",
- "dbSlimmingScanResultTitle": "데이터베이스 검사 결과",
- "dbSlimmingExecutionLoading": "데이터베이스 정리를 준비하고 있습니다. Cindy가 곧 다시 시작됩니다…",
- "dbSlimmingArchiveAgeLabel": "다음 기간 동안 업데이트되지 않은 작업 정리",
- "dbSlimmingArchiveAgeOption7Days": "7일",
- "dbSlimmingArchiveAgeOption1": "1개월",
- "dbSlimmingArchiveAgeOption3": "3개월",
- "dbSlimmingArchiveAgeOption6": "6개월",
- "dbSlimmingIncludeActiveLabel": "활성 작업 기록도 정리",
- "dbSlimmingIncludeActiveDescription": "선택한 기간보다 오래된 활성 작업의 기록도 정리합니다",
- "dbSlimmingIncludeActiveConfirmTitle": "활성 작업도 데이터베이스 정리 대상에 포함할까요?",
- "dbSlimmingIncludeActiveConfirmDescription": "선택한 기간보다 오래된 활성 작업도 아직 실행 중일 수 있습니다. 정리는 작업이 중지될 때까지 기다리지 않으며 스캔 후 추가된 메시지도 삭제될 수 있습니다. 사용하면 선택한 기간보다 오래 업데이트되지 않은 활성, 보관 및 소프트 삭제 작업이 정리됩니다. 대상 활성 작업의 기록과 Agent 컨텍스트는 삭제되지만 작업 항목은 유지됩니다. 데이터베이스 백업으로 작업과 메시지 데이터는 복구할 수 있습니다. 백업을 만들지 않으면 해당 데이터도 복구할 수 없습니다. 해당 메시지의 파일 변경 사항을 검토하거나 실행 취소하는 데 사용되는 기록은 데이터베이스 백업에 포함되지 않으며 복구할 수 없습니다.",
- "dbSlimmingIncludeActiveConfirmButton": "활성 작업 포함",
- "dbSlimmingIncludeActiveCancelButton": "활성 작업 유지",
- "dbSlimmingBackupLabel": "정리 전 데이터베이스 백업",
- "dbSlimmingBackupDefaultLocation": "데이터베이스 폴더(최근 정리 백업만 유지)",
- "dbSlimmingUseDefaultDirectoryButton": "기본 폴더 사용",
- "dbSlimmingChooseDirectoryButton": "백업 폴더 선택",
- "dbSlimmingBackupDirectoryFailed": "백업 폴더를 선택할 수 없습니다. 다시 시도해 주세요.",
- "dbSlimmingScanFailed": "데이터베이스를 검사할 수 없습니다. 다시 시도해 주세요.",
- "dbSlimmingScheduleFailed": "데이터베이스 정리를 예약할 수 없습니다. 다시 검사한 후 시도해 주세요.",
- "dbSlimmingBackupMissing": "최근 정리 백업을 찾을 수 없습니다.",
- "dbSlimmingBackupOpenFailed": "정리 백업 위치를 열 수 없습니다. 다시 시도해 주세요.",
- "dbSlimmingReportTasks": "소프트 삭제 작업 {{deleted}}개와 보관된 작업 {{archived}}개를 정리합니다",
- "dbSlimmingReportTasksWithActive": "활성 작업 {{active}}개, 소프트 삭제된 작업 {{deleted}}개, 보관된 작업 {{archived}}개를 정리합니다",
- "dbSlimmingReportMessages": "정리할 메시지 내용: {{count}}개(약 {{size}})",
- "dbSlimmingReportSpace": "데이터베이스 {{database}}, 필요한 임시 공간 최소 {{temporary}}, 사용 가능 {{free}}",
- "dbSlimmingSpaceUnknown": "알 수 없음",
- "dbSlimmingInsufficientSpace": "작업 복사본을 안전하게 만들고 데이터베이스를 압축할 디스크 공간이 부족합니다.",
- "dbSlimmingConfirmButton": "데이터베이스 정리 확인",
- "dbSlimmingConfirmTitle": "다시 시작하고 데이터베이스를 정리할까요?",
- "dbSlimmingConfirmDescriptionWithBackup": "Cindy가 정상적으로 다시 시작된 후 다음 시작 시 데이터베이스를 열기 전에 백업, 기록 정리, 압축, 무결성 검사를 수행합니다. 백업 작성과 검증이 끝난 후에만 데이터를 정리합니다.",
- "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy가 정상적으로 다시 시작된 후 다음 시작 시 데이터베이스를 열기 전에 기록을 정리하고 압축합니다. 이번에는 백업을 만들지 않으며 정리한 기록은 복구할 수 없습니다.",
- "dbSlimmingRestartButton": "다시 시작하고 데이터베이스 정리",
- "dbSlimmingResultCompleted": "{{tasks}}개 작업에서 메시지 {{messages}}개를 정리하고 데이터베이스를 {{size}} 줄였습니다.",
- "dbSlimmingOpenBackupButton": "정리 백업 열기",
- "dbSlimmingToastCompleted": "데이터베이스 정리 완료, {{size}} 확보",
- "dbSlimmingHistoryCleared": "기록이 정리되었습니다",
- "dbSlimmingFailure": {
- "backup-failed": "데이터베이스 백업을 만들거나 유지할 수 없어 기록을 정리하지 않았습니다.",
- "cleanup-failed": "데이터베이스 정리가 완료되지 않았습니다. 원본 데이터베이스는 변경되지 않았습니다.",
- "database-in-use": "다른 인스턴스가 데이터베이스를 사용 중이어서 정리를 실행하지 않았습니다.",
- "insufficient-space": "디스크 공간이 부족해 데이터베이스 정리를 실행하지 않았습니다.",
- "integrity-check-failed": "데이터베이스 무결성 검사에 실패해 원본 데이터베이스를 복원했습니다.",
- "replacement-failed": "압축된 데이터베이스를 설치할 수 없어 원본 데이터베이스를 복원했습니다.",
- "recovery-failed": "데이터베이스 복구에 실패했습니다. 원본 데이터를 보호하기 위해 Cindy가 데이터베이스를 열지 않았습니다.",
- "unknown": "데이터베이스 정리가 완료되지 않았습니다. 다시 시도해 주세요."
- },
+ "chatAttachmentsClearFailed": "메시지 첨부 파일 캐시를 정리할 수 없습니다. 다시 시도해 주세요.",
+ "dbSlimmingBackupDirectoryDialogTitle": "데이터베이스 정리 백업 폴더 선택",
+ "dbSlimmingLabel": "데이터베이스 정리",
+ "dbSlimmingDescription": "선택한 기간보다 오래 업데이트되지 않은 소프트 삭제 및 보관 작업의 기록을 검사하며, 활성 작업도 선택적으로 포함할 수 있습니다. 확인 후 Cindy를 다시 시작하고 데이터베이스를 열기 전에 기록을 정리하고 압축합니다. 디스크의 첨부 파일과 생성 미디어는 삭제하지 않습니다.",
+ "dbSlimmingScanButton": "데이터베이스 검사",
+ "dbSlimmingScanLoading": "데이터베이스를 검사하는 중…",
+ "dbSlimmingScanResultTitle": "데이터베이스 검사 결과",
+ "dbSlimmingExecutionLoading": "데이터베이스 정리를 준비하고 있습니다. Cindy가 곧 다시 시작됩니다…",
+ "dbSlimmingArchiveAgeLabel": "다음 기간 동안 업데이트되지 않은 작업 정리",
+ "dbSlimmingArchiveAgeOption7Days": "7일",
+ "dbSlimmingArchiveAgeOption1": "1개월",
+ "dbSlimmingArchiveAgeOption3": "3개월",
+ "dbSlimmingArchiveAgeOption6": "6개월",
+ "dbSlimmingIncludeActiveLabel": "활성 작업 기록도 정리",
+ "dbSlimmingIncludeActiveDescription": "선택한 기간보다 오래된 활성 작업의 기록도 정리합니다",
+ "dbSlimmingIncludeActiveConfirmTitle": "활성 작업도 데이터베이스 정리 대상에 포함할까요?",
+ "dbSlimmingIncludeActiveConfirmDescription": "선택한 기간보다 오래된 활성 작업도 아직 실행 중일 수 있습니다. 정리는 작업이 중지될 때까지 기다리지 않으며 스캔 후 추가된 메시지도 삭제될 수 있습니다. 사용하면 선택한 기간보다 오래 업데이트되지 않은 활성, 보관 및 소프트 삭제 작업이 정리됩니다. 대상 활성 작업의 기록과 Agent 컨텍스트는 삭제되지만 작업 항목은 유지됩니다. 데이터베이스 백업으로 작업과 메시지 데이터는 복구할 수 있습니다. 백업을 만들지 않으면 해당 데이터도 복구할 수 없습니다. 해당 메시지의 파일 변경 사항을 검토하거나 실행 취소하는 데 사용되는 기록은 데이터베이스 백업에 포함되지 않으며 복구할 수 없습니다.",
+ "dbSlimmingIncludeActiveConfirmButton": "활성 작업 포함",
+ "dbSlimmingIncludeActiveCancelButton": "활성 작업 유지",
+ "dbSlimmingBackupLabel": "정리 전 데이터베이스 백업",
+ "dbSlimmingBackupDefaultLocation": "데이터베이스 폴더(최근 정리 백업만 유지)",
+ "dbSlimmingUseDefaultDirectoryButton": "기본 폴더 사용",
+ "dbSlimmingChooseDirectoryButton": "백업 폴더 선택",
+ "dbSlimmingBackupDirectoryFailed": "백업 폴더를 선택할 수 없습니다. 다시 시도해 주세요.",
+ "dbSlimmingScanFailed": "데이터베이스를 검사할 수 없습니다. 다시 시도해 주세요.",
+ "dbSlimmingScheduleFailed": "데이터베이스 정리를 예약할 수 없습니다. 다시 검사한 후 시도해 주세요.",
+ "dbSlimmingBackupMissing": "최근 정리 백업을 찾을 수 없습니다.",
+ "dbSlimmingBackupOpenFailed": "정리 백업 위치를 열 수 없습니다. 다시 시도해 주세요.",
+ "dbSlimmingReportTasks": "소프트 삭제 작업 {{deleted}}개와 보관된 작업 {{archived}}개를 정리합니다",
+ "dbSlimmingReportTasksWithActive": "활성 작업 {{active}}개, 소프트 삭제된 작업 {{deleted}}개, 보관된 작업 {{archived}}개를 정리합니다",
+ "dbSlimmingReportMessages": "정리할 메시지 내용: {{count}}개(약 {{size}})",
+ "dbSlimmingReportSpace": "데이터베이스 {{database}}, 필요한 임시 공간 최소 {{temporary}}, 사용 가능 {{free}}",
+ "dbSlimmingSpaceUnknown": "알 수 없음",
+ "dbSlimmingInsufficientSpace": "작업 복사본을 안전하게 만들고 데이터베이스를 압축할 디스크 공간이 부족합니다.",
+ "dbSlimmingConfirmButton": "데이터베이스 정리 확인",
+ "dbSlimmingConfirmTitle": "다시 시작하고 데이터베이스를 정리할까요?",
+ "dbSlimmingConfirmDescriptionWithBackup": "Cindy가 정상적으로 다시 시작된 후 다음 시작 시 데이터베이스를 열기 전에 백업, 기록 정리, 압축, 무결성 검사를 수행합니다. 백업 작성과 검증이 끝난 후에만 데이터를 정리합니다.",
+ "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy가 정상적으로 다시 시작된 후 다음 시작 시 데이터베이스를 열기 전에 기록을 정리하고 압축합니다. 이번에는 백업을 만들지 않으며 정리한 기록은 복구할 수 없습니다.",
+ "dbSlimmingRestartButton": "다시 시작하고 데이터베이스 정리",
+ "dbSlimmingResultCompleted": "{{tasks}}개 작업에서 메시지 {{messages}}개를 정리하고 데이터베이스를 {{size}} 줄였습니다.",
+ "dbSlimmingOpenBackupButton": "정리 백업 열기",
+ "dbSlimmingToastCompleted": "데이터베이스 정리 완료, {{size}} 확보",
+ "dbSlimmingHistoryCleared": "기록이 정리되었습니다",
+ "dbSlimmingFailure": {
+ "backup-failed": "데이터베이스 백업을 만들거나 유지할 수 없어 기록을 정리하지 않았습니다.",
+ "cleanup-failed": "데이터베이스 정리가 완료되지 않았습니다. 원본 데이터베이스는 변경되지 않았습니다.",
+ "database-in-use": "다른 인스턴스가 데이터베이스를 사용 중이어서 정리를 실행하지 않았습니다.",
+ "insufficient-space": "디스크 공간이 부족해 데이터베이스 정리를 실행하지 않았습니다.",
+ "integrity-check-failed": "데이터베이스 무결성 검사에 실패해 원본 데이터베이스를 복원했습니다.",
+ "replacement-failed": "압축된 데이터베이스를 설치할 수 없어 원본 데이터베이스를 복원했습니다.",
+ "recovery-failed": "데이터베이스 복구에 실패했습니다. 원본 데이터를 보호하기 위해 Cindy가 데이터베이스를 열지 않았습니다.",
+ "unknown": "데이터베이스 정리가 완료되지 않았습니다. 다시 시도해 주세요."
+ },
"cleanupLabel": "디스크 정리",
"cleanupDescription": "어떤 세션에서도 참조하지 않는 미디어 파일, 한도를 초과한 캐시, 사용하지 않는 폴더를 검사합니다. 먼저 수치를 보여주고 확인 후에만 삭제합니다. 입력창 초안과 대기 중인 메시지의 이미지는 자동으로 보호됩니다.",
"scanButton": "검사",
@@ -1458,6 +1458,8 @@
"copyKeyFailed": "복사에 실패했습니다. 나중에 다시 시도해 주세요",
"asset": {
"viewUsage": "사용량 보기",
+ "buyPlan": "요금제 구매",
+ "upgradePlan": "요금제 업그레이드",
"syncFailed": "자격 증명 동기화에 실패해 잔액을 가져올 수 없습니다. 저장된 모델 설정은 영향을 받지 않습니다."
}
},
@@ -8200,7 +8202,13 @@
"showLess": "간략히 보기",
"artifactLabel": "산출물",
"formats": { "pdf": "PDF", "docx": "Word", "pptx": "PPT", "xlsx": "Excel" },
- "summary": { "pages": "{{count}}페이지", "slides": "{{count}}개 슬라이드", "sheets": "{{count}}개 시트", "rows": "{{count}}행", "bytes": "{{count}}" }
+ "summary": {
+ "pages": "{{count}}페이지",
+ "slides": "{{count}}개 슬라이드",
+ "sheets": "{{count}}개 시트",
+ "rows": "{{count}}행",
+ "bytes": "{{count}}"
+ }
},
"turnChanges": {
"title": "파일 {{count}}개 변경",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 02fcd46010..d1b4f27d21 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -849,61 +849,61 @@
"chatAttachmentsClearConfirmTitle": "清理消息附件缓存?",
"chatAttachmentsClearConfirmDescription": "只会删除消息附件缓存目录中的文件,不会读取消息数据库。清理后,历史消息中的部分附件可能无法打开,且无法恢复。",
"chatAttachmentsClearConfirmButton": "清理附件缓存",
- "chatAttachmentsCleared": "消息附件缓存已清理",
- "chatAttachmentsClearFailed": "无法清理消息附件缓存,请重试",
- "dbSlimmingBackupDirectoryDialogTitle": "选择数据库清理备份目录",
- "dbSlimmingLabel": "数据库清理",
- "dbSlimmingDescription": "扫描超过所选时间未更新的软删除和已归档任务历史,可选择同时纳入活跃任务。确认后重启 Cindy,在数据库打开前清理并压缩。不会删除磁盘附件或生成媒体。",
- "dbSlimmingScanButton": "扫描数据库",
- "dbSlimmingScanLoading": "正在扫描数据库,请稍候…",
- "dbSlimmingScanResultTitle": "数据库扫描结果",
- "dbSlimmingExecutionLoading": "正在准备数据库清理,Cindy 即将重启…",
- "dbSlimmingArchiveAgeLabel": "清理未更新时间超过",
- "dbSlimmingArchiveAgeOption7Days": "7 天",
- "dbSlimmingArchiveAgeOption1": "1 个月",
- "dbSlimmingArchiveAgeOption3": "3 个月",
- "dbSlimmingArchiveAgeOption6": "6 个月",
- "dbSlimmingIncludeActiveLabel": "清理活跃任务历史",
- "dbSlimmingIncludeActiveDescription": "同时清理超过所选时间的活跃任务历史",
- "dbSlimmingIncludeActiveConfirmTitle": "将活跃任务纳入数据库清理?",
- "dbSlimmingIncludeActiveConfirmDescription": "活跃任务即使超过所选时间,也可能仍在运行。清理不会等待任务停止,任务在扫描后继续产生的消息也可能被清除。启用后,超过所选时间的活跃、已归档和软删除任务都会被清理。符合范围的活跃任务历史消息和 Agent 上下文将被清除;任务条目仍会保留。数据库备份可以恢复任务和消息数据;不创建备份时,这些数据也无法恢复。用于审查或撤销这些消息所产生文件改动的记录不包含在数据库备份中,无法恢复。",
- "dbSlimmingIncludeActiveConfirmButton": "纳入活跃任务",
- "dbSlimmingIncludeActiveCancelButton": "保留活跃任务",
- "dbSlimmingBackupLabel": "清理前备份数据库",
- "dbSlimmingBackupDefaultLocation": "数据库所在目录(只保留最近一次清理备份)",
- "dbSlimmingUseDefaultDirectoryButton": "使用默认目录",
- "dbSlimmingChooseDirectoryButton": "选择备份目录",
- "dbSlimmingBackupDirectoryFailed": "无法选择备份目录,请重试",
- "dbSlimmingScanFailed": "无法扫描数据库,请重试",
- "dbSlimmingScheduleFailed": "无法安排数据库清理,请重新扫描后重试",
- "dbSlimmingBackupMissing": "没有找到最近一次清理备份",
- "dbSlimmingBackupOpenFailed": "无法打开清理备份位置,请重试",
- "dbSlimmingReportTasks": "将清理软删除任务 {{deleted}} 个、归档任务 {{archived}} 个",
- "dbSlimmingReportTasksWithActive": "将清理活跃任务 {{active}} 个、软删除任务 {{deleted}} 个、归档任务 {{archived}} 个",
- "dbSlimmingReportMessages": "预计清理 {{count}} 条消息内容(约 {{size}})",
- "dbSlimmingReportSpace": "数据库 {{database}};临时空间至少需要 {{temporary}};当前可用 {{free}}",
- "dbSlimmingSpaceUnknown": "未知",
- "dbSlimmingInsufficientSpace": "当前磁盘空间不足,无法安全创建工作副本并压缩数据库。",
- "dbSlimmingConfirmButton": "确认数据库清理",
- "dbSlimmingConfirmTitle": "重启并清理数据库?",
- "dbSlimmingConfirmDescriptionWithBackup": "Cindy 将优雅重启,并在下次启动、数据库打开前完成备份、历史清理、压缩和完整性校验。备份写入并校验通过后才会清理数据。",
- "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy 将优雅重启,并在下次启动、数据库打开前清理和压缩。本次不创建备份,清除的历史内容无法恢复。",
- "dbSlimmingRestartButton": "重启并清理数据库",
- "dbSlimmingResultCompleted": "已清除 {{tasks}} 个任务中的 {{messages}} 条消息,数据库缩小 {{size}}。",
- "dbSlimmingOpenBackupButton": "打开清理备份",
- "dbSlimmingToastCompleted": "数据库清理完成,已释放 {{size}}",
- "dbSlimmingHistoryCleared": "历史内容已清除",
- "dbSlimmingFailure": {
- "backup-failed": "未能创建或保留数据库备份,未清理历史内容。",
- "cleanup-failed": "数据库清理未完成,原数据库保持不变。",
- "database-in-use": "数据库正被其他实例使用,未执行清理。",
- "insufficient-space": "磁盘空间不足,未执行数据库清理。",
- "integrity-check-failed": "数据库完整性校验未通过,已恢复原数据库。",
- "replacement-failed": "无法安装压缩后的数据库,已恢复原数据库。",
- "recovery-failed": "数据库恢复失败,Cindy 已停止打开数据库以保护原始数据。",
- "unknown": "数据库清理未完成,请重试。"
- },
- "cleanupLabel": "磁盘清理",
+ "chatAttachmentsCleared": "消息附件缓存已清理",
+ "chatAttachmentsClearFailed": "无法清理消息附件缓存,请重试",
+ "dbSlimmingBackupDirectoryDialogTitle": "选择数据库清理备份目录",
+ "dbSlimmingLabel": "数据库清理",
+ "dbSlimmingDescription": "扫描超过所选时间未更新的软删除和已归档任务历史,可选择同时纳入活跃任务。确认后重启 Cindy,在数据库打开前清理并压缩。不会删除磁盘附件或生成媒体。",
+ "dbSlimmingScanButton": "扫描数据库",
+ "dbSlimmingScanLoading": "正在扫描数据库,请稍候…",
+ "dbSlimmingScanResultTitle": "数据库扫描结果",
+ "dbSlimmingExecutionLoading": "正在准备数据库清理,Cindy 即将重启…",
+ "dbSlimmingArchiveAgeLabel": "清理未更新时间超过",
+ "dbSlimmingArchiveAgeOption7Days": "7 天",
+ "dbSlimmingArchiveAgeOption1": "1 个月",
+ "dbSlimmingArchiveAgeOption3": "3 个月",
+ "dbSlimmingArchiveAgeOption6": "6 个月",
+ "dbSlimmingIncludeActiveLabel": "清理活跃任务历史",
+ "dbSlimmingIncludeActiveDescription": "同时清理超过所选时间的活跃任务历史",
+ "dbSlimmingIncludeActiveConfirmTitle": "将活跃任务纳入数据库清理?",
+ "dbSlimmingIncludeActiveConfirmDescription": "活跃任务即使超过所选时间,也可能仍在运行。清理不会等待任务停止,任务在扫描后继续产生的消息也可能被清除。启用后,超过所选时间的活跃、已归档和软删除任务都会被清理。符合范围的活跃任务历史消息和 Agent 上下文将被清除;任务条目仍会保留。数据库备份可以恢复任务和消息数据;不创建备份时,这些数据也无法恢复。用于审查或撤销这些消息所产生文件改动的记录不包含在数据库备份中,无法恢复。",
+ "dbSlimmingIncludeActiveConfirmButton": "纳入活跃任务",
+ "dbSlimmingIncludeActiveCancelButton": "保留活跃任务",
+ "dbSlimmingBackupLabel": "清理前备份数据库",
+ "dbSlimmingBackupDefaultLocation": "数据库所在目录(只保留最近一次清理备份)",
+ "dbSlimmingUseDefaultDirectoryButton": "使用默认目录",
+ "dbSlimmingChooseDirectoryButton": "选择备份目录",
+ "dbSlimmingBackupDirectoryFailed": "无法选择备份目录,请重试",
+ "dbSlimmingScanFailed": "无法扫描数据库,请重试",
+ "dbSlimmingScheduleFailed": "无法安排数据库清理,请重新扫描后重试",
+ "dbSlimmingBackupMissing": "没有找到最近一次清理备份",
+ "dbSlimmingBackupOpenFailed": "无法打开清理备份位置,请重试",
+ "dbSlimmingReportTasks": "将清理软删除任务 {{deleted}} 个、归档任务 {{archived}} 个",
+ "dbSlimmingReportTasksWithActive": "将清理活跃任务 {{active}} 个、软删除任务 {{deleted}} 个、归档任务 {{archived}} 个",
+ "dbSlimmingReportMessages": "预计清理 {{count}} 条消息内容(约 {{size}})",
+ "dbSlimmingReportSpace": "数据库 {{database}};临时空间至少需要 {{temporary}};当前可用 {{free}}",
+ "dbSlimmingSpaceUnknown": "未知",
+ "dbSlimmingInsufficientSpace": "当前磁盘空间不足,无法安全创建工作副本并压缩数据库。",
+ "dbSlimmingConfirmButton": "确认数据库清理",
+ "dbSlimmingConfirmTitle": "重启并清理数据库?",
+ "dbSlimmingConfirmDescriptionWithBackup": "Cindy 将优雅重启,并在下次启动、数据库打开前完成备份、历史清理、压缩和完整性校验。备份写入并校验通过后才会清理数据。",
+ "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy 将优雅重启,并在下次启动、数据库打开前清理和压缩。本次不创建备份,清除的历史内容无法恢复。",
+ "dbSlimmingRestartButton": "重启并清理数据库",
+ "dbSlimmingResultCompleted": "已清除 {{tasks}} 个任务中的 {{messages}} 条消息,数据库缩小 {{size}}。",
+ "dbSlimmingOpenBackupButton": "打开清理备份",
+ "dbSlimmingToastCompleted": "数据库清理完成,已释放 {{size}}",
+ "dbSlimmingHistoryCleared": "历史内容已清除",
+ "dbSlimmingFailure": {
+ "backup-failed": "未能创建或保留数据库备份,未清理历史内容。",
+ "cleanup-failed": "数据库清理未完成,原数据库保持不变。",
+ "database-in-use": "数据库正被其他实例使用,未执行清理。",
+ "insufficient-space": "磁盘空间不足,未执行数据库清理。",
+ "integrity-check-failed": "数据库完整性校验未通过,已恢复原数据库。",
+ "replacement-failed": "无法安装压缩后的数据库,已恢复原数据库。",
+ "recovery-failed": "数据库恢复失败,Cindy 已停止打开数据库以保护原始数据。",
+ "unknown": "数据库清理未完成,请重试。"
+ },
+ "cleanupLabel": "磁盘清理",
"cleanupDescription": "扫描没有被任何任务引用的媒体文件、超限缓存与废弃目录。先报数,确认后才删除;输入框草稿和排队消息里的图片会被自动保护。",
"scanButton": "扫描",
"scanFailed": "扫描失败",
@@ -1458,6 +1458,8 @@
"copyKeyFailed": "复制失败,请稍后重试",
"asset": {
"viewUsage": "查看用量",
+ "buyPlan": "购买套餐",
+ "upgradePlan": "升级套餐",
"syncFailed": "凭据同步失败,暂时无法获取余额。已保存的模型配置不受影响。"
}
},
@@ -8192,7 +8194,13 @@
"showLess": "收起",
"artifactLabel": "成品",
"formats": { "pdf": "PDF", "docx": "Word", "pptx": "PPT", "xlsx": "Excel" },
- "summary": { "pages": "{{count}} 页", "slides": "{{count}} 张幻灯片", "sheets": "{{count}} 个工作表", "rows": "{{count}} 行", "bytes": "{{count}}" }
+ "summary": {
+ "pages": "{{count}} 页",
+ "slides": "{{count}} 张幻灯片",
+ "sheets": "{{count}} 个工作表",
+ "rows": "{{count}} 行",
+ "bytes": "{{count}}"
+ }
},
"turnChanges": {
"title": "已更改 {{count}} 个文件",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index fd24cfe9f6..320978577d 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -849,61 +849,61 @@
"chatAttachmentsClearConfirmTitle": "清理訊息附件快取?",
"chatAttachmentsClearConfirmDescription": "只會刪除訊息附件快取目錄中的檔案,不會讀取訊息資料庫。清理後,歷史訊息中的部分附件可能無法開啟,且無法復原。",
"chatAttachmentsClearConfirmButton": "清理附件快取",
- "chatAttachmentsCleared": "訊息附件快取已清理",
- "chatAttachmentsClearFailed": "無法清理訊息附件快取,請重試",
- "dbSlimmingBackupDirectoryDialogTitle": "選擇資料庫清理備份目錄",
- "dbSlimmingLabel": "資料庫清理",
- "dbSlimmingDescription": "掃描超過所選時間未更新的軟刪除和已封存任務歷史,可選擇同時納入活躍任務。確認後重新啟動 Cindy,在資料庫開啟前清理並壓縮。不會刪除磁碟附件或生成媒體。",
- "dbSlimmingScanButton": "掃描資料庫",
- "dbSlimmingScanLoading": "正在掃描資料庫,請稍候…",
- "dbSlimmingScanResultTitle": "資料庫掃描結果",
- "dbSlimmingExecutionLoading": "正在準備資料庫清理,Cindy 即將重新啟動…",
- "dbSlimmingArchiveAgeLabel": "清理未更新時間超過",
- "dbSlimmingArchiveAgeOption7Days": "7 天",
- "dbSlimmingArchiveAgeOption1": "1 個月",
- "dbSlimmingArchiveAgeOption3": "3 個月",
- "dbSlimmingArchiveAgeOption6": "6 個月",
- "dbSlimmingIncludeActiveLabel": "清理活躍任務歷史",
- "dbSlimmingIncludeActiveDescription": "同時清理超過所選時間的活躍任務歷史",
- "dbSlimmingIncludeActiveConfirmTitle": "將活躍任務納入資料庫清理?",
- "dbSlimmingIncludeActiveConfirmDescription": "活躍任務即使超過所選時間,也可能仍在執行。清理不會等待任務停止,任務在掃描後繼續產生的訊息也可能被清除。啟用後,超過所選時間的活躍、已封存和軟刪除任務都會被清理。符合範圍的活躍任務歷史訊息和 Agent 上下文將被清除;任務項目仍會保留。資料庫備份可以復原任務和訊息資料;不建立備份時,這些資料也無法復原。用於審查或撤銷這些訊息所產生檔案變更的記錄不包含在資料庫備份中,無法復原。",
- "dbSlimmingIncludeActiveConfirmButton": "納入活躍任務",
- "dbSlimmingIncludeActiveCancelButton": "保留活躍任務",
- "dbSlimmingBackupLabel": "清理前備份資料庫",
- "dbSlimmingBackupDefaultLocation": "資料庫所在目錄(只保留最近一次清理備份)",
- "dbSlimmingUseDefaultDirectoryButton": "使用預設目錄",
- "dbSlimmingChooseDirectoryButton": "選擇備份目錄",
- "dbSlimmingBackupDirectoryFailed": "無法選擇備份目錄,請重試",
- "dbSlimmingScanFailed": "無法掃描資料庫,請重試",
- "dbSlimmingScheduleFailed": "無法安排資料庫清理,請重新掃描後重試",
- "dbSlimmingBackupMissing": "找不到最近一次清理備份",
- "dbSlimmingBackupOpenFailed": "無法開啟清理備份位置,請重試",
- "dbSlimmingReportTasks": "將清理軟刪除任務 {{deleted}} 個、封存任務 {{archived}} 個",
- "dbSlimmingReportTasksWithActive": "將清理活躍任務 {{active}} 個、軟刪除任務 {{deleted}} 個、封存任務 {{archived}} 個",
- "dbSlimmingReportMessages": "預計清理 {{count}} 則訊息內容(約 {{size}})",
- "dbSlimmingReportSpace": "資料庫 {{database}};暫存空間至少需要 {{temporary}};目前可用 {{free}}",
- "dbSlimmingSpaceUnknown": "未知",
- "dbSlimmingInsufficientSpace": "目前磁碟空間不足,無法安全建立工作副本並壓縮資料庫。",
- "dbSlimmingConfirmButton": "確認資料庫清理",
- "dbSlimmingConfirmTitle": "重新啟動並清理資料庫?",
- "dbSlimmingConfirmDescriptionWithBackup": "Cindy 將正常重新啟動,並在下次啟動、資料庫開啟前完成備份、歷史清理、壓縮和完整性檢查。備份寫入並通過檢查後才會清理資料。",
- "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy 將正常重新啟動,並在下次啟動、資料庫開啟前清理和壓縮。本次不建立備份,清除的歷史內容無法復原。",
- "dbSlimmingRestartButton": "重新啟動並清理資料庫",
- "dbSlimmingResultCompleted": "已清除 {{tasks}} 個任務中的 {{messages}} 則訊息,資料庫縮小 {{size}}。",
- "dbSlimmingOpenBackupButton": "開啟清理備份",
- "dbSlimmingToastCompleted": "資料庫清理完成,已釋放 {{size}}",
- "dbSlimmingHistoryCleared": "歷史內容已清除",
- "dbSlimmingFailure": {
- "backup-failed": "未能建立或保留資料庫備份,未清理歷史內容。",
- "cleanup-failed": "資料庫清理未完成,原資料庫保持不變。",
- "database-in-use": "資料庫正被其他執行個體使用,未執行清理。",
- "insufficient-space": "磁碟空間不足,未執行資料庫清理。",
- "integrity-check-failed": "資料庫完整性檢查未通過,已復原原資料庫。",
- "replacement-failed": "無法安裝壓縮後的資料庫,已復原原資料庫。",
- "recovery-failed": "資料庫復原失敗,Cindy 已停止開啟資料庫以保護原始資料。",
- "unknown": "資料庫清理未完成,請重試。"
- },
- "cleanupLabel": "磁碟清理",
+ "chatAttachmentsCleared": "訊息附件快取已清理",
+ "chatAttachmentsClearFailed": "無法清理訊息附件快取,請重試",
+ "dbSlimmingBackupDirectoryDialogTitle": "選擇資料庫清理備份目錄",
+ "dbSlimmingLabel": "資料庫清理",
+ "dbSlimmingDescription": "掃描超過所選時間未更新的軟刪除和已封存任務歷史,可選擇同時納入活躍任務。確認後重新啟動 Cindy,在資料庫開啟前清理並壓縮。不會刪除磁碟附件或生成媒體。",
+ "dbSlimmingScanButton": "掃描資料庫",
+ "dbSlimmingScanLoading": "正在掃描資料庫,請稍候…",
+ "dbSlimmingScanResultTitle": "資料庫掃描結果",
+ "dbSlimmingExecutionLoading": "正在準備資料庫清理,Cindy 即將重新啟動…",
+ "dbSlimmingArchiveAgeLabel": "清理未更新時間超過",
+ "dbSlimmingArchiveAgeOption7Days": "7 天",
+ "dbSlimmingArchiveAgeOption1": "1 個月",
+ "dbSlimmingArchiveAgeOption3": "3 個月",
+ "dbSlimmingArchiveAgeOption6": "6 個月",
+ "dbSlimmingIncludeActiveLabel": "清理活躍任務歷史",
+ "dbSlimmingIncludeActiveDescription": "同時清理超過所選時間的活躍任務歷史",
+ "dbSlimmingIncludeActiveConfirmTitle": "將活躍任務納入資料庫清理?",
+ "dbSlimmingIncludeActiveConfirmDescription": "活躍任務即使超過所選時間,也可能仍在執行。清理不會等待任務停止,任務在掃描後繼續產生的訊息也可能被清除。啟用後,超過所選時間的活躍、已封存和軟刪除任務都會被清理。符合範圍的活躍任務歷史訊息和 Agent 上下文將被清除;任務項目仍會保留。資料庫備份可以復原任務和訊息資料;不建立備份時,這些資料也無法復原。用於審查或撤銷這些訊息所產生檔案變更的記錄不包含在資料庫備份中,無法復原。",
+ "dbSlimmingIncludeActiveConfirmButton": "納入活躍任務",
+ "dbSlimmingIncludeActiveCancelButton": "保留活躍任務",
+ "dbSlimmingBackupLabel": "清理前備份資料庫",
+ "dbSlimmingBackupDefaultLocation": "資料庫所在目錄(只保留最近一次清理備份)",
+ "dbSlimmingUseDefaultDirectoryButton": "使用預設目錄",
+ "dbSlimmingChooseDirectoryButton": "選擇備份目錄",
+ "dbSlimmingBackupDirectoryFailed": "無法選擇備份目錄,請重試",
+ "dbSlimmingScanFailed": "無法掃描資料庫,請重試",
+ "dbSlimmingScheduleFailed": "無法安排資料庫清理,請重新掃描後重試",
+ "dbSlimmingBackupMissing": "找不到最近一次清理備份",
+ "dbSlimmingBackupOpenFailed": "無法開啟清理備份位置,請重試",
+ "dbSlimmingReportTasks": "將清理軟刪除任務 {{deleted}} 個、封存任務 {{archived}} 個",
+ "dbSlimmingReportTasksWithActive": "將清理活躍任務 {{active}} 個、軟刪除任務 {{deleted}} 個、封存任務 {{archived}} 個",
+ "dbSlimmingReportMessages": "預計清理 {{count}} 則訊息內容(約 {{size}})",
+ "dbSlimmingReportSpace": "資料庫 {{database}};暫存空間至少需要 {{temporary}};目前可用 {{free}}",
+ "dbSlimmingSpaceUnknown": "未知",
+ "dbSlimmingInsufficientSpace": "目前磁碟空間不足,無法安全建立工作副本並壓縮資料庫。",
+ "dbSlimmingConfirmButton": "確認資料庫清理",
+ "dbSlimmingConfirmTitle": "重新啟動並清理資料庫?",
+ "dbSlimmingConfirmDescriptionWithBackup": "Cindy 將正常重新啟動,並在下次啟動、資料庫開啟前完成備份、歷史清理、壓縮和完整性檢查。備份寫入並通過檢查後才會清理資料。",
+ "dbSlimmingConfirmDescriptionWithoutBackup": "Cindy 將正常重新啟動,並在下次啟動、資料庫開啟前清理和壓縮。本次不建立備份,清除的歷史內容無法復原。",
+ "dbSlimmingRestartButton": "重新啟動並清理資料庫",
+ "dbSlimmingResultCompleted": "已清除 {{tasks}} 個任務中的 {{messages}} 則訊息,資料庫縮小 {{size}}。",
+ "dbSlimmingOpenBackupButton": "開啟清理備份",
+ "dbSlimmingToastCompleted": "資料庫清理完成,已釋放 {{size}}",
+ "dbSlimmingHistoryCleared": "歷史內容已清除",
+ "dbSlimmingFailure": {
+ "backup-failed": "未能建立或保留資料庫備份,未清理歷史內容。",
+ "cleanup-failed": "資料庫清理未完成,原資料庫保持不變。",
+ "database-in-use": "資料庫正被其他執行個體使用,未執行清理。",
+ "insufficient-space": "磁碟空間不足,未執行資料庫清理。",
+ "integrity-check-failed": "資料庫完整性檢查未通過,已復原原資料庫。",
+ "replacement-failed": "無法安裝壓縮後的資料庫,已復原原資料庫。",
+ "recovery-failed": "資料庫復原失敗,Cindy 已停止開啟資料庫以保護原始資料。",
+ "unknown": "資料庫清理未完成,請重試。"
+ },
+ "cleanupLabel": "磁碟清理",
"cleanupDescription": "掃描沒有被任何任務引用的媒體檔案、超限快取與廢棄目錄。先報數,確認後才刪除;輸入框草稿和排隊訊息裡的圖片會被自動保護。",
"scanButton": "掃描",
"scanFailed": "掃描失敗",
@@ -1458,6 +1458,8 @@
"copyKeyFailed": "複製失敗,請稍後重試",
"asset": {
"viewUsage": "檢視用量",
+ "buyPlan": "購買套餐",
+ "upgradePlan": "升級套餐",
"syncFailed": "憑據同步失敗,暫時無法獲取餘額。已儲存的模型配置不受影響。"
}
},
@@ -8191,7 +8193,13 @@
"showLess": "收起",
"artifactLabel": "成品",
"formats": { "pdf": "PDF", "docx": "Word", "pptx": "PPT", "xlsx": "Excel" },
- "summary": { "pages": "{{count}} 頁", "slides": "{{count}} 張投影片", "sheets": "{{count}} 個工作表", "rows": "{{count}} 列", "bytes": "{{count}}" }
+ "summary": {
+ "pages": "{{count}} 頁",
+ "slides": "{{count}} 張投影片",
+ "sheets": "{{count}} 個工作表",
+ "rows": "{{count}} 列",
+ "bytes": "{{count}}"
+ }
},
"turnChanges": {
"title": "已更改 {{count}} 個檔案",
diff --git a/apps/desktop/src/shared/billing.ts b/apps/desktop/src/shared/billing.ts
index 186b99948d..7c56d7a355 100644
--- a/apps/desktop/src/shared/billing.ts
+++ b/apps/desktop/src/shared/billing.ts
@@ -35,8 +35,7 @@ export type BillingPaymentAction =
| { type: 'REDIRECT'; url: string; expiresAt: string };
export type BillingSubscriptionPortalResult =
- | { success: true }
- | { success: false; timedOut?: true };
+ { success: true } | { success: false; timedOut?: true };
export type BillingFulfillmentStatus = 'NOT_STARTED' | 'PENDING' | 'SUCCEEDED' | 'FAILED';
@@ -118,6 +117,14 @@ export type BillingSubscriptionStatus =
| 'CANCELED'
| 'PAUSED';
+/**
+ * 这些状态视为已有生效订阅:计费页阻断再买新套餐;供应商页据此把右侧主动作从
+ * 「购买套餐」换成「升级套餐」或「余额充值」。INCOMPLETE / INCOMPLETE_EXPIRED 属于
+ * 未完成首购,只活在当前 checkout 会话里,不算。
+ */
+export const BILLING_SUBSCRIPTION_PURCHASE_BLOCKING_STATUSES: readonly BillingSubscriptionStatus[] =
+ ['TRIALING', 'ACTIVE', 'PAST_DUE', 'UNPAID', 'PAUSED'];
+
export type BillingPlanChangeType = 'UPGRADE' | 'DOWNGRADE';
/**
diff --git a/apps/desktop/vite.main.config.ts b/apps/desktop/vite.main.config.ts
index 2cb2fcfad2..9c13839c05 100644
--- a/apps/desktop/vite.main.config.ts
+++ b/apps/desktop/vite.main.config.ts
@@ -25,8 +25,8 @@ export default defineConfig(({ mode }) => {
const readMainEnv = (key: string): string => allEnv[key] || process.env[key] || '';
const readMainEnvPreservingEmpty = (key: string): string =>
Object.prototype.hasOwnProperty.call(process.env, key)
- ? process.env[key] ?? ''
- : allEnv[key] ?? '';
+ ? (process.env[key] ?? '')
+ : (allEnv[key] ?? '');
return {
resolve: {
// 仅 fixtures 生产排除条件(v6.17 允许范围):production 构建把
@@ -135,6 +135,13 @@ export default defineConfig(({ mode }) => {
// Electron's unpatched filesystem implementation. The legacy userData
// migration needs physical .asar files to remain ordinary files.
'original-fs',
+ // node:sqlite is a Node 24 / Electron 41 builtin. The Vite process that
+ // bundles main may still be Node 22, whose builtinModules list does not
+ // include sqlite, so Vite stubs the specifier as
+ // `__vite-browser-external`. Named imports like `backup` then fail and
+ // a cold dev start never reaches ready-to-show.
+ 'sqlite',
+ 'node:sqlite',
'bufferutil',
'utf-8-validate',
'better-sqlite3',