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。

fix(mobile): 续跑复用历史错误的不可重试判定

Dashd45f258f68e8
diff --git a/apps/mobile/src/__tests__/InlineQueueSection.test.tsx b/apps/mobile/src/__tests__/InlineQueueSection.test.tsx
index 9ce1d18740..c807fe66e1 100644
--- a/apps/mobile/src/__tests__/InlineQueueSection.test.tsx
+++ b/apps/mobile/src/__tests__/InlineQueueSection.test.tsx
@@ -88,6 +88,20 @@ it('continues a settled error without replaying its old scheduled input', async
expect(retry).toHaveBeenCalledOnce();
expect(onContinueAfterError).toHaveBeenCalledOnce();
});
+// #7119 review: a host-confirmed scheduler failure without a retry token must
+// obey the existing history-error exclusions. Unit: render the real component;
+// previously these three minimal errors exposed a continuation action.
+it.each([
+ 'codex not authenticated: no_credentials',
+ 'thread not found',
+ 'invalid_encrypted_content',
+])('does not offer continuation for a non-retryable error: %s', async (error) => {
+ const onContinueAfterError = vi.fn();
+ await show({ projection: { ...projection, error, errorRetryText: null, errorCanContinue: true }, onContinueAfterError });
+ expect(button('retry')).toBeNull();
+ expect(button('clearError').disabled).toBe(false);
+ expect(onContinueAfterError).not.toHaveBeenCalled();
+});
// Review #6347: the real error actions must announce in-flight work, separately
// from read-only disabling. Existing tests only checked activation, not VoiceOver
// state. Minimal input: busy=true with a recovery action; unit (RN props -> DOM).
diff --git a/apps/mobile/src/session/InlineQueueSection.tsx b/apps/mobile/src/session/InlineQueueSection.tsx
index d06081bd56..993d6d17f3 100644
--- a/apps/mobile/src/session/InlineQueueSection.tsx
+++ b/apps/mobile/src/session/InlineQueueSection.tsx
@@ -29,7 +29,7 @@ import { describeAgentAuthError } from '@/device-link/remoteStatus';
import type { InputProjection } from '@/session/types';
import type { ErrorDiagnosisSource } from '@/session/errorDiagnosisPrompt';
import { inputProjectionErrorI18nKey } from '@/session/inputProjectionError';
-import { localizeAgentError, localizeUnclassifiedAgentError, requiresAgentErrorConfigurationChange } from '@/session/agentErrorI18n';
+import { describeNonRetryableAgentError, localizeAgentError, localizeUnclassifiedAgentError, requiresAgentErrorConfigurationChange } from '@/session/agentErrorI18n';
import {
fontWeight,
iconSize,
@@ -84,7 +84,10 @@ export function InlineQueueSection({
const controlsDisabled = busy || !!readOnlyReason;
const errorDisabledReason = readOnlyReason
|| (busy ? t('message.queuePresentation.row.busy') : null);
- const retryable = !requiresAgentErrorConfigurationChange(projection.error ?? '');
+ // Keep token-based retries on their existing path; hidden continuation uses
+ // the same exclusions as the persisted-tail continuation action.
+ const retryable = !requiresAgentErrorConfigurationChange(projection.error ?? '')
+ && (!!projection.errorRetryText || describeNonRetryableAgentError(projection.error ?? '') === null);
const retryDisabledReason = errorDisabledReason
|| (!projection.errorRetryText && !onContinueAfterError ? t('message.queue.noRetryContent') : null);
const localizedAgentError = localizeAgentError(
diff --git a/apps/mobile/src/session/agentErrorI18n.ts b/apps/mobile/src/session/agentErrorI18n.ts
index 9ab212e764..2bdba0a945 100644
--- a/apps/mobile/src/session/agentErrorI18n.ts
+++ b/apps/mobile/src/session/agentErrorI18n.ts
@@ -1,6 +1,20 @@
import { isResponsesLiteParallelToolCallsError, parseAgentErrorCode } from '@cindy/maker-shared/error-redaction';
export { requiresAgentErrorConfigurationChange } from '@cindy/maker-shared/error-redaction';
import { i18n } from '@/i18n';
+import { describeAgentAuthError } from '@/device-link/remoteStatus';
+
+/**
+ * Mobile history errors and recovery-less live failures share this guidance.
+ * Retrying cannot fix missing host credentials, a lost Codex thread or content
+ * encrypted for a different provider. Desktop has additional local-context gates.
+ */
+export function describeNonRetryableAgentError(text: string): string | null {
+ const authGuidance = describeAgentAuthError(text);
+ if (authGuidance) return authGuidance;
+ if (/thread not found/i.test(text)) return i18n.t('session.tail.codexThreadLost');
+ if (/invalid_encrypted_content/i.test(text)) return i18n.t('session.tail.encryptedContentInvalid');
+ return null;
+}
export type MobileToolLoopErrorKind = 'consecutive' | 'pingpong' | 'rotation' | 'contract';
diff --git a/apps/mobile/src/session/sessionTailBannerModel.ts b/apps/mobile/src/session/sessionTailBannerModel.ts
index c4366ef484..080dd75453 100644
--- a/apps/mobile/src/session/sessionTailBannerModel.ts
+++ b/apps/mobile/src/session/sessionTailBannerModel.ts
@@ -26,10 +26,9 @@ import {
messageContentToPreview,
sortMessagesByCreatedAt,
} from '@cindy/maker-shared/message-normalize';
-import { describeAgentAuthError } from '@/device-link/remoteStatus';
-import { i18n } from '@/i18n';
import type { InputProjection, QueuedRemoteMessage, RemoteMessage, RemoteSession } from '@/session/types';
import {
+ describeNonRetryableAgentError,
localizeAgentError,
requiresAgentErrorConfigurationChange,
localizeUnclassifiedAgentError,
@@ -106,7 +105,7 @@ export function resolveSessionTailBanner(input: ResolveSessionTailBannerInput):
const tail = findErrorTailMessage(input.messages);
if (tail && !input.hiddenErrorClientIds.has(tail.clientId)) {
- const nonRetryableGuidance = describeNonRetryableTailError(tail.text);
+ const nonRetryableGuidance = describeNonRetryableAgentError(tail.text);
const agentErrorGuidance = localizeAgentError(tail.reason, tail.toolLoop);
return {
kind: 'error-tail',
@@ -135,31 +134,6 @@ export function resolveSessionTailBanner(input: ResolveSessionTailBannerInput):
return null;
}
-/**
- * 不可重试的持久化尾行错误 → 引导文案(null = 可重试,展示原文)。对齐桌面
- * ErrorBanner hide-Retry 门控的核心子集——这些错误重试只会撞同一个失败循环:
- * - agent 未鉴权(describeAgentAuthError 模板):凭证在被控电脑上,手机改不了;
- * - codex thread not found:进程重启 / 鉴权模式切换后旧 thread 已随旧进程销毁;
- * - invalid_encrypted_content:换供应商后协议加密内容不可用,需回桌面处理
- * (fork 剥离入口仅桌面本地 codex 会话有)。
- * 桌面还有依赖本地上下文的更细分支(codex 401 区分 oauth-bearer / 网关 key、
- * session-expired 的登录引导等),手机端拿不到对应信号,不搬——这些场景重试
- * 失败后错误会重新浮现,不破坏数据。
- */
-function describeNonRetryableTailError(
- text: string,
-): string | null {
- const authGuidance = describeAgentAuthError(text);
- if (authGuidance) return authGuidance;
- if (/thread not found/i.test(text)) {
- return i18n.t('session.tail.codexThreadLost');
- }
- if (/invalid_encrypted_content/i.test(text)) {
- return i18n.t('session.tail.encryptedContentInvalid');
- }
- return null;
-}
-
interface ErrorTailMessage {
clientId: string;
text: string;