Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop,maker-shared): 计划泡泡按终态章退场,不再伪造完成
Kafeifeif22cbd801015
diff --git a/apps/desktop/src/main/__tests__/messagePersistBroadcaster.test.ts b/apps/desktop/src/main/__tests__/messagePersistBroadcaster.test.tsindex eac8f150d0..fa87f2a4e0 100644--- a/apps/desktop/src/main/__tests__/messagePersistBroadcaster.test.ts+++ b/apps/desktop/src/main/__tests__/messagePersistBroadcaster.test.ts@@ -186,7 +186,7 @@ describe('update_plan tool_use persistence', () => {);});- it('persists a successful turn plan as completed so reload cannot resurrect progress', async () => {+ it('seals a successful turn plan as-is so reload cannot resurrect it', async () => {const persistId = onToolUseEvent(SESSION,{@@ -218,11 +218,13 @@ describe('update_plan tool_use persistence', () => {{toolUseId: 'plan:turn-1',toolName: 'update_plan',+ // 步骤原样落库(Codex 报的就是 in_progress),退场靠下面这枚章,+ // 不靠把没干完的步骤改成 completed。input: {explanation: 'keep this field',plan: [{ step: 'Inspect', status: 'completed' },- { step: 'Start dev', status: 'completed' },+ { step: 'Start dev', status: 'in_progress' },],},terminalPlanSnapshot: true,@@ -235,6 +237,36 @@ describe('update_plan tool_use persistence', () => {);});+ /**+ * 现场 bug 的确切形态:活儿干完了,Codex 收尾时没有再发一次 plan 更新,+ * 于是 done 上压根没有 plan 快照,库里那份仍停在 in_progress/pending。+ * 必须只靠章收口——胶囊据此退场,步骤事实一个不动。+ */+ it('seals a successful turn that ended without any final plan snapshot', async () => {+ const openPlan = [+ { step: 'Find the capsule', status: 'completed' },+ { step: 'Reopen the task', status: 'in_progress' },+ { step: 'Confirm it stays gone', status: 'pending' },+ ];+ const persistId = onToolUseEvent(+ SESSION,+ { toolUseId: 'plan:turn-no-snapshot', toolName: 'update_plan', input: { plan: openPlan } },+ null,+ );++ expect(persistCodexPlanOnDone(SESSION, {+ raw: { id: 'turn-no-snapshot', status: 'completed' },+ })).toBe(true);++ await flushWrites();+ expect(updateMessageContent).toHaveBeenCalledWith(SESSION, persistId, {+ toolUseId: 'plan:turn-no-snapshot',+ toolName: 'update_plan',+ input: { plan: openPlan },+ terminalPlanSnapshot: true,+ });+ });+it('stamps an already-completed plan as terminal at the successful done boundary', async () => {const persistId = onToolUseEvent(SESSION,diff --git a/apps/desktop/src/main/messagePersistBroadcaster.ts b/apps/desktop/src/main/messagePersistBroadcaster.tsindex 878448e30a..8029162364 100644--- a/apps/desktop/src/main/messagePersistBroadcaster.ts+++ b/apps/desktop/src/main/messagePersistBroadcaster.ts@@ -31,7 +31,6 @@ import { createId } from '@paralleldrive/cuid2';import { BrowserWindow } from 'electron';import { desc, eq } from 'drizzle-orm';-import { resolveCodexPlanSnapshotOnDone } from '@cindy/maker-shared/message-render';import {broadcastMessageRow,@@ -618,13 +617,15 @@ export function persistCodexPlanOnDone(if (!input || !Array.isArray(input.plan)) return false;const isSuccessfulTerminal = isSuccessfulCodexDoneEventData(data);- const nextPlan =- resolveCodexPlanSnapshotOnDone(input.plan, data?.plan, isSuccessfulTerminal) ??- (isSuccessfulTerminal ? null : input.plan);- if (!nextPlan) return false;+ // Only an explicit snapshot from Codex may change step statuses. A successful+ // turn that left items open is recorded as-is and closed by the seal below —+ // ticking them here would make the stored plan claim work the agent never+ // reported doing.+ const nextPlan = Array.isArray(data?.plan) ? data.plan : input.plan;// Even when Codex already emitted the exact completed/empty plan, stamp the// durable row at done. Renderer must distinguish this authoritative write// from an older ordinary DB echo that merely happens to look completed.+ const terminalPlanAtMs = Date.now();const nextInput = { ...input, plan: nextPlan };infoMap?.set(toolUseId, { ...info, input: nextInput });enqueueWrite(`codex_plan_done:${sessionId}:${persistId}`, async (ownerScope) => {@@ -633,7 +634,7 @@ export function persistCodexPlanOnDone(toolName: 'update_plan',input: nextInput,...(isSuccessfulTerminal- ? { terminalPlanSnapshot: true }+ ? { terminalPlanSnapshot: true, terminalPlanAtMs }: { turnCompleted: false }),});// Reuse the existing upsert-style row broadcast so a renderer that mountsdiff --git a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsxindex 79f4e43b36..103e00b364 100644--- a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx+++ b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx@@ -6,7 +6,15 @@* 鼠标悬停时完整清单以浮层向上展开,原地实时更新,不会被后续消息冲走。* 数据从会话消息派生(findLatestMessageTodoInsertion):跨 source(TodoWrite /* update_plan / Task*)取最近更新的 plan session 快照;历史 session 不再逐张- * 展示。无计划时返回 null,不占位;计划完成后保留 2 秒再收起。+ * 展示。无计划时返回 null,不占位。+ *+ * **退场条件是 host 的终态章,不是"步骤全勾完"**(`insertion.sealed`,来源见+ * maker-shared 的 `terminalPlanSnapshot`)。agent 收尾时漏勾最后几步是常态,+ * 以"全勾完"为退场条件会让干完的活儿永远挂在屏幕上;而中断、失败、断线自动+ * 续跑都不盖章,那种情况计划必须留着——任务还活着,用户正要接着指挥。+ *+ * 盖章后同样保留 2 秒再收起,时刻锚在章上(章落库,所以重载/新窗口看到的是+ * 同一个时刻,不会重新数 2 秒)。旧数据没有章,按"全勾完"兜底,行为不变。*/import { useEffect, useMemo, useState } from 'react';@@ -47,9 +55,12 @@ export function PinnedPlanPanel({insertion.todos.length > 0 &&insertion.todos.every((todo) => todo.status === 'completed'),);- const completedAtMs = insertion?.updatedAtMs ?? Date.parse(insertion?.createdAt ?? '');+ // 退场 = host 盖了终态章(权威),或计划自己勾完了(没有章的旧数据兜底)。+ const retired = Boolean(insertion) && (insertion?.sealed === true || allDone);+ const completedAtMs =+ insertion?.sealedAtMs ?? insertion?.updatedAtMs ?? Date.parse(insertion?.createdAt ?? '');const persistedCompletionDeadlineMs =- allDone && Number.isFinite(completedAtMs) ? completedAtMs + COMPLETED_PLAN_VISIBLE_MS : null;+ retired && Number.isFinite(completedAtMs) ? completedAtMs + COMPLETED_PLAN_VISIBLE_MS : null;const [fallbackCompletionVisibility, setFallbackCompletionVisibility] = useState<{identity: string;deadlineMs: number;@@ -57,7 +68,7 @@ export function PinnedPlanPanel({const completionIdentity = insertion ? `${sessionId ?? 'unknown'}:${insertion.key}` : null;const completionDeadlineMs =persistedCompletionDeadlineMs ??- (allDone && fallbackCompletionVisibility?.identity === completionIdentity+ (retired && fallbackCompletionVisibility?.identity === completionIdentity? fallbackCompletionVisibility.deadlineMs: null);const completedPlanExpired = Boolean(@@ -66,7 +77,7 @@ export function PinnedPlanPanel({const [hiddenInsertionKey, setHiddenInsertionKey] = useState<string | null>(null);useEffect(() => {- if (!insertion || !allDone) {+ if (!insertion || !retired) {setHiddenInsertionKey(null);setFallbackCompletionVisibility(null);return;@@ -92,7 +103,7 @@ export function PinnedPlanPanel({setHiddenInsertionKey(insertion.key);}, remainingMs);return () => window.clearTimeout(timer);- }, [allDone, completionDeadlineMs, completionIdentity, insertion?.key]);+ }, [retired, completionDeadlineMs, completionIdentity, insertion?.key]);if (!visible ||diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/PinnedPlanPanel.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/PinnedPlanPanel.test.tsxindex 66505c4a4d..e89777f46b 100644--- a/apps/desktop/src/renderer/components/new-chat/__tests__/PinnedPlanPanel.test.tsx+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/PinnedPlanPanel.test.tsx@@ -297,3 +297,143 @@ describe('PinnedPlanPanel completed plan lifetime', () => {expect(screen.queryByTestId('plan-pill')).toBeNull();});});++/**+ * 终态盖章。main 只在「这一轮成功收尾」时给该计划行盖 terminalPlanSnapshot;+ * 胶囊的退场只认这枚章,不看勾选状态——agent 收尾时没把每一步勾完是常态+ * (Codex 官方同样如实保留未勾项),要求"全勾完才退场"等于要求它撒谎。+ *+ * 反过来,中断、失败、断线自动续跑都不盖章,计划照旧挂着:任务还活着,用户+ * 正要接着指挥,这时候摘牌比不摘更糟。+ */+describe('PinnedPlanPanel terminal seal', () => {+ function sealedPlanMessage(planUpdatedAtMs?: number, stepCount = 2): ChatMessage {+ return {+ ...planMessage('in_progress', T0, planUpdatedAtMs, stepCount),+ terminalPlanSnapshot: true,+ };+ }++ it('starts the grace period at the terminal seal, not when the plan was created', () => {+ // 真实复现:计划先展示了 4 秒,agent 才回答完成。若拿 createdAt 算 2 秒,+ // 章一到就已过期,用户会看到泡泡在收尾瞬间直接消失。+ vi.setSystemTime(T0 + 4_000);+ const sealedLater: ChatMessage = {+ ...planMessage('in_progress', T0),+ terminalPlanSnapshot: true,+ terminalPlanAtMs: T0 + 4_000,+ };++ render(+ <PinnedPlanPanel+ sessionId="late-seal"+ messages={[sealedLater]}+ animated={false}+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(1_999));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(1));+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('retires a sealed plan that still has open steps', () => {+ render(+ <PinnedPlanPanel+ sessionId="sealed-open-steps"+ messages={[sealedPlanMessage(T0)]}+ animated={false}+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(1_999));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(1));+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('keeps a sealed plan hidden when the task is reopened later', () => {+ vi.setSystemTime(T0 + 60_000);+ render(+ <PinnedPlanPanel+ sessionId="sealed-reopened"+ messages={[sealedPlanMessage()]}+ animated={false}+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).toBeNull();+ act(() => vi.advanceTimersByTime(10_000));+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('keeps an unsealed plan visible while the turn is still open', () => {+ render(+ <PinnedPlanPanel+ sessionId="unsealed"+ messages={[planMessage('in_progress')]}+ animated+ width={400}+ />,+ );++ act(() => vi.advanceTimersByTime(30_000));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ });++ it('keeps the plan visible when the turn was interrupted instead of finished', () => {+ // main 对中断/失败的匹配 turn 只打 turnCompleted:false,不盖终态章。+ const interrupted: ChatMessage = {+ ...planMessage('in_progress'),+ turnCompleted: false,+ };++ render(+ <PinnedPlanPanel+ sessionId="interrupted-turn"+ messages={[interrupted]}+ animated={false}+ width={400}+ />,+ );++ act(() => vi.advanceTimersByTime(30_000));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ });++ it('shows the capsule again when a new plan update clears the seal', () => {+ const view = render(+ <PinnedPlanPanel+ sessionId="sealed-then-updated"+ messages={[sealedPlanMessage(T0)]}+ animated={false}+ width={400}+ />,+ );+ act(() => vi.advanceTimersByTime(2_000));+ expect(screen.queryByTestId('plan-pill')).toBeNull();++ // 新一轮真的更新了计划:store 把章清成 false,胶囊重新亮牌。+ view.rerender(+ <PinnedPlanPanel+ sessionId="sealed-then-updated"+ messages={[+ {+ ...planMessage('in_progress', T0, T0 + 5_000, 3),+ terminalPlanSnapshot: false,+ },+ ]}+ animated+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ });+});diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 6e34415fe4..a00c59bfa8 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -371,6 +371,8 @@ export interface ChatMessage {planUpdatedAtMs?: number;/** Main stamped this persisted Codex plan at the successful done boundary. */terminalPlanSnapshot?: boolean;+ /** Host time when the successful Codex plan seal was applied. */+ terminalPlanAtMs?: number;/*** 产生这条消息的模型 raw id(读自 agentMeta.model)。对 subagent 子消息而言* 即子代理实际跑的模型(如 'claude-haiku-4-5-20251001')。仅 SDK 带 model 的@@ -14321,7 +14323,12 @@ function mapServerMessages(serverMsgs: Message[]): ChatMessage[] {toolName,toolInput,...(toolName === 'update_plan' && c.terminalPlanSnapshot === true- ? { terminalPlanSnapshot: true }+ ? {+ terminalPlanSnapshot: true,+ ...(typeof c.terminalPlanAtMs === 'number'+ ? { terminalPlanAtMs: c.terminalPlanAtMs }+ : {}),+ }: {}),...(toolName === 'update_plan' && c.turnCompleted === false? { turnCompleted: false }diff --git a/packages/maker-shared/src/__tests__/planCompletion.test.ts b/packages/maker-shared/src/__tests__/planCompletion.test.tsindex 5ab51042f0..5dceef08ed 100644--- a/packages/maker-shared/src/__tests__/planCompletion.test.ts+++ b/packages/maker-shared/src/__tests__/planCompletion.test.ts@@ -89,12 +89,13 @@ describe('applyCodexPlanSnapshotOnDone', () => {});});- it('marks the matching plan complete when a successful turn has no final snapshot', () => {+ it('seals the matching plan on a successful turn without ticking its open steps', () => {const completedAtMs = 1_700_000_005_000;- const message = planMessage('plan:done', [+ const openSteps = [{ step: 'Inspect', status: 'in_progress' },{ step: 'Patch', status: 'pending' },- ]);+ ];+ const message = planMessage('plan:done', openSteps);const result = applyCodexPlanSnapshotOnDone([message],null,@@ -105,54 +106,54 @@ describe('applyCodexPlanSnapshotOnDone', () => {expect(result.changed).toBe(true);expect(result.toolUseId).toBe('plan:done');+ // 章封生命周期,步骤事实保持原样:agent 没报告完成的事不能替它宣布完成。expect(result.messages[0]).toMatchObject({+ terminalPlanSnapshot: true,planUpdatedAtMs: completedAtMs,- toolInput: {- plan: [- { step: 'Inspect', status: 'completed' },- { step: 'Patch', status: 'completed' },- ],- },- content: {- input: {- plan: [- { step: 'Inspect', status: 'completed' },- { step: 'Patch', status: 'completed' },- ],- },- },+ toolInput: { plan: openSteps },+ content: { input: { plan: openSteps } },+ });+ });++ it('seals an already-sealed row only once so the capsule grace does not restart', () => {+ const message = {+ ...planMessage('plan:done', [{ step: 'Inspect', status: 'in_progress' }]),+ terminalPlanSnapshot: true,+ };+ const messages = [message];++ expect(applyCodexPlanSnapshotOnDone(messages, null, 'done', 'completed')).toEqual({+ messages,+ changed: false,+ toolUseId: 'plan:done',});});- it('treats an unfinished done snapshot as cached progress for a successful turn', () => {+ it('applies an explicit unfinished snapshot verbatim and seals it', () => {const message = planMessage('plan:done', [{ step: 'Inspect', status: 'in_progress' },{ step: 'Patch', status: 'pending' },]);- const cachedProgress = [+ const reportedProgress = [{ step: 'Inspect', status: 'completed', description: 'kept from latest update' },{ step: 'Patch', status: 'in_progress' },];const result = applyCodexPlanSnapshotOnDone([message],- cachedProgress,+ reportedProgress,'done','completed',);expect(result.changed).toBe(true);expect(result.messages[0]).toMatchObject({- toolInput: {- plan: [- { step: 'Inspect', status: 'completed', description: 'kept from latest update' },- { step: 'Patch', status: 'completed' },- ],- },+ terminalPlanSnapshot: true,+ toolInput: { plan: reportedProgress },});});- it('does not infer completion without a matching turn id', () => {+ it('does not seal without a matching turn id', () => {const message = planMessage('plan:unrelated', [{ step: 'Inspect', status: 'in_progress' },]);@@ -166,7 +167,7 @@ describe('applyCodexPlanSnapshotOnDone', () => {)).toEqual({ messages, changed: false, toolUseId: null });});- it('does not infer completion for a failed or interrupted turn', () => {+ it('does not seal a failed or interrupted turn', () => {const message = planMessage('plan:stopped', [{ step: 'Inspect', status: 'in_progress' }]);const messages = [message];diff --git a/packages/maker-shared/src/messageRender.ts b/packages/maker-shared/src/messageRender.tsindex ea6786edf4..036024f999 100644--- a/packages/maker-shared/src/messageRender.ts+++ b/packages/maker-shared/src/messageRender.ts@@ -19,6 +19,15 @@ export interface MessageRenderSourceMessageLike {toolUseId?: string | null;/** Host-persisted SDK turn boundary on the final assistant or owning Codex plan row. */turnCompleted?: boolean;+ /**+ * Host sealed this Codex plan row because its owning turn ended successfully.+ * The seal closes the plan's lifecycle only — step statuses stay exactly as the+ * agent last reported them. Interrupted, failed, and auto-resumed turns never+ * seal, so their plan stays open while the task itself is still alive.+ */+ terminalPlanSnapshot?: boolean;+ /** Host time when the successful turn seal was applied. */+ terminalPlanAtMs?: number;}export type MessageRenderNormalizedMessageKind =@@ -193,6 +202,14 @@ export interface MessageRenderTodoInsertion {createdAt?: string;updatedAtMs?: number;source: MessageRenderTodoSource;+ /**+ * 这份计划所属的 turn 已被 host 判定为成功收尾(见+ * `MessageRenderSourceMessageLike.terminalPlanSnapshot`)。常驻面板据此退场,+ * 不看勾选状态;未盖章就一直挂着。+ */+ sealed?: boolean;+ /** Persisted host time of the successful terminal seal. */+ sealedAtMs?: number;}export interface MessageRenderLatestTodoState {@@ -476,6 +493,14 @@ export function findMessageTodoInsertions<TMessage extends MessageRenderSourceMecreatedAt: messages[session.lastIndex]?.createdAt,updatedAtMs: messages[session.lastIndex]?.planUpdatedAtMs,source: session.source,+ ...(messages[session.lastIndex]?.terminalPlanSnapshot === true+ ? {+ sealed: true,+ ...(typeof messages[session.lastIndex]?.terminalPlanAtMs === 'number'+ ? { sealedAtMs: messages[session.lastIndex].terminalPlanAtMs }+ : {}),+ }+ : {}),});}return out;@@ -551,28 +576,23 @@ export interface CodexPlanSnapshotApplyResult<}/**- * Resolve the plan payload that should survive a Codex turn terminal event.- * A successful turn is authoritative even when Codex only returns its last- * cached in-progress snapshot: every remaining item belongs to that finished- * turn and must converge to completed. Other terminal states may only apply an- * explicit snapshot; they must never infer completion from stale progress.+ * Close out a Codex plan at its owning turn's terminal event.+ *+ * Two independent things happen here, and keeping them separate is the whole+ * point:+ * - **Content**: an explicit `turn/plan/updated` snapshot carried by `done` is+ * applied verbatim. Nothing else ever rewrites a step. Codex leaves open+ * items on a successful turn routinely (its own prompt asks the model to tick+ * them, and the model complies most of the time — not always), and inventing+ * the missing ticks makes the transcript claim work that was never reported.+ * - **Lifecycle**: a successful, ownership-matched turn *seals* the row. The+ * seal is what retires the pinned capsule, so retiring no longer depends on+ * the agent having ticked every box.+ *+ * Interrupted / failed turns, and any turn whose id does not match, seal+ * nothing: the task is still alive and the user is usually about to steer it,+ * so the plan must stay on screen.*/-export function resolveCodexPlanSnapshotOnDone(- currentPlan: readonly unknown[],- snapshot: unknown,- inferCompletion: boolean,-): unknown[] | null {- const authoritativeSnapshot = Array.isArray(snapshot) ? snapshot : null;- if (!authoritativeSnapshot && !inferCompletion) return null;-- const snapshotSource = authoritativeSnapshot ?? currentPlan;- if (!inferCompletion) return authoritativeSnapshot;- return snapshotSource.map((item) => {- const record = readRecord(item);- return record ? { ...record, status: 'completed' } : item;- });-}-export function applyCodexPlanSnapshotOnDone<TMessage extends MessageRenderSourceMessageLike,>(@@ -583,9 +603,8 @@ export function applyCodexPlanSnapshotOnDone<planUpdatedAtMs?: number,): CodexPlanSnapshotApplyResult<TMessage> {const authoritativeSnapshot = Array.isArray(snapshot) ? snapshot : null;- const hasAuthoritativeSnapshot = authoritativeSnapshot !== null;- const canInferCompletion = terminalStatus === 'completed' && Boolean(turnId);- if (!hasAuthoritativeSnapshot && !canInferCompletion) {+ const sealsTurn = terminalStatus === 'completed' && Boolean(turnId);+ if (!authoritativeSnapshot && !sealsTurn) {return { messages, changed: false, toolUseId: null };}const expectedToolUseId = turnId ? `plan:${turnId}` : null;@@ -600,36 +619,36 @@ export function applyCodexPlanSnapshotOnDone<const input = readRecord(toolInputOf(message));if (!Array.isArray(input?.plan)) continue;- // maker-core attaches the latest cached turn/plan/updated snapshot to done.- // When Codex omits its final plan update, that array still contains open- // items and is in progress rather than a terminal snapshot. Converge that- // cached progress (or the persisted row when no snapshot exists) only for a- // matching, explicitly successful turn. Without a turn id, an array can- // still be applied as supplied but completion must never be inferred for an- // unrelated last plan row.- const nextSnapshot = resolveCodexPlanSnapshotOnDone(- input.plan,- authoritativeSnapshot,- canInferCompletion,- );- if (!nextSnapshot) {- return { messages, changed: false, toolUseId: null };- }- if (samePlanSnapshot(input.plan, nextSnapshot)) {++ const nextPlan = authoritativeSnapshot ?? input.plan;+ const planChanged =+ authoritativeSnapshot !== null && !samePlanSnapshot(input.plan, authoritativeSnapshot);+ // Seal an already-sealed row again would be a no-op update that still+ // restarts the capsule's grace timer, so treat it as unchanged.+ const sealChanged = sealsTurn && message.terminalPlanSnapshot !== true;+ if (!planChanged && !sealChanged) {return { messages, changed: false, toolUseId };}const next = [...messages];next[index] = {...message,+ ...(sealsTurn+ ? {+ terminalPlanSnapshot: true,+ ...(typeof planUpdatedAtMs === 'number' && Number.isFinite(planUpdatedAtMs)+ ? { terminalPlanAtMs: planUpdatedAtMs }+ : {}),+ }+ : {}),...(typeof planUpdatedAtMs === 'number' && Number.isFinite(planUpdatedAtMs)? { planUpdatedAtMs }: {}),...(message.toolInput !== undefined- ? { toolInput: { ...input, plan: nextSnapshot } }+ ? { toolInput: { ...input, plan: nextPlan } }: {}),...(content- ? { content: { ...content, input: { ...input, plan: nextSnapshot } } }+ ? { content: { ...content, input: { ...input, plan: nextPlan } } }: {}),};return { messages: next, changed: true, toolUseId };