Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 完成步骤两秒后隐藏
Lizi93a9b8641570
diff --git a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsxindex 01848b81e5..cb430c3151 100644--- a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx+++ b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx@@ -6,29 +6,52 @@* 鼠标悬停时完整清单以浮层向上展开,原地实时更新,不会被后续消息冲走。* 数据从会话消息派生(findLatestMessageTodoInsertion):跨 source(TodoWrite /* update_plan / Task*)取最近更新的 plan session 快照;历史 session 不再逐张- * 展示。无计划时返回 null,不占位。+ * 展示。无计划时返回 null,不占位;计划完成后保留 2 秒再收起。*/-import { useMemo } from 'react';+import { useEffect, useMemo, useState } from 'react';import { findLatestMessageTodoInsertion } from '@cindy/maker-shared/message-render';import { TodoListCard } from '@/components/chat/TodoListCard';import type { ChatMessage } from '@/lib/makerChatStore';+const COMPLETED_PLAN_VISIBLE_MS = 2_000;+export function PinnedPlanPanel({messages,animated,width,+ visible = true,}: {messages: readonly ChatMessage[];/** 会话仍在流式时进行中项呼吸/旋转;停止后冻结。 */animated: boolean;/** 与 composer 同宽(inputWidth),胶囊在该宽度内居中,浮层不超出。 */width: number;+ /** 交互卡接管底部区域时只隐藏视图,保留完成后的计时与已收起状态。 */+ visible?: boolean;}): React.ReactElement | null {const insertion = useMemo(() => findLatestMessageTodoInsertion(messages), [messages]);+ const allDone = Boolean(+ insertion+ && insertion.todos.length > 0+ && insertion.todos.every((todo) => todo.status === 'completed'),+ );+ const [hiddenInsertionKey, setHiddenInsertionKey] = useState<string | null>(null);++ useEffect(() => {+ if (!insertion || !allDone) {+ setHiddenInsertionKey(null);+ return;+ }++ const timer = window.setTimeout(() => {+ setHiddenInsertionKey(insertion.key);+ }, COMPLETED_PLAN_VISIBLE_MS);+ return () => window.clearTimeout(timer);+ }, [allDone, insertion?.key]);- if (!insertion || insertion.todos.length === 0) return null;+ if (!visible || !insertion || insertion.todos.length === 0 || hiddenInsertionKey === insertion.key) return null;return (<div className="mb-1.5 max-w-full" style={{ width }}>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.tsxnew file mode 100644index 0000000000..01fb5191e5--- /dev/null+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/PinnedPlanPanel.test.tsx@@ -0,0 +1,86 @@+// @vitest-environment jsdom++import { act, cleanup, render, screen } from '@testing-library/react';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import type { ChatMessage } from '@/lib/makerChatStore';++import { PinnedPlanPanel } from '../PinnedPlanPanel';++vi.mock('@/components/chat/TodoListCard', () => ({+ TodoListCard: ({ todos }: { todos: Array<{ content: string }> }) => (+ <div data-testid="plan-pill">{todos.map((todo) => todo.content).join(',')}</div>+ ),+}));++const T0 = 1_700_000_000_000;++function planMessage(status: 'pending' | 'in_progress' | 'completed'): ChatMessage {+ return {+ clientId: 'plan-1',+ role: 'tool_use',+ content: '',+ toolName: 'update_plan',+ toolUseId: 'plan:turn-1',+ toolInput: { plan: [{ step: 'Finish work', status }] },+ createdAt: new Date(T0).toISOString(),+ };+}++beforeEach(() => {+ vi.useFakeTimers();+ vi.setSystemTime(T0);+});++afterEach(() => {+ cleanup();+ vi.useRealTimers();+});++describe('PinnedPlanPanel completed plan lifetime', () => {+ it('keeps a completed plan visible for 2 seconds, then hides it', () => {+ render(<PinnedPlanPanel messages={[planMessage('completed')]} 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('does not hide a plan that is still running', () => {+ render(<PinnedPlanPanel messages={[planMessage('in_progress')]} animated width={400} />);++ act(() => vi.advanceTimersByTime(10_000));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ });++ it('stays hidden after an interaction card temporarily hides the panel', () => {+ const completed = planMessage('completed');+ const view = render(+ <PinnedPlanPanel messages={[completed]} animated={false} width={400} visible />,+ );++ act(() => vi.advanceTimersByTime(2_000));+ expect(screen.queryByTestId('plan-pill')).toBeNull();++ view.rerender(+ <PinnedPlanPanel messages={[completed]} animated={false} width={400} visible={false} />,+ );+ view.rerender(+ <PinnedPlanPanel messages={[completed]} animated={false} width={400} visible />,+ );+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('starts a fresh 2-second wait when a running plan completes', () => {+ const running = planMessage('in_progress');+ const view = render(<PinnedPlanPanel messages={[running]} animated width={400} />);++ act(() => vi.advanceTimersByTime(5_000));+ view.rerender(<PinnedPlanPanel messages={[planMessage('completed')]} animated={false} width={400} />);+ act(() => vi.advanceTimersByTime(1_999));+ expect(screen.queryByTestId('plan-pill')).not.toBeNull();+ act(() => vi.advanceTimersByTime(1));+ 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 d9535126a8..8ab95604ac 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -3517,17 +3517,20 @@ export function CCAgentSessionView({审核 / 权限 / 提问 / 插件配置 / 各类确认卡)接管底部区时隐藏:胶囊的悬停浮层向上展开,会盖住交互卡内容(条件集与下方 ternary的静默判定保持一致)。 */}- {!(- pendingPlanReview ||- pendingPermission ||- pendingAskUser ||- pendingPluginSetup ||- pendingIssueConfirm ||- pendingRenameSessionsConfirm ||- pendingGhostGrantConfirm- ) && (- <PinnedPlanPanel messages={messages} animated={isStreaming} width={inputWidth} />- )}+ <PinnedPlanPanel+ messages={messages}+ animated={isStreaming}+ width={inputWidth}+ visible={!(+ pendingPlanReview ||+ pendingPermission ||+ pendingAskUser ||+ pendingPluginSetup ||+ pendingIssueConfirm ||+ pendingRenameSessionsConfirm ||+ pendingGhostGrantConfirm+ )}+ />{/* 互斥:有任意 pending interaction 时,下方 takeover/overlay/ChatInput全部静默 — 跟改造前 ternary 链 (Plan ? : Perm ? : Ask ? :Takeover ? : ChatInput) 的语义一致。