Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 隐藏自动重试期间重复的错误横幅 (#4470)
Dash08e95629d4c0
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 1ede34b3bd..238ddb7a2c 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -280,6 +280,7 @@ import {import { shouldFallbackVendorModel } from './lib/vendorModelFallback';import { localizeAgentStatus } from './lib/localizeAgentStatus';import { createSessionRefreshSequence } from './lib/sessionRefreshSequence';+import { hasInlineOverloadRetry } from './lib/inlineRetryError';import { createSessionSnapshotPatchBuffer } from './lib/sessionSnapshotPatchBuffer';import { readPanelCollapsedRecord } from '@/layout/collapsePrefs';import {@@ -4905,7 +4906,14 @@ export function CCAgentSessionView({/>)}- {!readOnly && error && (+ {/* 只隐藏已有同一错误活动行的过载重试;认证、额度等操作入口照常保留。 */}+ {!readOnly && error && !hasInlineOverloadRetry({+ error,+ errorReason,+ isRecoverable: errorIsRecoverable,+ messages,+ continuationTurnClientId,+ }) && (<ErrorBannererror={error}errorReason={errorReason}diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/inlineRetryError.test.ts b/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/inlineRetryError.test.tsnew file mode 100644index 0000000000..0c342d19fa--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/inlineRetryError.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from 'vitest';+import type { ChatMessage } from '@/lib/makerChatStore';+import { hasInlineOverloadRetry } from '../inlineRetryError';++const capacity = 'Selected model is at capacity.';+const pending: ChatMessage = {+ clientId: '__auto_resume_pending__',+ role: 'assistant',+ content: '',+ systemCardType: 'auto-resume-pending',+ systemCardData: { error: capacity, attempt: 1, maxAttempts: 5 },+};+const input = {+ error: `${capacity} (auto-retry 3/4)`,+ errorReason: 'upstream-overload',+ isRecoverable: true,+ messages: [pending],+ continuationTurnClientId: null as string | null,+};++describe('duplicate inline overload retry', () => {+ it('hides duplicate progress even when host and provider budgets differ', () => {+ expect(hasInlineOverloadRetry(input)).toBe(true);+ });++ it('keeps overload feedback when there is no matching inline row', () => {+ expect(hasInlineOverloadRetry({ ...input, messages: [] })).toBe(false);+ expect(hasInlineOverloadRetry({+ ...input, messages: [{ ...pending, systemCardData: { error: 'other failure' } }],+ })).toBe(false);+ });++ it.each([+ 'Reconnecting... 1/5 (401 Missing bearer)',+ 'Reconnecting... 1/5 (rate limit)',+ 'exceeded retry limit (rate-limit-retry 1/2)',+ 'Reconnecting... 1/5',+ ])('preserves actionable or otherwise unmatched recovery: %s', (error) => {+ expect(hasInlineOverloadRetry({ ...input, error, errorReason: null })).toBe(false);+ });++ it('keeps terminal failures, including those carrying a stale retry suffix', () => {+ expect(hasInlineOverloadRetry({ ...input, isRecoverable: false })).toBe(false);+ expect(hasInlineOverloadRetry({ ...input, error: capacity })).toBe(false);+ });++ it('only uses an unfinished persisted row owned by the current continuation', () => {+ const row: ChatMessage = { ...pending, role: 'user', systemCardType: 'auto-resume' };+ expect(hasInlineOverloadRetry({ ...input, messages: [row] })).toBe(false);+ const owned = { ...input, messages: [row], continuationTurnClientId: row.clientId };+ expect(hasInlineOverloadRetry(owned)).toBe(true);+ expect(hasInlineOverloadRetry({+ ...owned, messages: [{ ...row, systemCardData: { ...row.systemCardData, outcome: 'failed' } }],+ })).toBe(false);+ });+});diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/inlineRetryError.ts b/apps/desktop/src/renderer/features/cc-agent/lib/inlineRetryError.tsnew file mode 100644index 0000000000..342c4791c8--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/lib/inlineRetryError.ts@@ -0,0 +1,38 @@+import type { ChatMessage } from '@/lib/makerChatStore';+import { isOverloadErrorMessage, parseOverloadRetryProgress } from '@/utils/overloadError';++/** Only suppress duplicate overload progress, never actionable auth/quota errors. */+export function hasInlineOverloadRetry({+ error,+ errorReason,+ isRecoverable,+ messages,+ continuationTurnClientId,+}: {+ error: string | null;+ errorReason: string | null;+ isRecoverable: boolean;+ messages: readonly ChatMessage[];+ continuationTurnClientId: string | null;+}): boolean {+ if (+ !isRecoverable ||+ !error ||+ !isOverloadErrorMessage(error, undefined, errorReason) ||+ !parseOverloadRetryProgress(error)+ ) return false;++ const originalError = error.replace(/\s*\(auto-retry\s+\d+\s*\/\s*\d+\)\s*$/, '').trim();+ return messages.some((message) => {+ const pending = message.systemCardType === 'auto-resume-pending';+ const ownedContinuation =+ message.systemCardType === 'auto-resume' &&+ message.clientId === continuationTurnClientId;+ return (+ (pending || ownedContinuation) &&+ message.systemCardData?.outcome === undefined &&+ typeof message.systemCardData?.error === 'string' &&+ message.systemCardData.error.trim() === originalError+ );+ });+}