Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 流式期间未盖章的 codex 计划不走全勾完兜底退场
Kafeifei8f6659f9c845
diff --git a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsxindex 103e00b364..fcaeff3ef2 100644--- a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx+++ b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx@@ -15,6 +15,8 @@** 盖章后同样保留 2 秒再收起,时刻锚在章上(章落库,所以重载/新窗口看到的是* 同一个时刻,不会重新数 2 秒)。旧数据没有章,按"全勾完"兜底,行为不变。+ * 兜底只属于旧数据:turn 还在流式时,未盖章的 codex 计划正在等 host 的终态章,+ * 这时候按"全勾完"抢跑退场,会在章晚到(>2s)时先消失再被章复活闪回 2 秒。*/import { useEffect, useMemo, useState } from 'react';@@ -33,6 +35,7 @@ export function PinnedPlanPanel({width,taskHistoryMayBeIncomplete = false,visible = true,+ streaming = false,className,}: {sessionId: string | null;@@ -44,6 +47,8 @@ export function PinnedPlanPanel({taskHistoryMayBeIncomplete?: boolean;/** 交互卡接管底部区域时只隐藏视图,保留完成后的计时与已收起状态。 */visible?: boolean;+ /** turn 还在流式:未盖章的 codex 计划正在等终态章,不走"全勾完"兜底退场。 */+ streaming?: boolean;className?: string;}): React.ReactElement | null {const insertion = useMemo(@@ -55,8 +60,13 @@ export function PinnedPlanPanel({insertion.todos.length > 0 &&insertion.todos.every((todo) => todo.status === 'completed'),);+ // codex 计划在 turn 流式期间是"等章"状态:host 的终态章才是权威,agent 提前把+ // 步骤全勾完不算数——按 allDone 抢跑会在章晚到时产生"消失再闪回"。TodoWrite /+ // Task 永远不会有章,codex 旧历史数据也不会再有,它们照旧走全勾完兜底。+ const awaitingSeal = insertion?.source === 'codex' && insertion.sealed !== true && streaming;// 退场 = host 盖了终态章(权威),或计划自己勾完了(没有章的旧数据兜底)。- const retired = Boolean(insertion) && (insertion?.sealed === true || allDone);+ const retired =+ Boolean(insertion) && (insertion?.sealed === true || (allDone && !awaitingSeal));const completedAtMs =insertion?.sealedAtMs ?? insertion?.updatedAtMs ?? Date.parse(insertion?.createdAt ?? '');const persistedCompletionDeadlineMs =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 e89777f46b..d3ef44d30a 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@@ -436,4 +436,99 @@ describe('PinnedPlanPanel terminal seal', () => {expect(screen.queryByTestId('plan-pill')).not.toBeNull();});++ it('does not retire an unsealed all-done codex plan while the turn is still streaming', () => {+ // 真实复现:Codex 在终态事件前就把全部步骤勾成 completed,随后最终回复流式+ // 超过 2 秒。若 allDone 兜底在等章期间抢跑,胶囊会先消失,章一到又带着新+ // sealedAtMs 复活 2 秒——消失再闪回。等章期间必须留在原地。+ const allDoneStreaming = planMessage('completed', T0, T0);+ const view = render(+ <PinnedPlanPanel+ sessionId="streaming-all-done"+ messages={[allDoneStreaming]}+ animated+ streaming+ width={400}+ />,+ );++ act(() => vi.advanceTimersByTime(4_000));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();++ // 章落地:退场计时从 sealedAtMs 起数,整个过程无中断、无闪回。+ vi.setSystemTime(T0 + 4_000);+ view.rerender(+ <PinnedPlanPanel+ sessionId="streaming-all-done"+ messages={[+ {+ ...allDoneStreaming,+ terminalPlanSnapshot: true,+ terminalPlanAtMs: T0 + 4_000,+ },+ ]}+ animated={false}+ streaming={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('still retires an all-done codex plan from old history data without a seal', () => {+ // 旧数据没有章(升级前落库),也永远不会再有:全勾完兜底照旧生效,+ // 否则旧会话的计划会永远挂在屏幕上。非流式 = 没有在等章的 turn。+ render(+ <PinnedPlanPanel+ sessionId="old-history-all-done"+ messages={[planMessage('completed', T0, T0)]}+ animated={false}+ streaming={false}+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(2_000));+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('keeps the all-done fallback for TodoWrite plans even while streaming', () => {+ // TodoWrite / Task 计划永远不会被盖章,全勾完兜底是它们唯一的退场路径,+ // 流式与否都不该被"等章"逻辑挡住。+ const todoAllDone: ChatMessage = {+ clientId: 'todo-1',+ role: 'tool_use',+ content: '',+ toolName: 'TodoWrite',+ toolUseId: 'todo:turn-1',+ toolInput: {+ todos: [+ { content: 'Step 1', status: 'completed' },+ { content: 'Step 2', status: 'completed' },+ ],+ },+ createdAt: new Date(T0).toISOString(),+ planUpdatedAtMs: T0,+ };++ render(+ <PinnedPlanPanel+ sessionId="todo-streaming-all-done"+ messages={[todoAllDone]}+ animated+ streaming+ width={400}+ />,+ );++ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(2_000));+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });});diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 94c3a6e102..89aca6d6ba 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -3534,6 +3534,7 @@ export function CCAgentSessionView({sessionId={sessionId ?? null}messages={messages}animated={isStreaming}+ streaming={isStreaming}width={inputWidth}taskHistoryMayBeIncomplete={!historyLoaded || hasMoreMessages || historyWindowHasIsland