Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 分叉失败时显示远程 Agent 错误的本地化文案
david82d6dce9601b
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex dbf310ca16..fe531bb74a 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -229,6 +229,7 @@ import { ComposerRichInput, type ComposerRichInputHandle } from '@/session/Compoimport { createComposerDraftSource, useComposerVoiceDraftWriter, type ComposerDraftSource } from '@/session/composerDraftSource';import { InlineQueueSection } from '@/session/InlineQueueSection';import { inputProjectionErrorI18nKey } from '@/session/inputProjectionError';+import { remoteActionErrorI18nKey } from '@/session/agentErrorI18n';import { RewindPreviewPanel } from '@/session/RewindPreviewPanel';import { BlurBackdrop, FLOATING_CHROME_BLUR_INTENSITY } from '@/session/BlurBackdrop';import { SheetModal } from '@/session/SheetModal';@@ -9444,8 +9445,9 @@ function SessionScreenContent() {});} catch (err) {const detail = formatRemoteError(err);- const projectionKey = inputProjectionErrorI18nKey(detail);- setError(projectionKey ? t(projectionKey) : detail);+ // 远程 Agent 的分叉失败(如 REMOTE_AGENT_FORK_FAILED)用 session.remoteError 的本地化文案,不显示原始错误码。+ const key = inputProjectionErrorI18nKey(detail) ?? remoteActionErrorI18nKey(detail);+ setError(key ? t(key) : detail);} finally {setMessageActionBusy(null);}diff --git a/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx b/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsxindex dfba1ee996..3215076375 100644--- a/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx+++ b/apps/mobile/src/__tests__/AgentErrorLocalization.test.tsx@@ -2,7 +2,7 @@import { act, type ReactNode } from 'react';import { readFileSync } from 'node:fs';import { parseAgentErrorCode } from '@cindy/maker-shared/error-redaction';-import { unclassifiedAgentErrorI18nKey, requiresAgentErrorConfigurationChange } from '@/session/agentErrorI18n';+import { remoteActionErrorI18nKey, unclassifiedAgentErrorI18nKey, requiresAgentErrorConfigurationChange } from '@/session/agentErrorI18n';import { createRoot, type Root } from 'react-dom/client';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { i18n } from '@/i18n';@@ -159,6 +159,16 @@ describe.each(SUPPORTED_LOCALES)('known mobile remote errors in %s', locale => {expect(normalized.body).toBe(i18n.t(key));});+ // The fork action showed the raw "[IPC_ERROR] [REMOTE_AGENT_FORK_FAILED] …" string; it must use+ // the localized remote copy, while unknown codes keep the caller's own fallback.+ it('localizes a remote fork failure in one-shot action errors', async () => {+ await i18n.changeLanguage(locale);+ expect(remoteActionErrorI18nKey('[IPC_ERROR] [REMOTE_AGENT_FORK_FAILED] the conversation could not be forked'))+ .toBe('session.remoteError.REMOTE_AGENT_FORK_FAILED');+ expect(remoteActionErrorI18nKey('[REMOTE_FUTURE] private diagnostic')).toBeNull();+ expect(remoteActionErrorI18nKey('[NOT_FOUND] message missing')).toBeNull();+ });+it('has every desktop bracket-code translation without relying on fallback languages', async () => {await i18n.changeLanguage(locale);const desktop = JSON.parse(readFileSync(`../desktop/src/renderer/i18n/locales/${locale}/common.json`, 'utf8'));diff --git a/apps/mobile/src/session/agentErrorI18n.ts b/apps/mobile/src/session/agentErrorI18n.tsindex 70ad2fb0a8..f632d27550 100644--- a/apps/mobile/src/session/agentErrorI18n.ts+++ b/apps/mobile/src/session/agentErrorI18n.ts@@ -83,6 +83,16 @@ export function unclassifiedAgentErrorI18nKey(message: string, sessionSource?: u: 'session.tail.replyFailed';}+/**+ * Copy for a recognized remote / runtime code in a one-shot action error (fork and the like).+ * Unknown codes return null so the caller keeps its own fallback instead of "reply failed".+ */+export function remoteActionErrorI18nKey(message: string): string | null {+ const code = parseAgentErrorCode(message)?.code;+ const key = code ? `session.remoteError.${code}` : null;+ return key && i18n.exists(key) ? key : null;+}+export function localizeUnclassifiedAgentError(message: string, sessionSource?: unknown): string {return i18n.t(unclassifiedAgentErrorI18nKey(message, sessionSource));}