Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(subscription): merge Usage and Balance into one settings page (#22985)

YuTengjing36fdee8e81c2
diff --git a/locales/en-US/subscription.json b/locales/en-US/subscription.json
index e27726091ac..0b8c3ea0750 100644
--- a/locales/en-US/subscription.json
+++ b/locales/en-US/subscription.json
@@ -96,10 +96,32 @@
"credits.agentShareBudget.saveSuccess": "Agent Share budget policy saved",
"credits.agentShareBudget.title": "External agent sharing",
"credits.agentShareBudget.unlimited": "No workspace-wide cap",
+ "credits.autoTopUp.adjust": "Adjust",
"credits.autoTopUp.cardBindingGiftHint": "Add your first payment method and get $1 free",
+ "credits.autoTopUp.collapse": "Collapse",
"credits.autoTopUp.currentBalance": "Current balance",
"credits.autoTopUp.desc": "Ensure your balance never runs out",
"credits.autoTopUp.descUsd": "Make sure your balance never runs out",
+ "credits.autoTopUp.disabled": "Auto top-up is off",
+ "credits.autoTopUp.enable.addPaymentMethod": "Add a card",
+ "credits.autoTopUp.enable.chargeFailed": "Auto top-up is on, but this charge failed. Check your payment method.",
+ "credits.autoTopUp.enable.chargeNow": "Your balance is {{balance}}, at or below {{threshold}}. Turning this on charges {{amount}} now to bring it to {{target}}.",
+ "credits.autoTopUp.enable.chargeNowCapped": "Your balance is {{balance}}, at or below {{threshold}}. Turning this on charges {{amount}} now, all that this month's limit has left, bringing it to {{newBalance}}.",
+ "credits.autoTopUp.enable.desc": "When your balance runs low, it is refilled from your saved payment method, so requests keep going after your plan limits run out. You can turn it off anytime.",
+ "credits.autoTopUp.enable.failed": "Couldn't turn on auto top-up. Please try again.",
+ "credits.autoTopUp.enable.giftBadge": "$1 free for your first card",
+ "credits.autoTopUp.enable.limitReached": "Auto top-up is on, but this month's charge limit is reached, so nothing was added.",
+ "credits.autoTopUp.enable.limitReachedNow": "Your balance is {{balance}}, at or below {{threshold}}, but this month's limit is used up, so nothing is charged now.",
+ "credits.autoTopUp.enable.noChargeNow": "Your balance is {{balance}}, above {{threshold}}, so nothing is charged now. Auto top-up runs once it drops to {{threshold}}.",
+ "credits.autoTopUp.enable.noPaymentMethod": "Add a card first",
+ "credits.autoTopUp.enable.overflowNote": "This also turns on \"{{overflow}}\". Without it, requests stop at your plan limits and auto top-up never runs.",
+ "credits.autoTopUp.enable.paymentMethod": "Payment method",
+ "credits.autoTopUp.enable.submit": "Turn on auto top-up",
+ "credits.autoTopUp.enable.submitAndCharge": "Turn on and pay {{amount}}",
+ "credits.autoTopUp.enable.success": "Auto top-up is on",
+ "credits.autoTopUp.enable.successCharged": "Auto top-up is on. {{amount}} was added.",
+ "credits.autoTopUp.enable.title": "Turn on auto top-up",
+ "credits.autoTopUp.enable.waitingForPaymentMethod": "Add the card in the new tab, then come back here to turn it on.",
"credits.autoTopUp.monthlyLimit": "Monthly limit",
"credits.autoTopUp.monthlyLimitDesc": "Maximum amount that can be auto-charged per month. Leave empty for no limit",
"credits.autoTopUp.monthlyLimitPlaceholder": "No limit",
@@ -107,9 +129,15 @@
"credits.autoTopUp.noCustomerHint": "Top up once to save a payment method before enabling auto top-up.",
"credits.autoTopUp.noPaymentMethodHint": "No payment method on file. Auto top-up needs a saved card to charge automatically.",
"credits.autoTopUp.purchaseCredits": "Top up",
+ "credits.autoTopUp.recommended": "Recommended",
"credits.autoTopUp.saveError": "Failed to save auto top-up settings",
"credits.autoTopUp.saveSuccess": "Auto top-up settings saved",
+ "credits.autoTopUp.setupAndEnable": "Add card and turn on",
"credits.autoTopUp.setupPaymentMethod": "Add payment method",
+ "credits.autoTopUp.summary": "Refill to {{target}} when the balance is at or below {{threshold}}",
+ "credits.autoTopUp.summaryMonthly": "Charged this month: {{amount}} / {{limit}}",
+ "credits.autoTopUp.summaryNoCard": "Add a card to refill the balance automatically, so requests keep going after your limits run out",
+ "credits.autoTopUp.summaryOff": "{{summary}}, so requests keep going after your limits run out",
"credits.autoTopUp.targetBalance": "Target balance",
"credits.autoTopUp.targetBalanceDesc": "The balance to restore to when auto top-up triggers",
"credits.autoTopUp.threshold": "Threshold",
@@ -282,9 +310,12 @@
"credits.topUp.validityMonths": "{{months}} months",
"credits.topUp.yearlyNudge.cta": "View yearly plans",
"credits.topUp.yearlyNudge.title": "Yearly subscribers top up for less, as low as ${{price}} per $1 of balance",
+ "creditsChip.autoTopUp.enable": "Turn on auto top-up",
"creditsChip.available": "available",
"creditsChip.balance": "Balance {{amount}}",
+ "creditsChip.balanceInUse": "In use",
"creditsChip.balanceNote.limit": "Monthly limit reached. Requests now use your balance.",
+ "creditsChip.balanceNote.plan": "Plan limit reached. Requests now use your balance.",
"creditsChip.balanceNote.subscription": "Subscription usage has run out. Requests now use your balance.",
"creditsChip.rolling.topup": "Top up",
"creditsChip.rolling.usageTitle": "Plan usage",
@@ -345,6 +376,12 @@
"limitation.insufficientBudget.estimatedDesc": "This request is estimated to need more balance. Top up or upgrade your plan.",
"limitation.insufficientBudget.exactDesc": "This request needs more balance. Top up or upgrade your plan.",
"limitation.insufficientBudget.required": "Required amount",
+ "limitation.insufficientBudget.rescue.autoTopUp.cta": "Turn on auto top-up & continue",
+ "limitation.insufficientBudget.rescue.autoTopUp.ctaNoCard": "Add card & turn on auto top-up",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.desc": "{{amount}} was added, so you can continue now. The balance refills automatically when it runs low.",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.descNoCharge": "The balance refills automatically when it runs low. You can continue now.",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.title": "Auto top-up is on",
+ "limitation.insufficientBudget.rescue.autoTopUp.title": "Turn on auto top-up",
"limitation.insufficientBudget.rescue.desc": "This request needs {{shortfall}} more to continue",
"limitation.insufficientBudget.rescue.limit.benefit": "{{spent}} of {{limit}} used this month. Raise the limit to keep going on your balance.",
"limitation.insufficientBudget.rescue.limit.benefitPlain": "Raise the limit to keep going on your balance.",
@@ -374,6 +411,8 @@
"limitation.insufficientBudget.rescue.upgrade.benefitWithRuns": "{{credits}} usage per month ≈ {{runs}}+ requests like this",
"limitation.insufficientBudget.rescue.upgrade.cta": "Upgrade & continue",
"limitation.insufficientBudget.rescue.upgrade.price": "from ${{price}}/mo",
+ "limitation.insufficientBudget.rescue.upgrade.short": "{{multiple}}× usage",
+ "limitation.insufficientBudget.rescue.upgrade.shortUltra": "{{multiple}}× Ultra usage",
"limitation.insufficientBudget.rescue.upgrade.title": "Upgrade to {{plan}}",
"limitation.insufficientBudget.rescue.wait.hint": "Or wait for the reset and retry, it's free.",
"limitation.insufficientBudget.rescue.wait.hintUltra": "Or switch to a standard model to keep chatting, or wait for the reset. It's free.",
@@ -825,6 +864,7 @@
"tab.referral": "Referral rewards",
"tab.spend": "Usage details",
"tab.usage": "Usage",
+ "tab.usageAndBalance": "Usage & Balance",
"upgrade": "Upgrade",
"upgradeNow": "Upgrade now",
"upgradePlan": "Upgrade plan",
@@ -843,6 +883,7 @@
"usage.overview.included": "Plan usage",
"usage.overview.onDemand": "On-demand",
"usage.overview.product": "Product item",
+ "usage.overview.records": "Top-up history",
"usage.overview.resetsInHours_one": "Resets in {{count}} hour",
"usage.overview.resetsInHours_other": "Resets in {{count}} hours",
"usage.overview.resetsIn_one": "Resets in {{count}} day",
@@ -852,10 +893,14 @@
"usage.overview.section.limits": "Limits",
"usage.overview.section.storage": "Storage",
"usage.overview.title": "Overview",
+ "usage.overview.topUpOnce": "Top up once",
"usage.storage.embeddings.used": "Vector storage",
"usage.storage.file.used": "File usage",
"usage.storage.sandboxStorage.pool": "Sandbox drives (workspace pool)",
"usage.storage.sandboxStorage.used": "Sandbox storage",
+ "usage.tabs.detail": "Details",
+ "usage.tabs.overview": "Overview",
+ "usage.tabs.records": "Top-up history",
"usage.window.credits": "Balance",
"usage.window.notStarted": "Starts with your next request",
"usage.window.overflow.belowSpend": "Not above the {{spent}} used this month, so your balance stops covering requests.",
diff --git a/locales/zh-CN/subscription.json b/locales/zh-CN/subscription.json
index 6d70a826bb1..ad57dfb8073 100644
--- a/locales/zh-CN/subscription.json
+++ b/locales/zh-CN/subscription.json
@@ -96,10 +96,32 @@
"credits.agentShareBudget.saveSuccess": "智能体分享预算策略已保存",
"credits.agentShareBudget.title": "智能体对外分享",
"credits.agentShareBudget.unlimited": "不设置工作区总上限",
+ "credits.autoTopUp.adjust": "调整",
"credits.autoTopUp.cardBindingGiftHint": "首次添加支付方式,即送 $1",
+ "credits.autoTopUp.collapse": "收起",
"credits.autoTopUp.currentBalance": "当前总余额",
"credits.autoTopUp.desc": "确保你的余额不会用光",
"credits.autoTopUp.descUsd": "确保你的余额不会用光",
+ "credits.autoTopUp.disabled": "自动充值已关闭",
+ "credits.autoTopUp.enable.addPaymentMethod": "绑定银行卡",
+ "credits.autoTopUp.enable.chargeFailed": "自动充值已开启,但这次扣款失败,请检查支付方式",
+ "credits.autoTopUp.enable.chargeNow": "当前余额 {{balance}},已不高于 {{threshold}}:开启后会立即扣款 {{amount}},把余额充到 {{target}}。",
+ "credits.autoTopUp.enable.chargeNowCapped": "当前余额 {{balance}},已不高于 {{threshold}}:开启后会立即扣款 {{amount}}(本月上限只剩这么多),余额补到 {{newBalance}}。",
+ "credits.autoTopUp.enable.desc": "余额不足时自动用已保存的支付方式补充,套餐限额用完也不中断。可随时关闭。",
+ "credits.autoTopUp.enable.failed": "开启自动充值失败,请重试",
+ "credits.autoTopUp.enable.giftBadge": "首次绑卡送 $1",
+ "credits.autoTopUp.enable.limitReached": "自动充值已开启,但本月扣款已达上限,这次没有充值",
+ "credits.autoTopUp.enable.limitReachedNow": "当前余额 {{balance}},已不高于 {{threshold}},但本月扣款已达上限,开启时不会扣款。",
+ "credits.autoTopUp.enable.noChargeNow": "当前余额 {{balance}},高于 {{threshold}},开启时不会扣款;余额降到 {{threshold}} 时才自动充值。",
+ "credits.autoTopUp.enable.noPaymentMethod": "需要先绑定银行卡",
+ "credits.autoTopUp.enable.overflowNote": "会同时开启「{{overflow}}」,否则套餐限额用完后不会使用余额,自动充值也不会生效。",
+ "credits.autoTopUp.enable.paymentMethod": "支付方式",
+ "credits.autoTopUp.enable.submit": "开启自动充值",
+ "credits.autoTopUp.enable.submitAndCharge": "开启并扣款 {{amount}}",
+ "credits.autoTopUp.enable.success": "自动充值已开启",
+ "credits.autoTopUp.enable.successCharged": "自动充值已开启,已充值 {{amount}}",
+ "credits.autoTopUp.enable.title": "开启自动充值",
+ "credits.autoTopUp.enable.waitingForPaymentMethod": "在新标签页完成绑卡后回到这里,即可开启。",
"credits.autoTopUp.monthlyLimit": "月度上限",
"credits.autoTopUp.monthlyLimitDesc": "每月自动充值的最大金额,留空表示无限制",
"credits.autoTopUp.monthlyLimitPlaceholder": "无限制",
@@ -107,9 +129,15 @@
"credits.autoTopUp.noCustomerHint": "先充值一次并保存支付方式,之后即可启用自动充值。",
"credits.autoTopUp.noPaymentMethodHint": "未绑定支付方式,自动充值需要已保存的银行卡才能自动扣费。",
"credits.autoTopUp.purchaseCredits": "充值",
+ "credits.autoTopUp.recommended": "推荐",
"credits.autoTopUp.saveError": "保存自动充值设置失败",
"credits.autoTopUp.saveSuccess": "自动充值设置已保存",
+ "credits.autoTopUp.setupAndEnable": "绑卡并开启",
"credits.autoTopUp.setupPaymentMethod": "添加支付方式",
+ "credits.autoTopUp.summary": "余额 ≤ {{threshold}} 时自动充到 {{target}}",
+ "credits.autoTopUp.summaryMonthly": "本月已扣款 {{amount}} / {{limit}}",
+ "credits.autoTopUp.summaryNoCard": "绑定银行卡后,余额不足时自动补充,限额用完也不中断",
+ "credits.autoTopUp.summaryOff": "{{summary}},限额用完也不中断",
"credits.autoTopUp.targetBalance": "目标余额",
"credits.autoTopUp.targetBalanceDesc": "自动充值后余额将恢复到此目标值",
"credits.autoTopUp.threshold": "触发阈值",
@@ -282,9 +310,12 @@
"credits.topUp.validityMonths": "{{months}} 个月",
"credits.topUp.yearlyNudge.cta": "查看年费套餐",
"credits.topUp.yearlyNudge.title": "年费用户充值享折扣,每 $1 余额低至 ${{price}}",
+ "creditsChip.autoTopUp.enable": "开启自动充值",
"creditsChip.available": "可用",
"creditsChip.balance": "余额 {{amount}}",
+ "creditsChip.balanceInUse": "使用中",
"creditsChip.balanceNote.limit": "每月限额已用完,请求将使用余额。",
+ "creditsChip.balanceNote.plan": "套餐限额已用完,请求将使用余额。",
"creditsChip.balanceNote.subscription": "订阅额度已用完,请求将使用余额。",
"creditsChip.rolling.topup": "充值",
"creditsChip.rolling.usageTitle": "套餐用量",
@@ -345,6 +376,12 @@
"limitation.insufficientBudget.estimatedDesc": "本次请求预计需要更多余额,请充值或升级套餐。",
"limitation.insufficientBudget.exactDesc": "本次请求需要更多余额,请充值或升级套餐。",
"limitation.insufficientBudget.required": "所需金额",
+ "limitation.insufficientBudget.rescue.autoTopUp.cta": "开启自动充值并继续",
+ "limitation.insufficientBudget.rescue.autoTopUp.ctaNoCard": "绑卡并开启自动充值",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.desc": "已充值 {{amount}},现在可以继续了。余额不足时会自动补充。",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.descNoCharge": "余额不足时会自动补充,现在可以继续了。",
+ "limitation.insufficientBudget.rescue.autoTopUp.success.title": "自动充值已开启",
+ "limitation.insufficientBudget.rescue.autoTopUp.title": "开启自动充值",
"limitation.insufficientBudget.rescue.desc": "本次请求还差 {{shortfall}},补上就能继续",
"limitation.insufficientBudget.rescue.limit.benefit": "本月已用 {{spent}} / {{limit}},调高后可继续使用余额",
"limitation.insufficientBudget.rescue.limit.benefitPlain": "调高上限后可继续使用余额",
@@ -374,6 +411,8 @@
"limitation.insufficientBudget.rescue.upgrade.benefitWithRuns": "每月 {{credits}} 额度 ≈ {{runs}}+ 次这样的请求",
"limitation.insufficientBudget.rescue.upgrade.cta": "升级并继续",
"limitation.insufficientBudget.rescue.upgrade.price": "${{price}}/月起",
+ "limitation.insufficientBudget.rescue.upgrade.short": "{{multiple}} 倍用量",
+ "limitation.insufficientBudget.rescue.upgrade.shortUltra": "{{multiple}} 倍 Ultra 用量",
"limitation.insufficientBudget.rescue.upgrade.title": "升级至 {{plan}}",
"limitation.insufficientBudget.rescue.wait.hint": "也可以等限额重置后重试,无需付费。",
"limitation.insufficientBudget.rescue.wait.hintUltra": "也可以切换到标准模型继续对话,或等限额重置后重试,无需付费。",
@@ -825,6 +864,7 @@
"tab.referral": "推荐奖励",
"tab.spend": "用量明细",
"tab.usage": "用量",
+ "tab.usageAndBalance": "用量与余额",
"upgrade": "升级",
"upgradeNow": "立即升级",
"upgradePlan": "升级套餐",
@@ -843,6 +883,7 @@
"usage.overview.included": "套餐内使用",
"usage.overview.onDemand": "按需使用",
"usage.overview.product": "产品项目",
+ "usage.overview.records": "充值记录",
"usage.overview.resetsInHours_one": "{{count}} 小时后重置",
"usage.overview.resetsInHours_other": "{{count}} 小时后重置",
"usage.overview.resetsIn_one": "{{count}} 天后重置",
@@ -852,10 +893,14 @@
"usage.overview.section.limits": "限额",
"usage.overview.section.storage": "存储",
"usage.overview.title": "总览",
+ "usage.overview.topUpOnce": "单次充值",
"usage.storage.embeddings.used": "向量存储",
"usage.storage.file.used": "文件使用量",
"usage.storage.sandboxStorage.pool": "沙箱网盘(工作区配额池)",
"usage.storage.sandboxStorage.used": "沙箱存储",
+ "usage.tabs.detail": "明细",
+ "usage.tabs.overview": "概览",
+ "usage.tabs.records": "充值记录",
"usage.window.credits": "余额",
"usage.window.notStarted": "下次请求时开始计算",
"usage.window.overflow.belowSpend": "不高于本月已用的 {{spent}},余额将无法继续支付请求",
diff --git a/packages/locales/src/default/subscription.ts b/packages/locales/src/default/subscription.ts
index 45d073aa824..9ea83c1f979 100644
--- a/packages/locales/src/default/subscription.ts
+++ b/packages/locales/src/default/subscription.ts
@@ -84,7 +84,9 @@ export default {
'creditsChip.balance': 'Balance {{amount}}',
'creditsChip.viewDetails': 'View details',
'creditsChip.viewUsage': 'View usage',
+ 'creditsChip.balanceInUse': 'In use',
'creditsChip.balanceNote.limit': 'Monthly limit reached. Requests now use your balance.',
+ 'creditsChip.balanceNote.plan': 'Plan limit reached. Requests now use your balance.',
'creditsChip.balanceNote.subscription':
'Subscription usage has run out. Requests now use your balance.',
'compareAllPlans': 'View all plans',
@@ -1021,4 +1023,59 @@ export default {
'creditsChip.usageTitle': 'Usage',
'creditsChip.usageTooltip': 'Usage in the current billing cycle',
'usage.window.used': '{{percent}}% used',
+ 'credits.autoTopUp.adjust': 'Adjust',
+ 'credits.autoTopUp.collapse': 'Collapse',
+ 'credits.autoTopUp.disabled': 'Auto top-up is off',
+ 'credits.autoTopUp.enable.addPaymentMethod': 'Add a card',
+ 'credits.autoTopUp.enable.chargeFailed':
+ 'Auto top-up is on, but this charge failed. Check your payment method.',
+ 'credits.autoTopUp.enable.chargeNow':
+ 'Your balance is {{balance}}, at or below {{threshold}}. Turning this on charges {{amount}} now to bring it to {{target}}.',
+ 'credits.autoTopUp.enable.chargeNowCapped':
+ "Your balance is {{balance}}, at or below {{threshold}}. Turning this on charges {{amount}} now, all that this month's limit has left, bringing it to {{newBalance}}.",
+ 'credits.autoTopUp.enable.desc':
+ 'When your balance runs low, it is refilled from your saved payment method, so requests keep going after your plan limits run out. You can turn it off anytime.',
+ 'credits.autoTopUp.enable.failed': "Couldn't turn on auto top-up. Please try again.",
+ 'credits.autoTopUp.enable.giftBadge': '$1 free for your first card',
+ 'credits.autoTopUp.enable.limitReached':
+ "Auto top-up is on, but this month's charge limit is reached, so nothing was added.",
+ 'credits.autoTopUp.enable.limitReachedNow':
+ "Your balance is {{balance}}, at or below {{threshold}}, but this month's limit is used up, so nothing is charged now.",
+ 'credits.autoTopUp.enable.noChargeNow':
+ 'Your balance is {{balance}}, above {{threshold}}, so nothing is charged now. Auto top-up runs once it drops to {{threshold}}.',
+ 'credits.autoTopUp.enable.noPaymentMethod': 'Add a card first',
+ 'credits.autoTopUp.enable.overflowNote':
+ 'This also turns on "{{overflow}}". Without it, requests stop at your plan limits and auto top-up never runs.',
+ 'credits.autoTopUp.enable.paymentMethod': 'Payment method',
+ 'credits.autoTopUp.enable.submit': 'Turn on auto top-up',
+ 'credits.autoTopUp.enable.submitAndCharge': 'Turn on and pay {{amount}}',
+ 'credits.autoTopUp.enable.success': 'Auto top-up is on',
+ 'credits.autoTopUp.enable.successCharged': 'Auto top-up is on. {{amount}} was added.',
+ 'credits.autoTopUp.enable.title': 'Turn on auto top-up',
+ 'credits.autoTopUp.enable.waitingForPaymentMethod':
+ 'Add the card in the new tab, then come back here to turn it on.',
+ 'credits.autoTopUp.recommended': 'Recommended',
+ 'credits.autoTopUp.setupAndEnable': 'Add card and turn on',
+ 'credits.autoTopUp.summary': 'Refill to {{target}} when the balance is at or below {{threshold}}',
+ 'credits.autoTopUp.summaryMonthly': 'Charged this month: {{amount}} / {{limit}}',
+ 'credits.autoTopUp.summaryNoCard':
+ 'Add a card to refill the balance automatically, so requests keep going after your limits run out',
+ 'credits.autoTopUp.summaryOff': '{{summary}}, so requests keep going after your limits run out',
+ 'creditsChip.autoTopUp.enable': 'Turn on auto top-up',
+ 'limitation.insufficientBudget.rescue.autoTopUp.cta': 'Turn on auto top-up & continue',
+ 'limitation.insufficientBudget.rescue.autoTopUp.ctaNoCard': 'Add card & turn on auto top-up',
+ 'limitation.insufficientBudget.rescue.autoTopUp.success.desc':
+ '{{amount}} was added, so you can continue now. The balance refills automatically when it runs low.',
+ 'limitation.insufficientBudget.rescue.autoTopUp.success.descNoCharge':
+ 'The balance refills automatically when it runs low. You can continue now.',
+ 'limitation.insufficientBudget.rescue.autoTopUp.success.title': 'Auto top-up is on',
+ 'limitation.insufficientBudget.rescue.autoTopUp.title': 'Turn on auto top-up',
+ 'limitation.insufficientBudget.rescue.upgrade.short': '{{multiple}}× usage',
+ 'limitation.insufficientBudget.rescue.upgrade.shortUltra': '{{multiple}}× Ultra usage',
+ 'tab.usageAndBalance': 'Usage & Balance',
+ 'usage.overview.records': 'Top-up history',
+ 'usage.overview.topUpOnce': 'Top up once',
+ 'usage.tabs.detail': 'Details',
+ 'usage.tabs.overview': 'Overview',
+ 'usage.tabs.records': 'Top-up history',
};
diff --git a/src/components/Skeleton/Settings/Sections.tsx b/src/components/Skeleton/Settings/Sections.tsx
index 118816debbb..72a5beeb1d5 100644
--- a/src/components/Skeleton/Settings/Sections.tsx
+++ b/src/components/Skeleton/Settings/Sections.tsx
@@ -111,6 +111,8 @@ export type SettingsSectionSkeleton =
* of `cellHeight`.
*/
blocks: QuotaBlockShape[];
+ /** Setting rows (label + description, control) under the blocks. */
+ rows?: number;
variant: 'quota';
})
| (GroupHeadOptions & {
@@ -141,6 +143,8 @@ export interface SettingsSectionsShape {
/** Vertical gap between sections, as set by the real page's stack. */
gap?: number;
sections: SettingsSectionSkeleton[];
+ /** Number of tabs in a strip above the sections, 16px above the first one. */
+ tabs?: number;
/** The page draws its own large title + divider above the sections. */
title?: boolean;
}
@@ -690,6 +694,12 @@ const Section = ({ section }: { section: SettingsSectionSkeleton }) => {
return (
<Group {...section} flush>
<Quota blocks={section.blocks} />
+ {section.rows && (
+ <Flexbox paddingInline={16}>
+ <div {...stylex.props(styles.divider)} />
+ <FormRows rows={section.rows} />
+ </Flexbox>
+ )}
</Group>
);
}
@@ -750,6 +760,15 @@ const Section = ({ section }: { section: SettingsSectionSkeleton }) => {
}
};
+/** A page-level tab strip above the sections. */
+const PageTabs = ({ count }: { count: number }) => (
+ <Flexbox horizontal align={'center'} gap={32} height={44}>
+ {Array.from({ length: count }, (_, index) => (
+ <SkeletonBar height={14} key={index} width={widthAt(index, [40, 56, 64])} />
+ ))}
+ </Flexbox>
+);
+
/** Large page title + divider, matching a settings page that renders its own heading. */
const PageTitle = () => (
<Flexbox gap={24} style={{ paddingTop: 12 }}>
@@ -764,14 +783,24 @@ const PageTitle = () => (
* The sections of a settings page without any surrounding chrome. Use it
* directly where a layout already draws the header and padded container.
*/
-export const SettingsSectionsBody = ({ shape }: { shape: SettingsSectionsShape }) => (
- <Flexbox aria-busy data-testid={'settings-sections-skeleton'} gap={shape.gap ?? 36}>
- {shape.title && <PageTitle />}
- {shape.sections.map((section, index) => (
- <Section key={index} section={section} />
- ))}
- </Flexbox>
-);
+export const SettingsSectionsBody = ({ shape }: { shape: SettingsSectionsShape }) => {
+ const sections = (
+ <Flexbox aria-busy data-testid={'settings-sections-skeleton'} gap={shape.gap ?? 36}>
+ {shape.title && <PageTitle />}
+ {shape.sections.map((section, index) => (
+ <Section key={index} section={section} />
+ ))}
+ </Flexbox>
+ );
+ if (!shape.tabs) return sections;
+
+ return (
+ <Flexbox gap={16}>
+ <PageTabs count={shape.tabs} />
+ {sections}
+ </Flexbox>
+ );
+};
/**
* Route skeleton for a settings-style page made of stacked filled groups.
diff --git a/src/components/Skeleton/Settings/sectionShapes.ts b/src/components/Skeleton/Settings/sectionShapes.ts
index a0265b5fbb4..3d9bdaa038f 100644
--- a/src/components/Skeleton/Settings/sectionShapes.ts
+++ b/src/components/Skeleton/Settings/sectionShapes.ts
@@ -107,20 +107,34 @@ export const SETTINGS_SECTION_SHAPES: Record<string, SettingsSectionsShape> = {
},
],
},
+ // The overview tab of the usage and balance page: limits, the balance with
+ // its auto top-up and cost-hint rows, then storage.
usage: {
sections: [
+ {
+ blocks: [{ cellHeight: 70 }],
+ extra: { height: 24, width: 146 },
+ heading: ['subscription', 'usage.overview.section.limits'],
+ variant: 'quota',
+ },
{
blocks: [
{
- caption: ['subscription', 'usage.overview.section.credits'],
cellHeight: 95,
labels: [
['subscription', 'usage.overview.credits.topUp'],
['subscription', 'usage.window.referral'],
],
},
+ ],
+ extra: { height: 24, width: 160 },
+ heading: ['subscription', 'usage.overview.section.credits'],
+ rows: 2,
+ variant: 'quota',
+ },
+ {
+ blocks: [
{
- caption: ['subscription', 'usage.overview.section.storage'],
cellHeight: 70,
labels: [
['subscription', 'usage.storage.file.used'],
@@ -128,12 +142,11 @@ export const SETTINGS_SECTION_SHAPES: Record<string, SettingsSectionsShape> = {
],
},
],
- extra: { height: 24, width: 146 },
- heading: ['subscription', 'usage.overview.title'],
+ heading: ['subscription', 'usage.overview.section.storage'],
variant: 'quota',
},
- { columns: 8, heading: ['spend', 'table.title'], rows: 10, toolbar: true, variant: 'table' },
],
+ tabs: 3,
},
};
diff --git a/src/features/Settings/Layout/Body/index.tsx b/src/features/Settings/Layout/Body/index.tsx
index 56d55a717ea..15300cda473 100644
--- a/src/features/Settings/Layout/Body/index.tsx
+++ b/src/features/Settings/Layout/Body/index.tsx
@@ -13,10 +13,11 @@ import { isModifierClick } from '@/utils/navigation';
import { SettingsGroupKey, useCategory } from '../../hooks/useCategory';
import { useExpandedSettingsGroups } from '../../hooks/useExpandedSettingsGroups';
+import { usePersonalSettingsSearchScope } from '../../hooks/useSettingsSearchScope';
const Body = memo(() => {
const categoryGroups = useCategory();
- const searchScope = useMemo(() => ({ categoryGroups }), [categoryGroups]);
+ const searchScope = usePersonalSettingsSearchScope(categoryGroups);
const navigate = useWorkspaceAwareNavigate();
const location = useActiveLocation();
diff --git a/src/features/Settings/features/tabTitles.ts b/src/features/Settings/features/tabTitles.ts
index bd8a68db708..38172da7459 100644
--- a/src/features/Settings/features/tabTitles.ts
+++ b/src/features/Settings/features/tabTitles.ts
@@ -39,7 +39,7 @@ export const SETTINGS_TAB_TITLE_KEYS: Partial<Record<SettingsTabs, TitleKey>> =
[SettingsTabs.SystemTools]: ['setting', 'tab.systemTools'],
[SettingsTabs.Tools]: ['setting', 'tab.tools'],
[SettingsTabs.Trash]: ['setting', 'tab.trash'],
- [SettingsTabs.Usage]: ['setting', 'tab.usage'],
+ [SettingsTabs.Usage]: ['subscription', 'tab.usageAndBalance'],
};
const TITLE_NAMESPACES = ['auth', 'labs', 'setting', 'subscription'] as const;
diff --git a/src/features/Settings/hooks/useCategory.tsx b/src/features/Settings/hooks/useCategory.tsx
index 9288d16695d..fc233a5d2cc 100644
--- a/src/features/Settings/hooks/useCategory.tsx
+++ b/src/features/Settings/hooks/useCategory.tsx
@@ -10,7 +10,6 @@ import {
BrainCircuit,
ChartColumnBigIcon,
ChartPieIcon,
- Coins,
ContainerIcon,
CreditCard,
Database,
@@ -140,8 +139,12 @@ export const useCategory = () => {
if (enableBusinessFeatures) {
const subscriptionItems: CategoryItem[] = [
{ icon: Map, key: SettingsTabs.Plans, label: tSubscription('tab.plans') },
- { icon: ChartPieIcon, key: SettingsTabs.Usage, label: t('tab.usage') },
- { icon: Coins, key: SettingsTabs.Credits, label: tSubscription('tab.credits') },
+ // One entry for usage and balance: `/settings/credits` redirects into it.
+ {
+ icon: ChartPieIcon,
+ key: SettingsTabs.Usage,
+ label: tSubscription('tab.usageAndBalance'),
+ },
{ icon: CreditCard, key: SettingsTabs.Billing, label: tSubscription('tab.billing') },
{ icon: Gift, key: SettingsTabs.Referral, label: tSubscription('tab.referral') },
];
diff --git a/src/features/Settings/hooks/useSettingsSearchScope.test.ts b/src/features/Settings/hooks/useSettingsSearchScope.test.ts
new file mode 100644
index 00000000000..280abeb64c6
--- /dev/null
+++ b/src/features/Settings/hooks/useSettingsSearchScope.test.ts
@@ -0,0 +1,46 @@
+import { renderHook } from '@testing-library/react';
+import { createElement, type ReactNode } from 'react';
+import { describe, expect, it } from 'vitest';
+
+import { type SettingsSearchCategoryGroup, useSettingsSearch } from '@/features/SettingsSearch';
+import { SettingsTabs } from '@/store/global/initialState';
+import { ServerConfigStoreProvider } from '@/store/serverConfig/Provider';
+
+import { usePersonalSettingsSearchScope } from './useSettingsSearchScope';
+
+const groups: SettingsSearchCategoryGroup[] = [
+ {
+ items: [
+ { key: SettingsTabs.Plans, label: 'Plans' },
+ { key: SettingsTabs.Usage, label: 'Usage & Balance' },
+ { key: SettingsTabs.Billing, label: 'Billing' },
+ ],
+ key: 'subscription',
+ title: 'Subscription',
+ },
+];
+
+const search = (query: string) => {
+ const { result } = renderHook(
+ () => useSettingsSearch(query, usePersonalSettingsSearchScope(groups)),
+ {
+ wrapper: ({ children }: { children?: ReactNode }) =>
+ createElement(ServerConfigStoreProvider, null, children),
+ },
+ );
+ return result.current.results;
+};
+
+describe('personal settings search scope', () => {
+ it('finds the merged Usage & Balance page by the balance keywords', () => {
+ for (const query of ['balance', 'recharge', 'top up']) {
+ expect(search(query).map((result) => result.key)).toContain(
+ `tab-subscription-${SettingsTabs.Usage}`,
+ );
+ }
+ });
+
+ it('still finds the page by its usage keywords', () => {
+ expect(search('consumption').map((result) => result.url)).toContain('/settings/usage');
+ });
+});
diff --git a/src/features/Settings/hooks/useSettingsSearchScope.ts b/src/features/Settings/hooks/useSettingsSearchScope.ts
new file mode 100644
index 00000000000..bf8b37feec8
--- /dev/null
+++ b/src/features/Settings/hooks/useSettingsSearchScope.ts
@@ -0,0 +1,23 @@
+import { useMemo } from 'react';
+
+import type {
+ SettingsSearchCategoryGroup,
+ SettingsSearchScope,
+ SettingsSearchTab,
+} from '@/features/SettingsSearch';
+import { SettingsTabs } from '@/store/global/initialState';
+
+/**
+ * Personal Usage holds the balance (`/settings/credits` redirects into it), so
+ * it answers the balance keywords as well. Workspace settings keep a separate
+ * Credits page and do not merge them.
+ */
+const MERGED_TABS: Partial<Record<string, readonly SettingsSearchTab[]>> = {
+ [SettingsTabs.Usage]: [SettingsTabs.Credits],
+};
+
+/** Settings-search scope for the personal sidebar. */
+export const usePersonalSettingsSearchScope = (
+ categoryGroups: SettingsSearchCategoryGroup[],
+): SettingsSearchScope =>
+ useMemo(() => ({ categoryGroups, mergedTabs: MERGED_TABS }), [categoryGroups]);
diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.ts
index 974208a3aa7..cc60fc3755b 100644
--- a/src/features/SettingsSearch/items.ts
+++ b/src/features/SettingsSearch/items.ts
@@ -672,20 +672,20 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [
ns: 'subscription',
tab: SettingsTabs.Billing,
},
- // Credits
+ // Usage and balance (balance anchors keep their `credits-` ids for old links)
{
anchor: 'credits-balance',
keywords: ['balance', 'credits'],
labelKey: 'balance.title',
ns: 'subscription',
- tab: SettingsTabs.Credits,
+ tab: SettingsTabs.Usage,
},
{
anchor: 'credits-top-up',
keywords: ['top up', 'topup', 'buy credits', 'recharge'],
labelKey: 'credits.topUp.title',
ns: 'subscription',
- tab: SettingsTabs.Credits,
+ tab: SettingsTabs.Usage,
},
{
anchor: 'credits-cost-estimate-hint',
@@ -693,7 +693,7 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [
keywords: ['cost estimate'],
labelKey: 'credits.costEstimateHint.title',
ns: 'subscription',
- tab: SettingsTabs.Credits,
+ tab: SettingsTabs.Usage,
},
{
anchor: 'credits-auto-top-up',
@@ -701,14 +701,14 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [
keywords: ['auto top up', 'automatic recharge'],
labelKey: 'credits.autoTopUp.title',
ns: 'subscription',
- tab: SettingsTabs.Credits,
+ tab: SettingsTabs.Usage,
},
{
anchor: 'credits-packages',
keywords: ['package', 'budget'],
labelKey: 'credits.packages.title',
ns: 'subscription',
- tab: SettingsTabs.Credits,
+ tab: SettingsTabs.Usage,
},
// Plans
{
diff --git a/src/features/SettingsSearch/useSettingsSearch.ts b/src/features/SettingsSearch/useSettingsSearch.ts
index 3a97bab795c..751d9492325 100644
--- a/src/features/SettingsSearch/useSettingsSearch.ts
+++ b/src/features/SettingsSearch/useSettingsSearch.ts
@@ -69,6 +69,13 @@ export interface SettingsSearchScope {
* found on the page that no longer renders it.
*/
keywordOwnerTabs?: readonly SettingsSearchTab[];
+ /**
+ * Tabs whose page also holds other tabs' settings in this scope, mapped to
+ * the tabs they hold. The host tab answers those tabs' keywords too: personal
+ * Usage holds the balance, while the workspace keeps a separate Credits page.
+ * Keyed by `SettingsSearchTab` values, typed as `string` like the keyword tables.
+ */
+ mergedTabs?: Partial<Record<string, readonly SettingsSearchTab[]>>;
/** Builtin provider detail URL; defaults to the personal provider page */
providerUrl?: (providerId: string) => string;
}
@@ -122,6 +129,7 @@ export const useSettingsSearch = (
categoryGroups,
itemTabs,
keywordOwnerTabs,
+ mergedTabs,
providerUrl = getPersonalProviderUrl,
} = scope;
const { hideDocs, showAiImage } = useServerConfigStore(featureFlagsSelectors);
@@ -165,13 +173,15 @@ export const useSettingsSearch = (
!itemTabs || itemTabs.has(tab) ? visibleTabs.get(tab) : undefined;
// English floor + localized enrichment (deduped: on en-US they overlap)
- const getTabKeywords = (tab: SettingsSearchTab) => {
+ const getOwnTabKeywords = (tab: SettingsSearchTab) => {
const keywordsKey = TAB_SEARCH_KEYWORDS_KEYS[tab];
return [
...(TAB_SEARCH_EN_KEYWORDS[tab] ?? []),
...(keywordsKey ? splitKeywords(t(keywordsKey as never) as string) : []),
];
};
+ const getTabKeywords = (tab: SettingsSearchTab) =>
+ [tab, ...(mergedTabs?.[tab] ?? [])].flatMap(getOwnTabKeywords);
const ownerTabs = new Set(keywordOwnerTabs);
const ownedKeywords = new Set(keywordOwnerTabs?.flatMap(getTabKeywords));
const withoutOwnedKeywords = (tab: SettingsSearchTab, keywords: string[]) =>
@@ -303,6 +313,7 @@ export const useSettingsSearch = (
categoryGroups,
itemTabs,
keywordOwnerTabs,
+ mergedTabs,
providerUrl,
t,
disableEmailPassword,
diff --git a/src/features/WorkspaceSetting/hooks/useSettingsSearchScope.test.ts b/src/features/WorkspaceSetting/hooks/useSettingsSearchScope.test.ts
index 62343e1507f..63165dde4b2 100644
--- a/src/features/WorkspaceSetting/hooks/useSettingsSearchScope.test.ts
+++ b/src/features/WorkspaceSetting/hooks/useSettingsSearchScope.test.ts
@@ -93,6 +93,28 @@ describe('workspace settings search scope', () => {
);
});
+ it('sends balance searches to the workspace Credits page, not Usage', () => {
+ const billingGroups: WorkspaceSettingCategoryGroup[] = [
+ ...adminGroups,
+ {
+ items: [
+ { icon: null, key: WorkspaceSettingsTabs.Usage, label: 'Usage' },
+ { icon: null, key: WorkspaceSettingsTabs.Credits, label: 'Credits' },
+ ],
+ key: WorkspaceSettingsGroupKey.Subscription,
+ title: 'Subscription',
+ },
+ ];
+
+ for (const query of ['balance', 'recharge', 'top up']) {
+ const urls = search(query, billingGroups).map((result) => result.url);
+
+ expect(urls).toContain('/acme/settings/credits');
+ // Only the personal Usage page holds the balance
+ expect(urls).not.toContain('/acme/settings/usage');
+ }
+ });
+
it('indexes only the tab for workspace pages that differ from the personal ones', () => {
const results = search('notification', memberGroups);
diff --git a/src/routes/(mobile)/me/settings/features/useCategory.tsx b/src/routes/(mobile)/me/settings/features/useCategory.tsx
index 1919c43a5fc..5237a63fd05 100644
--- a/src/routes/(mobile)/me/settings/features/useCategory.tsx
+++ b/src/routes/(mobile)/me/settings/features/useCategory.tsx
@@ -7,7 +7,6 @@ import {
BrainCircuit,
ChartColumnBigIcon,
ChartPieIcon,
- Coins,
CreditCard,
Database,
EllipsisIcon,
@@ -88,12 +87,7 @@ export const useCategory = (): CategoryGroup[] => {
makeItem({
icon: ChartPieIcon,
key: SettingsTabs.Usage,
- label: t('setting:tab.usage'),
- }),
- makeItem({
- icon: Coins,
- key: SettingsTabs.Credits,
- label: t('subscription:tab.credits'),
+ label: t('subscription:tab.usageAndBalance'),
}),
makeItem({
icon: CreditCard,
diff --git a/src/routes/(mobile)/settings/_layout/Header.tsx b/src/routes/(mobile)/settings/_layout/Header.tsx
index 01f2fea74dc..7b132ffaef4 100644
--- a/src/routes/(mobile)/settings/_layout/Header.tsx
+++ b/src/routes/(mobile)/settings/_layout/Header.tsx
@@ -27,6 +27,7 @@ const TAB_TITLE_KEY: Partial<Record<SettingsTabs, string>> = {
[SettingsTabs.ServiceModel]: 'setting:tab.serviceModel',
[SettingsTabs.Stats]: 'auth:tab.stats',
[SettingsTabs.SystemTools]: 'setting:tab.systemTools',
+ [SettingsTabs.Usage]: 'subscription:tab.usageAndBalance',
};
const WORKSPACE_TAB_TITLE_KEY: Record<string, string> = {