Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): localize post-terminal IM recovery notices
zqchris4772216379dc
diff --git a/apps/desktop/src/main/hook-control/__tests__/dispatcher.test.ts b/apps/desktop/src/main/hook-control/__tests__/dispatcher.test.tsindex 945d7391f5..134335b357 100644--- a/apps/desktop/src/main/hook-control/__tests__/dispatcher.test.ts+++ b/apps/desktop/src/main/hook-control/__tests__/dispatcher.test.ts@@ -10,6 +10,7 @@ import { describe, expect, it, vi } from 'vitest';import { Session, type AgentEvent, type AgentSessionHandle, type Capabilities } from '@cindy/maker-core';import { observeHookTurn } from '../turnObserver';import { bindRuntimeRecoveryNotice } from '../../im/shared/runtimeRecoveryNotice';+import { setMainLocale } from '../../i18n';import {HOOK_FEATURE_MESSAGE_OPS,@@ -244,7 +245,14 @@ function makeDispatcher(overrides?: {}describe('post-terminal runtime recovery delivery', () => {- it('delivers after the production observer unsubscribes, without replaying the successful turn', async () => {+ it.each([+ ['en', 'Pi extensions could not be refreshed. Restart Cindy before using Pi again.'],+ ['zh-CN', 'Pi 扩展未能完成刷新。请重启 Cindy 后再使用 Pi。'],+ ['zh-TW', 'Pi 擴充功能未能完成重新整理。請重新啟動 Cindy 後再使用 Pi。'],+ ['ja', 'Pi 拡張機能を更新できませんでした。Pi を再び使用する前に Cindy を再起動してください。'],+ ['ko', 'Pi 확장을 새로 고치지 못했습니다. Pi를 다시 사용하기 전에 Cindy를 다시 시작하세요.'],+ ] as const)('delivers localized %s recovery after the observer unsubscribes, without replay', async (locale, expected) => {+ setMainLocale(locale);let terminal!: () => void;const terminalReady = new Promise<void>(resolve => { terminal = resolve; });let end!: () => void;@@ -298,7 +306,8 @@ describe('post-terminal runtime recovery delivery', () => {const notices = c.ofType('msg.op').filter(m => m.payload.action.kind === 'send');expect(notices).toHaveLength(1);expect(notices[0]?.payload).toMatchObject({ scope: { externalKey: telegramDispatch().externalKey },- action: { kind: 'send', text: 'restart-cindy-to-refresh-packages' } });+ action: { kind: 'send', text: expected } });+ expect(JSON.stringify(notices)).not.toContain('restart-cindy-to-refresh-packages');expect(notices[0]?.payload.requestId).toBeUndefined();expect(noticeResult).not.toHaveBeenCalled(); // Socket send is not channel delivery.d.onMessageOpResult({ opId: notices[0]!.payload.opId, ok: true, messageId: 'notice-1' });@@ -312,6 +321,7 @@ describe('post-terminal runtime recovery delivery', () => {vi.mocked(handle.close).mockImplementation(async () => { end(); });await session.close().catch(() => session.close());d.dispose();+ setMainLocale('en');}});diff --git a/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts b/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.tsindex 2f66a8e091..7ac26f1821 100644--- a/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts+++ b/apps/desktop/src/main/im/shared/__tests__/turnRunnerSendOutcome.test.ts@@ -24,6 +24,7 @@ import type {TurnPermissionPolicy,} from '@cindy/maker-core';import type { ChannelIM } from '@cindy/im';+import { setMainLocale } from '../../../i18n';const mocks = vi.hoisted(() => ({logger: {@@ -1035,6 +1036,7 @@ describe('turnRunner send outcome policy (feishu adapter characterization)', ()});it('sends retirement recovery separately after the personal IM turn has completed', async () => {+ setMainLocale('zh-CN');const terminal = deferred<void>();const ended = deferred<void>();const closeFailure = deferred<void>();@@ -1068,13 +1070,14 @@ describe('turnRunner send outcome policy (feishu adapter characterization)', ()closeFailure.resolve();await waitForAssertion(() => expect(session.getStatus()).toBe('error'));expect(mocks.feishuIm.sendText).toHaveBeenCalledExactlyOnceWith('ou_user',- 'restart-cindy-to-refresh-packages', { threadTs: undefined });+ 'Pi 扩展未能完成刷新。请重启 Cindy 后再使用 Pi。', { threadTs: undefined });expect(complete).toHaveBeenCalledOnce();expect(handle.send).toHaveBeenCalledOnce();} finally {closeFailure.resolve();vi.mocked(handle.close).mockImplementation(async () => { ended.resolve(); });await session.close();+ setMainLocale('en');}});diff --git a/apps/desktop/src/main/im/shared/runtimeRecoveryNotice.ts b/apps/desktop/src/main/im/shared/runtimeRecoveryNotice.tsindex 3f963a4bee..88fc640296 100644--- a/apps/desktop/src/main/im/shared/runtimeRecoveryNotice.ts+++ b/apps/desktop/src/main/im/shared/runtimeRecoveryNotice.ts@@ -1,4 +1,5 @@import type { Session } from '@cindy/maker-core';+import { t } from '../../i18n';// One actual channel owner per runtime. A product terminal does not unsubscribe:// retirement can fail afterwards. Runtime termination/replacement releases it.@@ -20,11 +21,11 @@ export function bindRuntimeRecoveryNotice(const offEvent = session.onEvent((event) => {if (!event.runtimeRecovery || event.sessionInstanceId !== session.instanceId|| event.sessionTurnGeneration !== generation || event.type !== 'text') return;- const text = (event.data as { text?: unknown } | null)?.text;- if (typeof text !== 'string' || !text) return;cleanup(); // Claim once before invoking any asynchronous channel operation.try {- void deliver(text).then((result) => {+ // No model consumes this post-terminal notice. Keep the machine receipt+ // on the internal event; never expose its JSON/protocol enum to the channel.+ void deliver(t('settings.piPackages.failure.runtimeRetirementFailed')).then((result) => {if (result === false) log.warn('runtime recovery channel notice was not delivered');}).catch(() => log.warn('runtime recovery channel notice delivery failed'));} catch {diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex b8d25f0d3b..ca030b7b48 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -3171,6 +3171,7 @@"packageNotFound": "The package was not found. Check the package name or repository URL.","versionNotFound": "That version was not found. Choose an available version and try again.","stateUnavailable": "Cindy could not read the Pi extension state. Restart Cindy and try again.",+ "runtimeRetirementFailed": "Pi extensions could not be refreshed. Restart Cindy before using Pi again.","runtimeConvergencePartial": "The Pi extension change was saved, but some local Pi tasks may still be running the old extension. Restart Cindy before using Pi again.","nativeCommandFailed": "Pi's package command failed. Check the source or version and try again."},diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex fd110665f0..7bf8108da0 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -3170,6 +3170,7 @@"packageNotFound": "パッケージが見つかりません。パッケージ名またはリポジトリ URL を確認してください。","versionNotFound": "そのバージョンが見つかりません。利用可能なバージョンを選んで再試行してください。","stateUnavailable": "Cindy は Pi 拡張機能の状態を読み取れませんでした。Cindy を再起動して再試行してください。",+ "runtimeRetirementFailed": "Pi 拡張機能を更新できませんでした。Pi を再び使用する前に Cindy を再起動してください。","runtimeConvergencePartial": "Pi 拡張機能の変更は保存されましたが、一部のローカル Pi タスクが古い拡張機能を実行中の可能性があります。Pi を再び使用する前に Cindy を再起動してください。","nativeCommandFailed": "Pi のネイティブパッケージコマンドが失敗しました。ソースまたはバージョンを確認してください。"},diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex a178573686..98e1e60497 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -3170,6 +3170,7 @@"packageNotFound": "패키지를 찾지 못했습니다. 패키지 이름이나 저장소 URL을 확인하세요.","versionNotFound": "해당 버전을 찾지 못했습니다. 사용 가능한 버전을 선택해 다시 시도하세요.","stateUnavailable": "Cindy가 Pi 확장 상태를 읽지 못했습니다. Cindy를 다시 시작한 뒤 다시 시도하세요.",+ "runtimeRetirementFailed": "Pi 확장을 새로 고치지 못했습니다. Pi를 다시 사용하기 전에 Cindy를 다시 시작하세요.","runtimeConvergencePartial": "Pi 확장 변경 사항은 저장되었지만 일부 로컬 Pi 작업에서 이전 확장이 계속 실행 중일 수 있습니다. Pi를 다시 사용하기 전에 Cindy를 다시 시작하세요.","nativeCommandFailed": "Pi 기본 패키지 명령에 실패했습니다. 소스나 버전을 확인한 뒤 다시 시도하세요."},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 8e2c431964..71523ef1b7 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -3170,6 +3170,7 @@"packageNotFound": "没有找到这个包。请检查包名或仓库地址。","versionNotFound": "没有找到这个版本。请选择可用版本后重试。","stateUnavailable": "Cindy 无法读取 Pi 扩展状态。请重启 Cindy 后重试。",+ "runtimeRetirementFailed": "Pi 扩展未能完成刷新。请重启 Cindy 后再使用 Pi。","runtimeConvergencePartial": "Pi 扩展更改已保存,但部分本机 Pi 任务可能仍在运行旧扩展。请重启 Cindy 后再使用 Pi。","nativeCommandFailed": "Pi 原生包命令失败。请检查来源或版本后重试。"},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 0f37527d8f..82e551fe7a 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -3170,6 +3170,7 @@"packageNotFound": "找不到這個套件。請檢查套件名稱或儲存庫網址。","versionNotFound": "找不到這個版本。請選擇可用版本後重試。","stateUnavailable": "Cindy 無法讀取 Pi 擴充功能狀態。請重新啟動 Cindy 後重試。",+ "runtimeRetirementFailed": "Pi 擴充功能未能完成重新整理。請重新啟動 Cindy 後再使用 Pi。","runtimeConvergencePartial": "Pi 擴充功能變更已儲存,但部分本機 Pi 任務可能仍在執行舊擴充功能。請重新啟動 Cindy 後再使用 Pi。","nativeCommandFailed": "Pi 原生套件命令失敗。請檢查來源或版本後重試。"},