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 修复——保留无 agentId 的排队行;方块条 tooltip 本地化

Kafeifei4c6dba07ec49
diff --git a/apps/desktop/src/main/workflow-progress/__tests__/reader.test.ts b/apps/desktop/src/main/workflow-progress/__tests__/reader.test.ts
index b0ee0c14e3..056442c67f 100644
--- a/apps/desktop/src/main/workflow-progress/__tests__/reader.test.ts
+++ b/apps/desktop/src/main/workflow-progress/__tests__/reader.test.ts
@@ -217,13 +217,27 @@ describe('extractWorkflowProgress', () => {
runId: 'wf_x',
status: 'running',
workflowProgress: [
- { type: 'workflow_agent', label: 'no-id' }, // 缺 agentId/state → skip
+ { type: 'workflow_agent', label: 'no-state' }, // 缺 state → skip
+ { type: 'workflow_agent', state: 'queued' }, // label 与 agentId 双缺 → skip
{ type: 'workflow_agent', agentId: 'a1', state: 'done' }, // label 缺 → 回退 agentId
],
});
expect(p!.agents).toEqual([{ label: 'a1', agentId: 'a1', state: 'done' }]);
});
+ it('keeps agents that have a label but no assigned agentId yet (queued rows)', () => {
+ // 排队中的 agent 尚未分配 id(事件流侧同形态):不得丢行,否则重载后的树
+ // 比 live 少行。
+ const p = extractWorkflowProgress({
+ runId: 'wf_x',
+ status: 'running',
+ workflowProgress: [
+ { type: 'workflow_agent', label: 'verify:auth', state: 'queued', phaseIndex: 0 },
+ ],
+ });
+ expect(p!.agents).toEqual([{ label: 'verify:auth', state: 'queued' }]);
+ });
+
it('returns null when runId is missing or input is not an object', () => {
expect(extractWorkflowProgress({ status: 'completed' })).toBeNull();
expect(extractWorkflowProgress(null)).toBeNull();
diff --git a/apps/desktop/src/main/workflow-progress/reader.ts b/apps/desktop/src/main/workflow-progress/reader.ts
index a83f15f125..cc2d29bf6f 100644
--- a/apps/desktop/src/main/workflow-progress/reader.ts
+++ b/apps/desktop/src/main/workflow-progress/reader.ts
@@ -97,9 +97,13 @@ export function extractWorkflowProgress(record: unknown): WorkflowProgress | nul
const index = asNumber(e.index);
if (title && index != null) phases.push({ index, title });
} else if (e.type === 'workflow_agent') {
+ // agentId 允许缺失:排队中的 agent 尚未分配 id(事件流侧同语义),workflow
+ // 提前退出时文件里会留下这种行 —— 丢弃会让重载后的树比 live 少行。
+ // label 与 agentId 双缺才跳过(没有任何可展示身份)。
const agentId = asString(e.agentId);
const state = asString(e.state);
- if (!agentId || !state) continue;
+ const label = asString(e.label) ?? agentId;
+ if (!label || !state) continue;
const model = asString(e.model);
const phaseTitle = asString(e.phaseTitle);
const attempt = asNumber(e.attempt);
@@ -109,8 +113,8 @@ export function extractWorkflowProgress(record: unknown): WorkflowProgress | nul
const durationMs = asNumber(e.durationMs);
const error = asTruncated(e.error, 300);
agents.push({
- label: asString(e.label) ?? agentId,
- agentId,
+ label,
+ ...(agentId ? { agentId } : {}),
state,
...(model ? { model } : {}),
...(phaseTitle ? { phaseTitle } : {}),
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx
index 8dd21facb7..c371744c96 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx
@@ -6,11 +6,13 @@
* 语义 token,与状态点/running 色的设计定稿同源)。
*
* - 纯视觉增强,aria-hidden(相邻的摘要行/聚合行已承担文字语义);每格 title
- * 提示 label · state(数据原词透传,非 i18n 文案)。
+ * 提示 label · 状态(状态经 chat.workflowTree.state.* 本地化,词表外原词兜底)。
* - 无动画(DESIGN.md §14.4:不为常驻状态加循环动效,状态变化直接换色)。
* - maxVisible 截断(卡片等紧凑场景),超出部分以 +n 文本收尾。
*/
+import { useTranslation } from 'react-i18next';
+
import {
workflowAgentVisualState,
type WorkflowAgentVisualState,
@@ -36,9 +38,18 @@ export function WorkflowAgentStrip({
/** 紧凑场景(聊天卡片)截断上限;省略 = 全量 wrap。 */
maxVisible?: number;
}) {
+ const { t } = useTranslation();
if (cells.length === 0) return null;
const visible = maxVisible !== undefined ? cells.slice(0, maxVisible) : cells;
const overflow = cells.length - visible.length;
+ // title 是用户可见 tooltip:状态词走 i18n(与树行同一词表 key),词表外原词兜底。
+ const cellTitle = (cell: WorkflowAgentStripCell): string | undefined => {
+ const stateLabel = cell.state
+ ? t(`chat.workflowTree.state.${cell.state}`, { defaultValue: cell.state })
+ : undefined;
+ if (cell.label && stateLabel) return `${cell.label} · ${stateLabel}`;
+ return cell.label ?? stateLabel;
+ };
return (
<span
data-workflow-agent-strip="true"
@@ -49,7 +60,7 @@ export function WorkflowAgentStrip({
<span
// 稳定序:workflow_progress 条目顺序即 spawn 顺序,index 作 key 足够。
key={i}
- title={cell.label ? `${cell.label} · ${cell.state ?? ''}` : cell.state}
+ title={cellTitle(cell)}
className={`h-2 w-2 rounded-[2px] ${STATE_BG[workflowAgentVisualState(cell.state)]}`}
/>
))}
diff --git a/apps/desktop/src/shared/workflow-progress.ts b/apps/desktop/src/shared/workflow-progress.ts
index ccbae6fa6b..9a7431cfea 100644
--- a/apps/desktop/src/shared/workflow-progress.ts
+++ b/apps/desktop/src/shared/workflow-progress.ts
@@ -10,7 +10,8 @@
export interface WorkflowAgentProgress {
/** 脚本里 agent() 的 label(如 "search:ai-tech");缺失时回退 agentId。 */
label: string;
- agentId: string;
+ /** 运行时 agent id;排队中尚未分配时缺失(与事件流 workflow_agent 同语义)。 */
+ agentId?: string;
/** 该 agent 实际跑的模型 raw id(如 claude-opus-4-8[1m])。 */
model?: string;
/** 运行时原始状态:queued / running / done / failed / stopped 等(原样透传)。 */