Browse Source

fix: blue nodes also show goal

guantao 3 days ago
parent
commit
927a2ab8d4

+ 1 - 0
examples/restore/run.py

@@ -42,6 +42,7 @@ from agent.llm import create_openrouter_llm_call
 from agent.tools import get_tool_registry
 
 
+os.environ.setdefault("no_proxy", "*")
 # ===== 非阻塞 stdin 检测 =====
 if sys.platform == 'win32':
     import msvcrt

+ 16 - 8
frontend/react-template/src/components/FlowChart/FlowChart.tsx

@@ -810,18 +810,27 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
   const handleNodeClick = useCallback(
     (node: LayoutNode) => {
       if (node.type === "goal") {
-        // 检查是否是子节点 (subgoal)
-        if (node.parentId && onSubTraceClick) {
+        const goalData = node.data as Goal;
+
+        // 只有具有 sub_trace_ids 的子目标节点(agent 委托执行)才触发 trace 切换
+        // 普通的 sub_goal 节点(蓝色节点)没有 sub_trace_ids,应该打开 DetailPanel
+        const hasSubTraces = goalData.sub_trace_ids && goalData.sub_trace_ids.length > 0;
+
+        if (node.parentId && onSubTraceClick && hasSubTraces) {
           const parentNode = layoutData.nodes.find((n) => n.id === node.parentId);
           if (parentNode && parentNode.type === "goal") {
-            // 如果是子节点,触发 onSubTraceClick
-            const entry: SubTraceEntry = { id: (node.data as Goal).id };
+            // 取第一个 sub_trace_id 作为跳转目标(使用 trace_id,而非 goal.id)
+            const firstEntry = goalData.sub_trace_ids![0];
+            const entry: SubTraceEntry =
+              typeof firstEntry === "string"
+                ? { id: firstEntry }
+                : { id: firstEntry.trace_id, mission: firstEntry.mission };
             onSubTraceClick(parentNode.data as Goal, entry);
             return;
           }
         }
 
-        // 主链节点,触发 onNodeClick
+        // 主链节点 或 没有 sub_trace_ids 的普通子目标节点 → 打开 DetailPanel
         setSelectedNodeId(node.id);
         onNodeClick?.(node.data as Goal);
       } else if (node.type === "message") {
@@ -950,9 +959,8 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
                     {/* 折叠状态提示徽章 */}
                     {edge.collapsed && (
                       <g
-                        transform={`translate(${(edge.source.x + edge.target.x) / 2},${
-                          (edge.source.y + edge.target.y) / 2
-                        })`}
+                        transform={`translate(${(edge.source.x + edge.target.x) / 2},${(edge.source.y + edge.target.y) / 2
+                          })`}
                         onClick={(e) => {
                           e.stopPropagation();
                           toggleCollapse(edge.id);