Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 拦截过期变更并统一消息术语
DavidShen718b922e5fb9
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex c0e3a41804..85ad8aa591 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -4469,12 +4469,12 @@},"review": {"turn": {- "title": "本轮变更",+ "title": "本条消息的变更","currentWorkspace": "当前工作区",- "localOnly": "本轮精确变更暂不支持远程任务。",- "partialNotice": "本轮包含无法精确追踪的命令或工具写入;以下仅展示已精确捕获的部分,不能视为完整补丁。",+ "localOnly": "本条消息的精确变更暂不支持远程任务。",+ "partialNotice": "本条消息包含无法精确追踪的命令或工具写入;以下仅展示已精确捕获的部分,不能视为完整补丁。","emptyTitle": "没有已记录的变更",- "emptyDesc": "本轮保存的补丁中没有可显示的文件变更。"+ "emptyDesc": "这条消息记录的补丁中没有可显示的文件变更。"},"fileCount_one": "{{count}} 个文件","fileCount_other": "{{count}} 个文件",@@ -6201,23 +6201,23 @@},"turnChanges": {"title": "已更改 {{count}} 个文件",- "partialTitle": "本轮文件变更未完整记录",+ "partialTitle": "本条消息的文件变更未完整记录","review": "审查","undo": "撤销",- "undoAria": "撤销本轮改动",- "undoPartialAria": "撤销本轮中已精确记录的改动",+ "undoAria": "撤销本条消息的改动",+ "undoPartialAria": "撤销本条消息中已精确记录的改动","reapply": "重新应用",- "reapplyAria": "重新应用本轮改动",- "reapplyPartialAria": "重新应用本轮中已精确记录的改动",- "undoSuccess": "已撤销本轮改动",- "reapplySuccess": "已重新应用本轮改动",+ "reapplyAria": "重新应用本条消息的改动",+ "reapplyPartialAria": "重新应用本条消息中已精确记录的改动",+ "undoSuccess": "已撤销本条消息的改动",+ "reapplySuccess": "已重新应用本条消息的改动","undoPartialSuccess": "已撤销精确记录的改动;未记录的改动未被撤销","reapplyPartialSuccess": "已重新应用精确记录的改动;未记录的改动未被重新应用","actionRunning": "请等待当前回复结束后再更改工作区","gitUnavailable": "未检测到 Git。请在本机安装 Git 并确保它已加入系统 PATH,然后重启 Cindy,即可使用完整的撤销和重新应用功能。",- "actionConflict": "工作区内容已变化,无法安全应用本轮补丁;请先审查当前改动",- "actionUnavailable": "本轮包含无法安全撤销的文件变更",- "actionFailed": "未能应用本轮改动,请重试",+ "actionConflict": "工作区内容已变化,无法安全应用本条消息的补丁;请先审查当前改动",+ "actionUnavailable": "本条消息包含无法安全撤销的文件变更",+ "actionFailed": "未能应用本条消息的改动,请重试","partial": "仅记录了可精确捕获的部分变更","partialReversible": "仅撤销或重新应用已精确记录的变更;未记录的改动不会由此操作处理","partialActionHint": "仅撤销或重新应用已精确记录的文件变更",diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex 4fb6343e6f..001a129607 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -19182,6 +19182,71 @@ describe('CodexAgent context window reporting', () => {await handle.close();});+ it('ignores descendant diffs that arrive after the child turn is terminal', async () => {+ const agent = new CodexAgent(createDeps());+ const host = installFakeHost(agent);+ const handle = await agent.startSession({+ sessionId: 'session-terminal-descendant-diff',+ model: 'gpt-5.4',+ workingDir: '/repo',+ });+ const events: AgentEvent[] = [];+ void (async () => {+ for await (const event of handle.events()) events.push(event);+ })();+ const handlers = host.getThreadHandlers();+ if (!handlers?.descendantThreadStarted || !handlers.descendantNotification) {+ throw new Error('expected descendant handlers');+ }++ handlers.turnStarted?.({ threadId: 'start-thread-id', turn: { id: 'turn-terminal-child' } });+ handlers.descendantThreadStarted({+ thread: { id: 'child-terminal-diff', parentThreadId: 'start-thread-id' },+ });+ handlers.descendantNotification('child-terminal-diff', 'turn/diff/updated', {+ threadId: 'child-terminal-diff',+ turnId: 'child-terminal-turn',+ diff: 'diff --git a/child.txt b/child.txt\n--- a/child.txt\n+++ b/child.txt\n@@ -1 +1 @@\n-old\n+child-final\n',+ });+ handlers.descendantNotification('child-terminal-diff', 'turn/completed', {+ threadId: 'child-terminal-diff',+ turn: { id: 'child-terminal-turn', status: 'completed' },+ });+ await vi.waitFor(() => {+ const last = events.filter((event) => event.type === 'turn_diff').at(-1);+ expect((last?.data as { diff?: string } | undefined)?.diff).toContain('+child-final');+ });+ handlers.turnCompleted?.({+ threadId: 'start-thread-id',+ turn: { id: 'turn-terminal-child', status: 'completed' },+ });+ handlers.turnStarted?.({+ threadId: 'start-thread-id',+ turn: { id: 'turn-after-terminal-child' },+ });+ handlers.descendantNotification('child-terminal-diff', 'turn/diff/updated', {+ threadId: 'child-terminal-diff',+ turnId: 'child-terminal-turn',+ diff: 'diff --git a/child.txt b/child.txt\n--- a/child.txt\n+++ b/child.txt\n@@ -1 +1 @@\n-old\n+stale-late-child\n',+ });+ handlers.turnDiffUpdated?.({+ threadId: 'start-thread-id',+ turnId: 'turn-after-terminal-child',+ diff: 'diff --git a/root.txt b/root.txt\n--- a/root.txt\n+++ b/root.txt\n@@ -1 +1 @@\n-old\n+root-current\n',+ });++ await vi.waitFor(() => {+ const last = events.filter((event) => event.type === 'turn_diff').at(-1);+ const diff = (last?.data as { diff?: string } | undefined)?.diff ?? '';+ expect(last?.data).toMatchObject({ turnId: 'turn-after-terminal-child' });+ expect(diff).toContain('+root-current');+ expect(diff).not.toContain('+child-final');+ expect(diff).not.toContain('+stale-late-child');+ });++ await handle.close();+ });+it('merges same-file descendant hunks without duplicating the diff block', async () => {const agent = new CodexAgent(createDeps());const host = installFakeHost(agent);diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex df36a6b53e..2915b3851f 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -3595,6 +3595,7 @@ export class CodexAgent extends BaseAgent {const diffParams = params as { turnId?: unknown; diff?: unknown } | null;if (currentTurnId+ && !descendantTurnIsTerminal&& diffParams&& typeof diffParams.turnId === 'string'&& typeof diffParams.diff === 'string'