Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 为置顶计划增加手动关闭入口 (#2200)
YuRuiHadfff1b2f36f
diff --git a/apps/desktop/src/renderer/components/chat/TodoListCard.tsx b/apps/desktop/src/renderer/components/chat/TodoListCard.tsxindex 4024740206..be4fbbe276 100644--- a/apps/desktop/src/renderer/components/chat/TodoListCard.tsx+++ b/apps/desktop/src/renderer/components/chat/TodoListCard.tsx@@ -21,10 +21,11 @@*/import { useEffect, useId, useRef, useState } from 'react';-import { CircleCheck, CircleDot, Circle } from 'lucide-react';+import { CircleCheck, CircleDot, Circle, X } from 'lucide-react';import { useTranslation } from 'react-i18next';import type { MessageRenderTodoItem } from '@cindy/maker-shared/message-render';+import { Tip } from '@/components/ui/tooltip';import { cn } from '@/lib/utils';// ---------------------------------------------------------------------------@@ -102,6 +103,7 @@ export function TodoListCard({todos,animated = false,maxWidth,+ onDismiss,}: {todos: TodoItem[];/**@@ -112,6 +114,8 @@ export function TodoListCard({animated?: boolean;/** Composer/chat column width. Keeps the flyout inside clipped compact panes. */maxWidth?: number;+ /** Hide the current rendered snapshot without mutating the agent's plan state. */+ onDismiss?: () => void;}) {const { t } = useTranslation();const flyoutId = useId();@@ -243,7 +247,7 @@ export function TodoListCard({<divaria-hidden={!revealed}className={cn(- 'w-full origin-bottom overflow-hidden rounded-[12px]',+ 'relative w-full origin-bottom overflow-hidden rounded-[12px]','border border-[var(--msg-tool-card-border)]','bg-[var(--msg-tool-card-bg)]',revealed ? 'animate-float-in' : 'animate-float-out',@@ -252,7 +256,30 @@ export function TodoListCard({if (!revealed) setRenderFlyout(false);}}>- <div className="flex max-h-[280px] flex-col gap-[2px] overflow-y-auto px-[14px] py-[10px]">+ {onDismiss && revealed && (+ <Tip text={t('chat.planPill.dismiss')}>+ <button+ type="button"+ onClick={onDismiss}+ aria-label={t('chat.planPill.dismiss')}+ className={cn(+ 'absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center rounded-full',+ 'text-[var(--msg-tool-card-chevron)] transition-colors',+ 'hover:bg-[var(--model-item-hover)] hover:text-[var(--msg-tool-card-text)]',+ 'active:scale-[0.98]',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ )}+ >+ <X size={14} aria-hidden="true" />+ </button>+ </Tip>+ )}+ <div+ className={cn(+ 'flex max-h-[280px] flex-col gap-[2px] overflow-y-auto py-[10px] pl-[14px]',+ onDismiss ? 'pr-10' : 'pr-[14px]',+ )}+ >{todos.map((todo, i) => (<div key={i} className="flex h-[30px] items-center gap-[10px]">{/* Icon */}diff --git a/apps/desktop/src/renderer/components/chat/__tests__/TodoListCard.test.tsx b/apps/desktop/src/renderer/components/chat/__tests__/TodoListCard.test.tsxindex f40da073b9..a65092fac0 100644--- a/apps/desktop/src/renderer/components/chat/__tests__/TodoListCard.test.tsx+++ b/apps/desktop/src/renderer/components/chat/__tests__/TodoListCard.test.tsx@@ -7,8 +7,8 @@ import { TodoListCard } from '../TodoListCard';vi.mock('react-i18next', () => ({useTranslation: () => ({- t: (_key: string, values: { current: number; total: number }) =>- `Step ${values.current} / ${values.total}`,+ t: (key: string, values?: { current: number; total: number }) =>+ key === 'chat.planPill.dismiss' ? 'Close Plan' : `Step ${values?.current} / ${values?.total}`,}),}));@@ -154,6 +154,27 @@ describe('TodoListCard flyout interaction', () => {expect(trigger.getAttribute('aria-expanded')).toBe('false');});+ it('offers an accessible close action with a keyboard-visible shared tooltip', async () => {+ const onDismiss = vi.fn();+ render(<TodoListCard todos={TODOS} animated={false} onDismiss={onDismiss} />);++ const trigger = screen.getByRole('button', { name: 'Step 1 / 2' });+ fireEvent.click(trigger);+ const closeButton = screen.getByRole('button', { name: 'Close Plan' });++ expect(closeButton.classList.contains('hover:bg-[var(--model-item-hover)]')).toBe(true);+ expect(closeButton.classList.contains('hover:bg-[var(--surface-hover)]')).toBe(false);+ expect(closeButton.classList.contains('focus-visible:outline-none')).toBe(true);+ expect(closeButton.getAttribute('title')).toBeNull();++ fireEvent.focus(closeButton);+ expect((await screen.findByRole('tooltip')).textContent).toBe('Close Plan');++ fireEvent.click(closeButton);++ expect(onDismiss).toHaveBeenCalledOnce();+ });+it('keeps centering and entrance animation transforms on separate elements', () => {render(<TodoListCard todos={TODOS} animated={false} />);diff --git a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsxindex 8d196b7530..9cb0844de1 100644--- a/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx+++ b/apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx@@ -133,10 +133,19 @@ export function PinnedPlanPanel({if (current?.identity === completionIdentity && current.deadlineMs >= completionDeadlineMs) return;deadlineFloorRef.current = { identity: completionIdentity, deadlineMs: completionDeadlineMs };}, [completionDeadlineMs, completionIdentity]);+ const snapshotIdentity = insertion+ ? JSON.stringify([+ sessionId ?? 'unknown',+ insertion.key,+ insertion.updatedAtMs ?? insertion.createdAt ?? null,+ insertion.todos.map((todo) => [todo.status, todo.content]),+ ])+ : null;const completedPlanExpired = Boolean(completionDeadlineMs !== null && completionDeadlineMs <= Date.now(),);const [hiddenInsertionKey, setHiddenInsertionKey] = useState<string | null>(null);+ const [dismissedSnapshotIdentity, setDismissedSnapshotIdentity] = useState<string | null>(null);useEffect(() => {if (!insertion || !retired) {@@ -172,7 +181,8 @@ export function PinnedPlanPanel({!insertion ||insertion.todos.length < 2 ||completedPlanExpired ||- hiddenInsertionKey === insertion.key+ hiddenInsertionKey === insertion.key ||+ dismissedSnapshotIdentity === snapshotIdentity)return null;@@ -187,6 +197,7 @@ export function PinnedPlanPanel({todos={insertion.todos}animated={animated}maxWidth={width}+ onDismiss={() => setDismissedSnapshotIdentity(snapshotIdentity)}/></div>);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 9cd3d1ad67..571c2ca7af 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@@ -1,14 +1,27 @@// @vitest-environment jsdom-import { act, cleanup, render, screen } from '@testing-library/react';+import { act, cleanup, fireEvent, 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>+ TodoListCard: ({+ todos,+ onDismiss,+ }: {+ todos: Array<{ content: string }>;+ onDismiss?: () => void;+ }) => (+ <div>+ <div data-testid="plan-pill">{todos.map((todo) => todo.content).join(',')}</div>+ {onDismiss && (+ <button type="button" onClick={onDismiss}>+ Dismiss Plan+ </button>+ )}+ </div>),}));@@ -148,6 +161,53 @@ describe('PinnedPlanPanel completed plan lifetime', () => {expect(screen.queryByTestId('plan-pill')).not.toBeNull();});+ it('keeps the current plan snapshot hidden after the user dismisses it', () => {+ const running = planMessage('in_progress');+ const view = render(+ <PinnedPlanPanel sessionId="manual-dismiss" messages={[running]} animated width={400} />,+ );++ fireEvent.click(screen.getByRole('button', { name: 'Dismiss Plan' }));+ expect(screen.queryByTestId('plan-pill')).toBeNull();++ view.rerender(+ <PinnedPlanPanel+ sessionId="manual-dismiss"+ messages={[+ running,+ {+ clientId: 'unrelated-answer',+ role: 'assistant',+ content: 'Unrelated response',+ },+ ]}+ animated={false}+ width={400}+ />,+ );+ expect(screen.queryByTestId('plan-pill')).toBeNull();+ });++ it('shows a dismissed plan again when the agent reports a newer snapshot', () => {+ const running = planMessage('in_progress');+ const view = render(+ <PinnedPlanPanel sessionId="dismiss-update" messages={[running]} animated width={400} />,+ );++ fireEvent.click(screen.getByRole('button', { name: 'Dismiss Plan' }));+ expect(screen.queryByTestId('plan-pill')).toBeNull();++ view.rerender(+ <PinnedPlanPanel+ sessionId="dismiss-update"+ messages={[planMessage('completed', T0, T0 + 1_000)]}+ animated={false}+ width={400}+ />,+ );+ 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(diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex ffc51bccca..c250d59644 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -6611,7 +6611,8 @@"outputFile": "Output: {{path}}"},"planPill": {- "step": "Step {{current}} of {{total}}"+ "step": "Step {{current}} of {{total}}",+ "dismiss": "Close Plan"},"forkOrigin": {"label": "Created from another session"diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 44119383d3..4770aaf779 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -6636,7 +6636,8 @@"outputFile": "出力: {{path}}"},"planPill": {- "step": "ステップ {{current}} / {{total}}"+ "step": "ステップ {{current}} / {{total}}",+ "dismiss": "計画を閉じる"},"forkOrigin": {"label": "元のセッションから作成"diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 14d7259cc5..c4249cb790 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -6636,7 +6636,8 @@"outputFile": "출력: {{path}}"},"planPill": {- "step": "{{current}} / {{total}}단계"+ "step": "{{current}} / {{total}}단계",+ "dismiss": "계획 닫기"},"forkOrigin": {"label": "원래 세션에서 생성됨"diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 8023a30f1d..deaca2118c 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -6609,7 +6609,8 @@"outputFile": "输出:{{path}}"},"planPill": {- "step": "第 {{current}} / {{total}} 步"+ "step": "第 {{current}} / {{total}} 步",+ "dismiss": "关闭计划"},"forkOrigin": {"label": "基于原任务创建"diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex a41fea52b8..adcec26a31 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -6634,9 +6634,10 @@"lastTool": "最近工具:{{tool}}","outputFile": "輸出:{{path}}"},- "planPill": {- "step": "第 {{current}} / {{total}} 步"- },+ "planPill": {+ "step": "第 {{current}} / {{total}} 步",+ "dismiss": "關閉計劃"+ },"forkOrigin": {"label": "基於原任務建立"},