Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(update): 重启记录不设条数上限,不为新记录丢弃未送达的旧记录
Dash3a601bf314ed
diff --git a/apps/desktop/src/main/agent-app-update/__tests__/restartRecords.test.ts b/apps/desktop/src/main/agent-app-update/__tests__/restartRecords.test.tsindex df5f5690fa..e3d628a9f4 100644--- a/apps/desktop/src/main/agent-app-update/__tests__/restartRecords.test.ts+++ b/apps/desktop/src/main/agent-app-update/__tests__/restartRecords.test.ts@@ -58,3 +58,11 @@ describe('restart records file', () => {expect(fs.readFileSync(file, 'utf8')).toBe('not json');});});++describe('restart records capacity', () => {+ it('never drops an undelivered record to make room for a new one', () => {+ for (let i = 0; i < 25; i += 1) addRestartRecord(file, record(`r${i}`));+ expect(listRestartRecords(file)).toHaveLength(25);+ expect(listRestartRecords(file)[0]!.requestId).toBe('r0');+ });+});diff --git a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.tsindex 48a41db668..9c462a0e4e 100644--- a/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts+++ b/apps/desktop/src/main/agent-app-update/agentAppUpdateService.ts@@ -143,7 +143,6 @@ const UNDELIVERED_REASONS = new Set([]);const MARKER_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;const MAX_PENDING_NOTICES = 20;-export const MAX_RESTART_RECORDS = 20;interface PendingNotice {/** Account id, not a captured scope: a later sign-in of the same account still matches. */diff --git a/apps/desktop/src/main/agent-app-update/restartRecords.ts b/apps/desktop/src/main/agent-app-update/restartRecords.tsindex c0e7cde91b..0272bf40e6 100644--- a/apps/desktop/src/main/agent-app-update/restartRecords.ts+++ b/apps/desktop/src/main/agent-app-update/restartRecords.ts@@ -8,7 +8,7 @@ import path from 'node:path';import { createLogger, maskPath } from '../logger.js';import { atomicWriteFileSync, readAtomicFileSync } from '../utils/atomicWriteFile.js';-import { MAX_RESTART_RECORDS, type AgentAppUpdateMarker } from './agentAppUpdateService.js';+import type { AgentAppUpdateMarker } from './agentAppUpdateService.js';const log = createLogger('agent-app-update');@@ -81,7 +81,8 @@ export function listRestartRecords(file: string): AgentAppUpdateMarker[] {/** Throws when existing records cannot be preserved; the caller then does not restart. */export function addRestartRecord(file: string, record: AgentAppUpdateMarker): void {const records = readRecords(file, 'before-write');- writeRecords(file, [...records, record].slice(-MAX_RESTART_RECORDS));+ // No cap: records leave only when delivered, their task is gone, or after 7 days.+ writeRecords(file, [...records, record]);}export function removeRestartRecord(file: string, requestId: string): void {diff --git a/docs/product-rules/agent-app-update.md b/docs/product-rules/agent-app-update.mdindex f2a4386422..4744b7d062 100644--- a/docs/product-rules/agent-app-update.md+++ b/docs/product-rules/agent-app-update.md@@ -24,7 +24,7 @@ Agent 只能反复引导用户去点「检查更新」;那次收紧的起因- **真的要重启时**:更新器启动前的最后一道检查里,在账号私有目录写一份重启标记(写不进就不重启)。新版本启动、该账号数据库就绪后,把结果(新版本号或「仍是旧版本」)作为一条普通助手消息写回发起任务,桌面和手机重连后都能看到;写入暂时失败保留标记下次再写(按 clientId 去重),任务已不存在或超过- 7 天才丢弃。标记文件按请求逐条保存重启记录,新记录追加而不覆盖,每条各自写回、各自清除。+ 7 天才丢弃。标记文件按请求逐条保存重启记录,新记录追加而不覆盖(不设条数上限,只在写回、任务不存在或超过 7 天时移除),每条各自写回、各自清除。设置页或空闲自动安装已经在重启时,Agent 不认领那次重启,直接说明 Cindy 已在重启更新。- **没有重启时**(下载失败、版本变化、切换账号取消、更新器没启动等):不写磁盘,按错误码生成本地化原因放进内存待写回列表,立即写回;写不进或原账号不在时保留,在该账号下次就绪或下次发起更新时重试。