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(chat-input): add a credits slot to the composer control bar (#18789)

Arvin Xu3cb5cfc99ca0
diff --git a/locales/en-US/subscription.json b/locales/en-US/subscription.json
index a3ec209d1e3..836a67d84a3 100644
--- a/locales/en-US/subscription.json
+++ b/locales/en-US/subscription.json
@@ -212,6 +212,12 @@
"credits.topUp.upgradePrefix": "Upgrade to",
"credits.topUp.upgradeSuffix": "to save ${{savings}}",
"credits.topUp.validityInfo": "{{months}} months validity",
+ "creditsChip.available": "available",
+ "creditsChip.balance": "Balance {{amount}}",
+ "creditsChip.percent": "{{percent}}%",
+ "creditsChip.title": "Credits Left",
+ "creditsChip.tooltip": "Credits left in the current billing cycle",
+ "creditsChip.viewUsage": "View Usage",
"crossPlatform.desc": "This subscription was purchased through the mobile app and cannot be modified here. Please manage your subscription on your mobile device.",
"crossPlatform.manageOnMobile": "Manage on mobile device",
"crossPlatform.title": "Cross-Platform Subscription",
diff --git a/locales/zh-CN/subscription.json b/locales/zh-CN/subscription.json
index c5f0314568f..fef74ea95f6 100644
--- a/locales/zh-CN/subscription.json
+++ b/locales/zh-CN/subscription.json
@@ -212,6 +212,12 @@
"credits.topUp.upgradePrefix": "升级至",
"credits.topUp.upgradeSuffix": "可节省 ${{savings}}",
"credits.topUp.validityInfo": "有效期 {{months}} 个月",
+ "creditsChip.available": "可用",
+ "creditsChip.balance": "余额 {{amount}}",
+ "creditsChip.percent": "{{percent}}%",
+ "creditsChip.title": "剩余额度",
+ "creditsChip.tooltip": "当前计费周期剩余额度",
+ "creditsChip.viewUsage": "查看用量",
"crossPlatform.desc": "此订阅通过移动端应用购买,无法在此修改。请在移动设备上管理您的订阅。",
"crossPlatform.manageOnMobile": "前往移动端管理",
"crossPlatform.title": "跨平台订阅",
diff --git a/packages/locales/src/default/subscription.ts b/packages/locales/src/default/subscription.ts
index c25ed2b2c4d..3c3599ef4f5 100644
--- a/packages/locales/src/default/subscription.ts
+++ b/packages/locales/src/default/subscription.ts
@@ -83,6 +83,12 @@ export default {
'compare.title': 'Plan Comparison',
'creditUsageReminder.title':
'{{percent}} of the subscription credits included in this billing cycle have been used',
+ 'creditsChip.available': 'available',
+ 'creditsChip.balance': 'Balance {{amount}}',
+ 'creditsChip.percent': '{{percent}}%',
+ 'creditsChip.title': 'Credits Left',
+ 'creditsChip.tooltip': 'Credits left in the current billing cycle',
+ 'creditsChip.viewUsage': 'View Usage',
'compareAllPlans': 'View All Plans',
'comparePlans': 'View Plans',
'createSubscriptionError': 'Failed to create subscription',
diff --git a/src/business/client/features/ChatInputCredits.tsx b/src/business/client/features/ChatInputCredits.tsx
new file mode 100644
index 00000000000..440c1f03444
--- /dev/null
+++ b/src/business/client/features/ChatInputCredits.tsx
@@ -0,0 +1,9 @@
+/**
+ * Rendered in the composer control bar, next to the approval-mode chip. The
+ * open-source build keeps this slot empty; downstream builds can override the
+ * module through their own `@/business/...` mapping to surface a remaining
+ * balance indicator there.
+ */
+const ChatInputCredits = () => null;
+
+export default ChatInputCredits;
diff --git a/src/features/ChatInput/ControlBar/index.tsx b/src/features/ChatInput/ControlBar/index.tsx
index 53b2272f55e..232c8dbbd2c 100644
--- a/src/features/ChatInput/ControlBar/index.tsx
+++ b/src/features/ChatInput/ControlBar/index.tsx
@@ -2,6 +2,7 @@ import { Flexbox, Skeleton } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
+import ChatInputCredits from '@/business/client/features/ChatInputCredits';
import { useAgentStore } from '@/store/agent';
import { agentByIdSelectors } from '@/store/agent/selectors';
@@ -74,6 +75,7 @@ const ControlBar = memo(() => {
</Flexbox>
<Flexbox horizontal align={'center'} className={styles.rightGroup} gap={4}>
+ <ChatInputCredits />
{isAgentRuntimeMode && <ApprovalMode />}
{showContextWindow && <ContextWindow />}
</Flexbox>