feat: Dashboard workflow graph visualization (React Flow) #204
Reference in New Issue
Block a user
Delete Branch "feat/198-dashboard-workflow-graph"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
在 Dashboard 的 ThreadDetail 页面中嵌入交互式流程图,将 workflow 的 ModeratorTable 可视化为有向图。
Why
Changes
Backend (
cli-workflow/src/commands/serve/routes-workflow.ts)GET /workflows/:name现在读取bundles/{hash}.yaml并返回descriptor(含 graph)Dashboard API (
workflow-dashboard/src/api.ts)WorkflowGraphEdge、WorkflowGraph、WorkflowDescriptor等类型getWorkflowDescriptor(agent, name)函数流程图组件 (
workflow-dashboard/src/components/workflow-graph/)7 个新文件:
types.ts— NodeState、节点/边数据类型use-layout.ts— dagre TB 自动布局 hook,处理自循环边role-node.tsx— 圆角矩形 role 节点,按状态着色 + active 脉冲terminal-node.tsx— START/END 圆形节点condition-edge.tsx— FALLBACK 虚线 / 条件边实线 + label + tooltipworkflow-graph.tsx— ReactFlow 容器,fitView、dark modeindex.ts— re-exports集成 (
workflow-dashboard/src/components/thread-detail.tsx)样式 (
index.css)wf-node-pulsekeyframe 动画Ref
Closes #198 (Phase 1)
Phase 1 可视化实现得很完整 ✅
亮点:
e.from === e.to跳过 dagre 但保留 React Flow 渲染computeNodeStates逻辑正确:最后一个 role 无 result 时 active,有 result 全部 completedgetWorkflowDescriptor用.then()解包——虽然项目约定 async/await,但这里是单行 transform 还行两个小 nit(不阻塞):
api.ts里getWorkflowDescriptor用了.then()链,项目约定 async/await。改成async函数更一致useLayout的 useMemo deps 是[input.edges, input.roles, input.nodeStates]——Map 对象每次 render 都是新引用,会导致 useMemo 失效。如果computeNodeStates返回的 Map 没 memo 住,layout 会每次重算。当前computeNodeStates在useMemo里所以应该没问题,但值得留意LGTM 🚀