Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(update): 写回任务的安装失败原因按界面语言本地化
Dash8dba37f346db
diff --git a/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts b/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.tsindex 10ec252e2d..af6b8aaa06 100644--- a/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts+++ b/apps/desktop/src/main/agent-app-update/__tests__/agentAppUpdateService.test.ts@@ -238,13 +238,44 @@ describe('Agent app update install', () => {ownerA,'task-1',expect.stringMatching(/^agent-app-update:/),- 'update.agentInstall.failed 下载更新失败,请稍后重试。 update.agentInstall.retryHint',+ 'update.agentInstall.failed update.agentInstall.reasons.downloadFailed update.agentInstall.retryHint',);// Released after the failure.await service.install(caller);expect(deps.requestHostPermission).toHaveBeenCalledTimes(2);});+ it('localizes the failure reason from its error code, never the updater diagnostic text', async () => {+ const { deps, service } = setup({+ translate: (key) =>+ key === 'update.agentInstall.reasons.versionChanged'+ ? 'now {{version}}, confirmed {{confirmed}}'+ : key,+ apply: vi.fn(async () => ({+ status: 'failed' as const,+ reason: '中文诊断文本',+ errorCode: 'version_changed',+ stagedVersion: '0.1.91',+ })),+ });+ await service.install(caller);+ await flush();+ const text = vi.mocked(deps.notify).mock.calls[0]![3];+ expect(text).toContain('now 0.1.91, confirmed 0.1.90');+ expect(text).not.toContain('中文诊断文本');+ });++ it('falls back to a generic localized reason for unknown error codes', async () => {+ const { deps, service } = setup({+ apply: vi.fn(async () => ({ status: 'failed' as const, reason: 'x', errorCode: 'EACCES' })),+ });+ await service.install(caller);+ await flush();+ expect(vi.mocked(deps.notify).mock.calls[0]![3]).toContain(+ 'update.agentInstall.reasons.generic',+ );+ });+it('cancels the restart after an account switch and never writes into the next account', async () => {let restartAllowed: boolean | undefined;const harness = setup({diff --git a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.tsindex d5dfa3b2ec..b17ac5acdb 100644--- a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts+++ b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts@@ -35,7 +35,26 @@ export interface AgentAppUpdateCheck {export type AgentAppUpdateApplyResult =| { status: 'relaunching'; targetVersion?: string }- | { status: 'failed'; reason: string; errorCode?: string };+ | { status: 'failed'; reason: string; errorCode?: string; stagedVersion?: string };++/**+ * User-visible failure text is localized from the stable error code; the+ * updater's own `reason` is Chinese diagnostic text for the model only.+ */+const FAILURE_REASON_KEYS: Record<string, string> = {+ download_failed: 'downloadFailed',+ manifest_failed: 'manifestFailed',+ manual_download: 'manualDownload',+ idle: 'noUpdate',+ version_changed: 'versionChanged',+ relaunch_cancelled: 'notRestarted',+ not_ready: 'notReady',+ relaunch_not_started: 'updaterNotStarted',+ updater_spawn_failed: 'updaterNotStarted',+ unsupported: 'unsupported',+ linux_installation_unsupported: 'unsupported',+ windows_vc_runtime_missing: 'unsupported',+};export interface AgentAppUpdateMarker {requestId: string;@@ -211,20 +230,24 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {const reportFailure = async (owner: AgentAppUpdateOwner,sessionId: string,- requestId: string,- reason: string,+ marker: AgentAppUpdateMarker,+ failure: { errorCode?: string; stagedVersion?: string },) => {// Never write into whichever account replaced the one that confirmed.if (!deps.isOwnerCurrent(owner)) return;+ const reasonKey = FAILURE_REASON_KEYS[failure.errorCode ?? ''] ?? 'generic';const message = [text('update.agentInstall.failed', { version: deps.appVersion() }),- reason,+ text(`update.agentInstall.reasons.${reasonKey}`, {+ version: failure.stagedVersion ?? '',+ confirmed: marker.targetVersion ?? '',+ }),text('update.agentInstall.retryHint'),].filter(Boolean).join(' ');try {- await deps.notify(owner, sessionId, `agent-app-update:${requestId}`, message);+ await deps.notify(owner, sessionId, `agent-app-update:${marker.requestId}`, message);} catch (error) {deps.logger?.warn?.('agent app update failure notice failed', { error: String(error) });}@@ -247,15 +270,15 @@ export function createAgentAppUpdateService(deps: AgentAppUpdateDeps) {// A relaunch ends this process; the next start reports from the marker.if (result.status === 'relaunching') return;deps.marker.clear(owner);- await reportFailure(owner, caller.sessionId, marker.requestId, result.reason);+ deps.logger?.warn?.('agent app update did not restart', {+ errorCode: result.errorCode,+ reason: result.reason,+ });+ await reportFailure(owner, caller.sessionId, marker, result);} catch (error) {deps.marker.clear(owner);- await reportFailure(- owner,- caller.sessionId,- marker.requestId,- String(error instanceof Error ? error.message : error),- );+ deps.logger?.warn?.('agent app update failed', { error: String(error) });+ await reportFailure(owner, caller.sessionId, marker, {});} finally {flow = null;}diff --git a/apps/desktop/src/main/updateService.ts b/apps/desktop/src/main/updateService.tsindex 696f7d3871..b2b23ed3bd 100644--- a/apps/desktop/src/main/updateService.ts+++ b/apps/desktop/src/main/updateService.ts@@ -2156,7 +2156,7 @@ const AGENT_UPDATE_FAILURE_REASONS: Record<Exclude<CheckForUpdateResult, 'ready'export type AgentConfirmedAppUpdateResult =| { status: 'relaunching'; targetVersion?: string }- | { status: 'failed'; reason: string; errorCode?: string };+ | { status: 'failed'; reason: string; errorCode?: string; stagedVersion?: string };/*** Apply an update the user approved on the Host confirmation card. This is the@@ -2180,6 +2180,7 @@ export async function applyConfirmedAppUpdateForAgent(options: {status: 'failed',reason: `当前渠道的新版本是 ${readyVersion ?? '未知版本'},与确认的 ${options.expectedVersion} 不同,本次没有安装;请重新发起更新。`,errorCode: 'version_changed',+ ...(readyVersion ? { stagedVersion: readyVersion } : {}),}: null;const unsupported = agentUpdateUnsupportedReason();diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 8d68e8021d..d8d9e86251 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -8055,7 +8055,19 @@"linuxAuth": "Installing requires your system password on this computer.","succeeded": "{{appName}} is updated to {{version}} (was {{from}}).","failed": "The {{appName}} update did not finish. This computer is still on {{version}}.",- "retryHint": "Ask me to try again later, or check for updates in Settings → About."+ "retryHint": "Ask me to try again later, or check for updates in Settings → About.",+ "reasons": {+ "downloadFailed": "Downloading the update failed. Try again later.",+ "manifestFailed": "Could not read update information for the current channel.",+ "manualDownload": "This installation requires downloading the new version manually.",+ "noUpdate": "The current channel has no installable update for this device.",+ "versionChanged": "The channel now offers {{version}} instead of the confirmed {{confirmed}}, so nothing was installed.",+ "notRestarted": "The update was downloaded but {{appName}} did not restart (for example, you signed out or switched accounts).",+ "notReady": "The downloaded update is no longer available.",+ "updaterNotStarted": "The updater did not start, so {{appName}} did not restart.",+ "unsupported": "This installation does not support in-app updates.",+ "generic": "Something went wrong during installation."+ }},"agentAutoUpdate": {"enableTitle": "Install updates while idle?",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex a5d9502033..16aabc73a5 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -8047,7 +8047,19 @@"linuxAuth": "インストールにはこのコンピューターでのシステムパスワード入力が必要です。","succeeded": "{{appName}} を {{version}} に更新しました(以前は {{from}})。","failed": "{{appName}} の更新は完了しませんでした。現在も {{version}} です。",- "retryHint": "後でもう一度依頼するか、「設定 → 情報」で更新を確認してください。"+ "retryHint": "後でもう一度依頼するか、「設定 → 情報」で更新を確認してください。",+ "reasons": {+ "downloadFailed": "更新のダウンロードに失敗しました。後でもう一度お試しください。",+ "manifestFailed": "現在のチャンネルの更新情報を読み取れませんでした。",+ "manualDownload": "このインストールでは新しいバージョンを手動でダウンロードする必要があります。",+ "noUpdate": "現在のチャンネルにはこのデバイスにインストールできる更新がありません。",+ "versionChanged": "チャンネルの新しいバージョンが確認した {{confirmed}} ではなく {{version}} になったため、インストールしませんでした。",+ "notRestarted": "更新はダウンロードされましたが、再起動しませんでした(途中でサインアウトやアカウント切り替えがあった場合など)。",+ "notReady": "ダウンロード済みの更新は利用できなくなりました。",+ "updaterNotStarted": "アップデーターが起動しなかったため、{{appName}} は再起動していません。",+ "unsupported": "このインストール環境はアプリ内更新に対応していません。",+ "generic": "インストール中にエラーが発生しました。"+ }},"agentAutoUpdate": {"enableTitle": "アイドル時に更新をインストールしますか?",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 5e0110643d..075d59d79e 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -8047,7 +8047,19 @@"linuxAuth": "설치하려면 이 컴퓨터에서 시스템 비밀번호를 입력해야 합니다.","succeeded": "{{appName}}이(가) {{version}}(으)로 업데이트되었습니다(이전 버전 {{from}}).","failed": "{{appName}} 업데이트가 완료되지 않았습니다. 현재 버전은 여전히 {{version}}입니다.",- "retryHint": "나중에 다시 요청하거나 \"설정 → 정보\"에서 업데이트를 확인하세요."+ "retryHint": "나중에 다시 요청하거나 \"설정 → 정보\"에서 업데이트를 확인하세요.",+ "reasons": {+ "downloadFailed": "업데이트를 다운로드하지 못했습니다. 나중에 다시 시도하세요.",+ "manifestFailed": "현재 채널의 업데이트 정보를 읽을 수 없습니다.",+ "manualDownload": "이 설치는 새 버전을 직접 다운로드해야 합니다.",+ "noUpdate": "현재 채널에 이 기기에 설치할 수 있는 업데이트가 없습니다.",+ "versionChanged": "채널의 새 버전이 확인한 {{confirmed}}이(가) 아닌 {{version}}(으)로 바뀌어 설치하지 않았습니다.",+ "notRestarted": "업데이트는 다운로드했지만 다시 시작하지 않았습니다(예: 도중에 로그아웃하거나 계정을 전환한 경우).",+ "notReady": "다운로드한 업데이트를 더 이상 사용할 수 없습니다.",+ "updaterNotStarted": "업데이터가 시작되지 않아 {{appName}}가 다시 시작되지 않았습니다.",+ "unsupported": "이 설치 환경은 앱 내 업데이트를 지원하지 않습니다.",+ "generic": "설치 중 오류가 발생했습니다."+ }},"agentAutoUpdate": {"enableTitle": "유휴 상태일 때 업데이트를 설치할까요?",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex ebebdf14f3..1060b2a221 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -8047,7 +8047,19 @@"linuxAuth": "安装时需要在这台电脑上输入系统密码。","succeeded": "{{appName}} 已更新到 {{version}}(原版本 {{from}})。","failed": "{{appName}} 更新没有完成,当前仍是 {{version}}。",- "retryHint": "可以稍后再让我更新,或在「设置 → 关于」中检查更新。"+ "retryHint": "可以稍后再让我更新,或在「设置 → 关于」中检查更新。",+ "reasons": {+ "downloadFailed": "下载更新失败,请稍后重试。",+ "manifestFailed": "无法读取当前渠道的更新信息。",+ "manualDownload": "当前安装需要手动下载新版本。",+ "noUpdate": "当前渠道没有适用于这台设备的可安装更新。",+ "versionChanged": "当前渠道的新版本已变成 {{version}},与确认的 {{confirmed}} 不同,本次没有安装。",+ "notRestarted": "更新已下载,但本次没有重启(例如期间退出或切换了账号)。",+ "notReady": "已下载的更新不再可用。",+ "updaterNotStarted": "更新器没有启动,{{appName}} 未重启。",+ "unsupported": "当前安装环境不支持应用内更新。",+ "generic": "安装过程中出现错误。"+ }},"agentAutoUpdate": {"enableTitle": "开启空闲时自动安装更新?",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 87f7cdbd6b..784095eace 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -8047,7 +8047,19 @@"linuxAuth": "安裝時需要在這台電腦上輸入系統密碼。","succeeded": "{{appName}} 已更新到 {{version}}(原版本 {{from}})。","failed": "{{appName}} 更新沒有完成,目前仍是 {{version}}。",- "retryHint": "可以稍後再讓我更新,或在「設定 → 關於」中檢查更新。"+ "retryHint": "可以稍後再讓我更新,或在「設定 → 關於」中檢查更新。",+ "reasons": {+ "downloadFailed": "下載更新失敗,請稍後重試。",+ "manifestFailed": "無法讀取目前頻道的更新資訊。",+ "manualDownload": "目前的安裝需要手動下載新版本。",+ "noUpdate": "目前頻道沒有適用於這台裝置的可安裝更新。",+ "versionChanged": "目前頻道的新版本已變成 {{version}},與確認的 {{confirmed}} 不同,這次沒有安裝。",+ "notRestarted": "更新已下載,但這次沒有重新啟動(例如期間登出或切換了帳號)。",+ "notReady": "已下載的更新不再可用。",+ "updaterNotStarted": "更新器沒有啟動,{{appName}} 未重新啟動。",+ "unsupported": "目前的安裝環境不支援應用程式內更新。",+ "generic": "安裝過程中發生錯誤。"+ }},"agentAutoUpdate": {"enableTitle": "開啟閒置時自動安裝更新?",