Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): 后台任务面板对抗 review 修复(详情残留/历史卡降级/命令兜底/菜单入口)

Kafeifei85938e9c3527
diff --git a/apps/desktop/src/renderer/__tests__/AgentTaskCard.test.ts b/apps/desktop/src/renderer/__tests__/AgentTaskCard.test.ts
index 8ee58c909a..3f20845ce0 100644
--- a/apps/desktop/src/renderer/__tests__/AgentTaskCard.test.ts
+++ b/apps/desktop/src/renderer/__tests__/AgentTaskCard.test.ts
@@ -228,25 +228,31 @@ describe('AgentTaskCard', () => {
expect(openBackgroundTasksTabMock).toHaveBeenCalledWith('session-1', { focusTaskId: 'wf-1' });
});
- it('degrades to a no-op when sessionId or taskId is missing on a workflow card', () => {
+ it('falls back to the expand toggle when sessionId or taskId is missing on a workflow card', () => {
+ // 历史重载 workflow 卡(无 live taskId / sessionId):面板侧无该任务数据,
+ // 入口模式退回传统展开交互,description/summary 仍就地可读,不做假入口。
openBackgroundTasksTabMock.mockClear();
const { container } = render(
React.createElement(AgentTaskCard, {
- // sessionId 缺失 → 点击不跳转,外观不变。
+ // sessionId 缺失 → 不是面板入口,而是可展开卡。
update: {
provider: 'claude-code',
taskId: 'wf-1',
- status: 'running',
+ status: 'completed',
taskType: 'local_workflow',
+ summary: 'WORKFLOW_HISTORY_SUMMARY',
},
}),
);
- const btn = headerButton(container);
- expect(btn).not.toBeNull();
+ // 无面板入口按钮,但有展开 toggle(aria-expanded 存在)。
+ expect(headerButton(container)).toBeNull();
+ const toggleBtn = container.querySelector<HTMLButtonElement>('button[aria-expanded]');
+ expect(toggleBtn).not.toBeNull();
act(() => {
- btn!.click();
+ toggleBtn!.click();
});
expect(openBackgroundTasksTabMock).not.toHaveBeenCalled();
+ expect(container.textContent).toContain('WORKFLOW_HISTORY_SUMMARY');
});
it('renders no inline expand region for workflow cards', () => {
diff --git a/apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx b/apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx
index 495719ec56..c77f733ae2 100644
--- a/apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx
+++ b/apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx
@@ -153,9 +153,12 @@ export function AgentTaskCard({ toolCall, update, result, subagentModel, session
.finally(() => setStopping(false));
}, [sessionId, update?.taskId]);
- // workflow 卡整卡点击 → 打开右栏后台任务面板并定位本任务;sessionId / taskId
- // 任一缺失(历史孤儿卡)时降级 no-op,外观不变。
+ // workflow 卡整卡点击 → 打开右栏后台任务面板并定位本任务。入口模式要求
+ // sessionId 与 live taskId 都在;历史重载卡(update 为空,面板侧也无该任务的
+ // 数据)退回传统展开交互,让 description/summary(Workflow 最终结果文本)仍然
+ // 就地可读,不做「点了没反应」的假入口。
const workflowTaskId = update?.taskId;
+ const canOpenInPanel = Boolean(sessionId) && Boolean(workflowTaskId);
const openInPanel = useCallback(() => {
if (!sessionId || !workflowTaskId) return;
void openBackgroundTasksTab(sessionId, { focusTaskId: workflowTaskId });
@@ -215,9 +218,9 @@ export function AgentTaskCard({ toolCall, update, result, subagentModel, session
<div className="flex w-full items-start gap-2">
<button
type="button"
- onClick={isWorkflow ? openInPanel : toggle}
+ onClick={isWorkflow && canOpenInPanel ? openInPanel : toggle}
className="flex min-w-0 flex-1 items-start gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
- {...(isWorkflow
+ {...(isWorkflow && canOpenInPanel
? { 'aria-label': t('chat.agentTask.openInPanel') }
: {
'aria-expanded': expanded,
@@ -278,7 +281,7 @@ export function AgentTaskCard({ toolCall, update, result, subagentModel, session
</span>
)}
</span>
- {isWorkflow ? (
+ {isWorkflow && canOpenInPanel ? (
<PanelRight
size={14}
className="mt-1 shrink-0 text-[var(--text-tertiary)]"
@@ -316,8 +319,9 @@ export function AgentTaskCard({ toolCall, update, result, subagentModel, session
)}
</div>
- {/* workflow 卡不渲染展开区:详情(逐 agent 进度树等)在后台任务面板。 */}
- {!isWorkflow && (
+ {/* live workflow 卡不渲染展开区(详情在后台任务面板);历史 workflow 卡
+ (无 live taskId,面板无数据)保留展开区兜底展示 description/summary。 */}
+ {!(isWorkflow && canOpenInPanel) && (
<Collapse open={expanded}>
<div className="mt-2 border-l-2 border-[var(--agent-actions-rail)] pl-3 text-13 leading-5 text-[var(--text-secondary)]">
{description && <p className="mb-1">{description}</p>}
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index 124cfaa80a..8a48b5a6cb 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -1553,15 +1553,16 @@ export function CCAgentSessionView({
return;
}
if (payload.command === 'workflows') {
- // workflow 的主视图在右栏「后台任务」面板:从本会话任务表取最近一个
- // local_workflow 任务,打开面板并定位到该任务详情;没有则 toast。数据/展现
+ // workflow 的主视图在右栏「后台任务」面板:有 live workflow 任务则打开面板
+ // 并定位其详情;没有(如重载后任务表已清空)也打开面板列表 —— 列表基于消息
+ // 扫描,历史 workflow 行仍可见,比 toast「暂无」更符合命令语义。数据/展现
// 全在本地,不回 SDK(原生 /workflows 在非交互 SDK 模式下不可用)。
+ if (!sessionId) return;
const latest = findLatestWorkflowTask(taskUpdatesRef.current);
- if (!sessionId || !latest) {
- toast.warning(t('workflows.toast.none'));
- return;
- }
- void openBackgroundTasksTab(sessionId, { focusTaskId: latest.taskId });
+ void openBackgroundTasksTab(
+ sessionId,
+ latest ? { focusTaskId: latest.taskId } : {},
+ );
return;
}
// 'issue' 命令由下方独立 effect 处理(需要 handleSend,其声明在本 effect 之后)。
diff --git a/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx b/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx
index 4118ca51be..2bc91d8e08 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx
@@ -14,7 +14,7 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { FileDiff, FolderTree, Globe, Terminal } from 'lucide-react';
+import { FileDiff, FolderTree, Globe, ListTodo, Terminal } from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { listGhostTabMenuMetas, useTabKindRegistryVersion } from './registry';
@@ -54,6 +54,14 @@ const MENU_ITEMS: TabKindMenuMeta[] = [
enabled: true,
singleton: true,
},
+ {
+ kind: 'background-tasks',
+ labelKey: 'rightSidebar.tabs.kinds.backgroundTasks',
+ icon: ListTodo,
+ order: 17,
+ enabled: true,
+ singleton: true,
+ },
{
kind: 'web-browser',
labelKey: 'rightSidebar.tabs.kinds.browser',
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
index 02598ece5d..5de32a9df5 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx
@@ -541,7 +541,16 @@ export function BackgroundTasksBody({
}, []);
if (selectedItem && selectedItem.kind === 'workflow') {
- return <WorkflowDetail item={selectedItem} sessionId={sessionId} onBack={handleBack} />;
+ // key 强制换任务时重挂载:WorkflowDetail 内部持有 fileProgress state,原地复用
+ // 会把上一个任务的 wf 文件数据(logs/detail/聚合)残留合进新任务的树。
+ return (
+ <WorkflowDetail
+ key={selectedItem.key}
+ item={selectedItem}
+ sessionId={sessionId}
+ onBack={handleBack}
+ />
+ );
}
if (running.length === 0 && completed.length === 0) {
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 03969e1a73..f5059ca9df 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -7178,11 +7178,6 @@
"learnButton": "Learn this skill"
}
},
- "workflows": {
- "toast": {
- "none": "No workflow is running in this session"
- }
- },
"planMode": {
"menuItem": "Plan mode",
"indicator": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 0f00344584..71299c92e5 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -7167,11 +7167,6 @@
"learnButton": "このスキルを学習"
}
},
- "workflows": {
- "toast": {
- "none": "このセッションで実行中のワークフローはありません"
- }
- },
"planMode": {
"menuItem": "計画モード",
"indicator": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 2ae9d0f098..e459f03533 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -7167,11 +7167,6 @@
"learnButton": "이 스킬 학습하기"
}
},
- "workflows": {
- "toast": {
- "none": "이 세션에서 실행 중인 워크플로우가 없습니다"
- }
- },
"planMode": {
"menuItem": "계획 모드",
"indicator": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 7cf3427cc9..fe49f6e19d 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -7167,11 +7167,6 @@
"learnButton": "学习此技能"
}
},
- "workflows": {
- "toast": {
- "none": "当前对话没有正在运行的 Workflow"
- }
- },
"planMode": {
"menuItem": "计划模式",
"indicator": {