🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(agent): 保留额度耗尽后的转派与恢复入口 (#21881)
Mochaf835a30e7b52
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.jsonindex 596d720e77f..680dc731052 100644--- a/locales/en-US/chat.json+++ b/locales/en-US/chat.json@@ -160,9 +160,11 @@"cliOverloadedGuide.errorDetails": "Error details","cliOverloadedGuide.retryHint": "Wait a few seconds and retry. If it keeps failing, the provider may be having a wider incident.","cliOverloadedGuide.title": "{{name}} is temporarily overloaded",+ "cliRateLimitGuide.actions.collapse": "Collapse details","cliRateLimitGuide.actions.handoff": "Hand off to another Agent","cliRateLimitGuide.actions.openSystemTools": "Open System Tools","cliRateLimitGuide.actions.retry": "Retry message",+ "cliRateLimitGuide.actions.showDetails": "Show details","cliRateLimitGuide.afterReset": "This account has reached its current usage limit. You can continue after {{resetAt}}.","cliRateLimitGuide.afterResetWithLimitType": "This account has reached its {{limitType}} usage limit. You can continue after {{resetAt}}.","cliRateLimitGuide.desc": "{{name}} has reached its current usage limit and cannot continue this run right now.",diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.jsonindex c5c7cd617b9..2e0f926522f 100644--- a/locales/zh-CN/chat.json+++ b/locales/zh-CN/chat.json@@ -160,9 +160,11 @@"cliOverloadedGuide.errorDetails": "错误详情","cliOverloadedGuide.retryHint": "稍等几秒重试即可。如果一直失败,可能是模型服务商出现了更大范围的故障。","cliOverloadedGuide.title": "{{name}} 服务暂时繁忙",+ "cliRateLimitGuide.actions.collapse": "收起详情","cliRateLimitGuide.actions.handoff": "转交给其他 Agent 继续","cliRateLimitGuide.actions.openSystemTools": "打开系统工具","cliRateLimitGuide.actions.retry": "重试这条消息",+ "cliRateLimitGuide.actions.showDetails": "展开详情","cliRateLimitGuide.afterReset": "当前账号已达到当前使用上限,{{resetAt}} 后可继续使用。","cliRateLimitGuide.afterResetWithLimitType": "当前账号已达到{{limitType}}使用上限,{{resetAt}} 后可继续使用。","cliRateLimitGuide.desc": "{{name}} 已达到当前使用上限,这次运行暂时无法继续。",diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.tsindex 0740e8d81cb..2338c68af44 100644--- a/packages/locales/src/default/chat.ts+++ b/packages/locales/src/default/chat.ts@@ -1258,9 +1258,11 @@ export default {'cliOverloadedGuide.retryHint':'Wait a few seconds and retry. If it keeps failing, the provider may be having a wider incident.','cliOverloadedGuide.title': '{{name}} is temporarily overloaded',+ 'cliRateLimitGuide.actions.collapse': 'Collapse details','cliRateLimitGuide.actions.handoff': 'Hand off to another Agent','cliRateLimitGuide.actions.openSystemTools': 'Open System Tools','cliRateLimitGuide.actions.retry': 'Retry message',+ 'cliRateLimitGuide.actions.showDetails': 'Show details','cliRateLimitGuide.afterReset':'This account has reached its current usage limit. You can continue after {{resetAt}}.','cliRateLimitGuide.afterResetWithLimitType':diff --git a/src/features/Conversation/Error/index.test.tsx b/src/features/Conversation/Error/index.test.tsxindex cf404ae2c4b..4d13592980a 100644--- a/src/features/Conversation/Error/index.test.tsx+++ b/src/features/Conversation/Error/index.test.tsx@@ -2,7 +2,7 @@ import type * as lobechatConstModule from '@lobechat/const';import { HeterogeneousAgentSessionErrorCode } from '@lobechat/electron-client-ipc';import type * as lobechatTypesModule from '@lobechat/types';import { AgentRuntimeErrorType, ChatErrorType } from '@lobechat/types';-import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';import type { ReactNode } from 'react';import { beforeEach, describe, expect, it, vi } from 'vitest';@@ -690,7 +690,7 @@ describe('ErrorMessageExtra', () => {});});- it('requests cancellation of the conversation source even when another topic is active', () => {+ it('restores handoff after cancelling the source wait even when another topic is active', () => {useChatStore.setState({activeTopicId: 'main-topic',topicDetailMap: {@@ -727,7 +727,26 @@ describe('ErrorMessageExtra', () => {/>,);+ expect(screen.queryByText('handoff')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'dismiss' })).not.toBeInTheDocument();++ act(() => {+ useChatStore.setState((state) => ({+ topicDetailMap: {+ ...state.topicDetailMap,+ 'source-topic': {+ ...state.topicDetailMap['source-topic'],+ metadata: { scheduledRun: null },+ status: 'failed',+ } as any,+ },+ }));+ });+fireEvent.click(screen.getByText('handoff'));+ // Opening the picker does not resolve the quota error or consume the entry.+ fireEvent.click(screen.getByText('handoff'));+ expect(createTopicForwardModalMock).toHaveBeenCalledTimes(2);expect(cancelHeteroContinuationMock).not.toHaveBeenCalled();const props = createTopicForwardModalMock.mock.calls[0][0];@@ -840,7 +859,7 @@ describe('ErrorMessageExtra', () => {});});- it('dismisses only the current heterogeneous error field', () => {+ it('dismisses only the current non-quota heterogeneous error field', () => {render(<ErrorMessageExtraerror={{ message: 'response.undefined' }}@@ -848,7 +867,7 @@ describe('ErrorMessageExtra', () => {error: {body: {agentType: 'claude-code',- code: HeterogeneousAgentSessionErrorCode.RateLimit,+ code: HeterogeneousAgentSessionErrorCode.Overloaded,},} as any,id: 'failed-step-2',diff --git a/src/features/Conversation/Error/index.tsx b/src/features/Conversation/Error/index.tsxindex 24e82b00e08..17bfaa8e651 100644--- a/src/features/Conversation/Error/index.tsx+++ b/src/features/Conversation/Error/index.tsx@@ -481,9 +481,19 @@ const ErrorMessageExtra = memo<ErrorExtraProps>(agentType: sessionErrorBody.agentType,autoRetry,error: sessionErrorBody,- onDismiss: () => void updateMessageError(data.id, null),+ // A quota card owns its local collapse action. Clearing its error would+ // also remove recovery controls while a scheduled continuation survives.+ onDismiss:+ sessionErrorBody.code === HeterogeneousAgentSessionErrorCode.RateLimit+ ? undefined+ : () => void updateMessageError(data.id, null),onHandoff:- isRateLimitError && conversationAgentId && conversationTopicId+ // Waiting is an explicit choice. Cancelling it restores this entry+ // from the topic state; opening or closing the picker consumes nothing.+ isRateLimitError &&+ !conversationTopicScheduled &&+ conversationAgentId &&+ conversationTopicId? () =>createTopicForwardModal({cancelSourceContinuation: true,diff --git a/src/features/Electron/HeterogeneousAgent/StatusGuide/GuideShell.tsx b/src/features/Electron/HeterogeneousAgent/StatusGuide/GuideShell.tsxindex 36839d086b8..d7f442f700c 100644--- a/src/features/Electron/HeterogeneousAgent/StatusGuide/GuideShell.tsx+++ b/src/features/Electron/HeterogeneousAgent/StatusGuide/GuideShell.tsx@@ -14,6 +14,7 @@ interface GuideShellProps {* status, not a full error panel.*/compact?: boolean;+ dismissLabel?: string;headerDescription?: ReactNode;icon: ReactNode;onDismiss?: () => void;@@ -25,6 +26,7 @@ const GuideShell = ({actions,children,compact = false,+ dismissLabel,headerDescription,icon,onDismiss,@@ -73,8 +75,13 @@ const GuideShell = ({>{actionsInHeader && actions}{onDismiss && (- <Tooltip title={t('close')}>- <ActionIcon aria-label={t('close')} icon={X} size="small" onClick={onDismiss} />+ <Tooltip title={dismissLabel ?? t('close')}>+ <ActionIcon+ aria-label={dismissLabel ?? t('close')}+ icon={X}+ size="small"+ onClick={onDismiss}+ /></Tooltip>)}</Flexbox>diff --git a/src/features/Electron/HeterogeneousAgent/StatusGuide/states/RateLimitState.tsx b/src/features/Electron/HeterogeneousAgent/StatusGuide/states/RateLimitState.tsxindex 9eed5b43331..5ad0656f5e3 100644--- a/src/features/Electron/HeterogeneousAgent/StatusGuide/states/RateLimitState.tsx+++ b/src/features/Electron/HeterogeneousAgent/StatusGuide/states/RateLimitState.tsx@@ -1,7 +1,7 @@import { readHeterogeneousErrorContext } from '@lobechat/heterogeneous-agents/errors';import { Button, Flexbox, Text } from '@lobehub/ui';import { CalendarClock, Forward, RotateCcw } from 'lucide-react';-import { useMemo } from 'react';+import { useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import GuideActions from '../GuideActions';@@ -18,7 +18,6 @@ const extractTimezoneLabel = (value?: string) => {const RateLimitState = ({config,error,- onDismiss,onOpenSystemTools,onRetry,onHandoff,@@ -26,6 +25,7 @@ const RateLimitState = ({variant,}: HeterogeneousAgentGuideStateProps) => {const { t, i18n } = useTranslation('chat');+ const [collapsed, setCollapsed] = useState(false);const quotaContext = readHeterogeneousErrorContext({ type: 'AgentRuntimeError', body: error });const rawErrorDetails = error?.stderr || error?.message;const dateLocale = i18n.resolvedLanguage || i18n.language || undefined;@@ -150,25 +150,36 @@ const RateLimitState = ({}): t('cliRateLimitGuide.schedule.titleAfterReset', { name: config.title }): t('cliRateLimitGuide.title', { name: config.title });+ const recoveryActions = scheduleActions ?? (+ <GuideActions+ openSystemToolsLabel={onRetry ? undefined : t('cliRateLimitGuide.actions.openSystemTools')}+ retryLabel={t('cliRateLimitGuide.actions.retry')}+ onOpenSystemTools={onRetry ? undefined : onOpenSystemTools}+ onRetry={onRetry}+ />+ );return (<GuideShell+ compact={collapsed}+ dismissLabel={t('cliRateLimitGuide.actions.collapse')}icon={<config.icon size={24} />}title={title}variant={variant}actions={- scheduleActions ?? (- <GuideActions- retryLabel={t('cliRateLimitGuide.actions.retry')}- openSystemToolsLabel={- onRetry ? undefined : t('cliRateLimitGuide.actions.openSystemTools')- }- onOpenSystemTools={onRetry ? undefined : onOpenSystemTools}- onRetry={onRetry}- />+ collapsed ? (+ <Flexbox horizontal gap={8} style={{ flexWrap: 'wrap' }}>+ {recoveryActions}+ <Button size="small" type="text" onClick={() => setCollapsed(false)}>+ {t('cliRateLimitGuide.actions.showDetails')}+ </Button>+ </Flexbox>+ ) : (+ recoveryActions)}headerDescription={+ !collapsed &&!isScheduled && (<Text type="secondary">{t(@@ -185,38 +196,40 @@ const RateLimitState = ({</Text>)}- onDismiss={onDismiss}+ onDismiss={collapsed ? undefined : () => setCollapsed(true)}>- <Flexbox gap={8}>- {formattedResetAt && (- <Flexbox horizontal gap={8} style={{ alignItems: 'baseline' }}>- <Text strong style={{ fontSize: 12 }}>- {t('cliRateLimitGuide.resetAt')}- </Text>- <Flexbox- horizontal- gap={8}- style={{ alignItems: 'baseline', flexWrap: 'nowrap', whiteSpace: 'nowrap' }}- >- <Text>{`${formattedResetAt}${timezoneLabel ? ` (${timezoneLabel})` : ''}`}</Text>- {relativeResetText && (- <Text style={{ fontSize: 12, whiteSpace: 'nowrap' }} type="secondary">- {relativeResetText}- </Text>- )}+ {!collapsed && (+ <Flexbox gap={8}>+ {formattedResetAt && (+ <Flexbox horizontal gap={8} style={{ alignItems: 'baseline' }}>+ <Text strong style={{ fontSize: 12 }}>+ {t('cliRateLimitGuide.resetAt')}+ </Text>+ <Flexbox+ horizontal+ gap={8}+ style={{ alignItems: 'baseline', flexWrap: 'nowrap', whiteSpace: 'nowrap' }}+ >+ <Text>{`${formattedResetAt}${timezoneLabel ? ` (${timezoneLabel})` : ''}`}</Text>+ {relativeResetText && (+ <Text style={{ fontSize: 12, whiteSpace: 'nowrap' }} type="secondary">+ {relativeResetText}+ </Text>+ )}+ </Flexbox></Flexbox>- </Flexbox>- )}+ )}- {rateLimitTypeLabel && (- <Flexbox horizontal align="center" gap={8}>- <Text strong style={{ fontSize: 12 }}>- {t('cliRateLimitGuide.limitType')}- </Text>- <Text>{rateLimitTypeLabel}</Text>- </Flexbox>- )}- </Flexbox>+ {rateLimitTypeLabel && (+ <Flexbox horizontal align="center" gap={8}>+ <Text strong style={{ fontSize: 12 }}>+ {t('cliRateLimitGuide.limitType')}+ </Text>+ <Text>{rateLimitTypeLabel}</Text>+ </Flexbox>+ )}+ </Flexbox>+ )}</GuideShell>);};