Prechádzať zdrojové kódy

refactor(旧布局): 移除固定 Phase flow 计算与测试

删除基于预设阶段框和静态边的布局算法及其单元测试。任务位置现在由真实 parent_task_id 与 display_path 动态生成,不再假设固定流程。
SamLee 15 hodín pred
rodič
commit
455f2805e7

+ 0 - 92
visualization/frontend/lib/flow.ts

@@ -1,92 +0,0 @@
-import { MarkerType, Position, type Edge, type Node } from "@xyflow/react";
-import type { FlowNodeRecord, Phase, PhaseFrame, RunGraph } from "@/lib/types";
-
-export type CardData = {
-  kind: "card";
-  item: FlowNodeRecord;
-  dimmed: boolean;
-} & Record<string, unknown>;
-
-export type FrameData = {
-  kind: "frame";
-  frame: PhaseFrame;
-} & Record<string, unknown>;
-
-export type CanvasData = CardData | FrameData;
-
-export const PHASE_LABELS: Record<Phase, string> = {
-  "phase-1": "Phase 1",
-  "phase-2": "Phase 2",
-  "phase-3": "Phase 3",
-  delivery: "Final Delivery",
-};
-
-const EDGE_COLOR = {
-  control: "#68707f",
-  artifact: "#4ca6d8",
-  validation: "#b68cff",
-  publication: "#5ec48d",
-};
-
-export function matchesNode(item: FlowNodeRecord, query: string): boolean {
-  const value = query.trim().toLocaleLowerCase();
-  if (!value) return true;
-  return [
-    item.title, item.subtitle, item.id, item.lane, item.status,
-    item.task_kind ?? "", item.agent_role ?? "", item.record.model_name,
-    ...item.tags,
-  ].some((part) => part.toLocaleLowerCase().includes(value));
-}
-
-export function buildCanvas(
-  graph: RunGraph,
-  enabledPhases: Set<Phase>,
-  query: string,
-): { nodes: Node<CanvasData>[]; edges: Edge[] } {
-  const visibleIds = new Set(
-    graph.nodes.filter((item) => enabledPhases.has(item.phase)).map((item) => item.id),
-  );
-  const frameNodes: Node<CanvasData>[] = graph.frames.map((frame) => {
-    const phase = frame.id.replace("frame-", "") as Phase;
-    return {
-      id: frame.id,
-      type: "phaseFrame",
-      position: { x: frame.x, y: frame.y },
-      data: { kind: "frame", frame },
-      style: { width: frame.width, height: frame.height },
-      selectable: false,
-      draggable: false,
-      connectable: false,
-      hidden: !enabledPhases.has(phase),
-      zIndex: -10,
-    };
-  });
-  const cardNodes: Node<CanvasData>[] = graph.nodes.map((item) => ({
-    id: item.id,
-    type: "flowCard",
-    position: { x: item.x, y: item.y },
-    data: { kind: "card", item, dimmed: !matchesNode(item, query) },
-    sourcePosition: Position.Right,
-    targetPosition: Position.Left,
-    style: { width: item.width },
-    hidden: !visibleIds.has(item.id),
-    zIndex: 2,
-  }));
-  const edges: Edge[] = graph.edges.map((edge) => ({
-    id: edge.id,
-    source: edge.source,
-    target: edge.target,
-    label: edge.label ?? undefined,
-    type: "smoothstep",
-    animated: edge.animated,
-    hidden: !visibleIds.has(edge.source) || !visibleIds.has(edge.target),
-    markerEnd: { type: MarkerType.ArrowClosed, width: 16, height: 16, color: EDGE_COLOR[edge.kind] },
-    style: { stroke: EDGE_COLOR[edge.kind], strokeWidth: edge.kind === "publication" ? 2.2 : 1.45 },
-    labelStyle: { fill: "#9aa0ab", fontSize: 10, fontWeight: 600 },
-    labelBgStyle: { fill: "#15171b", fillOpacity: 0.92 },
-    labelBgPadding: [5, 3] as [number, number],
-    labelBgBorderRadius: 5,
-  }));
-  return { nodes: [...frameNodes, ...cardNodes], edges };
-}
-

+ 0 - 22
visualization/frontend/tests/flow.test.ts

@@ -1,22 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { matchesNode } from "@/lib/flow";
-import type { FlowNodeRecord } from "@/lib/types";
-
-const node: FlowNodeRecord = {
-  id: "root-delivery:artifact", node_type: "artifact", phase: "phase-3",
-  lane: "root-delivery", title: "RootDeliveryManifest", subtitle: "唯一冻结 Manifest",
-  status: "frozen", agent_role: "worker", task_kind: "root-delivery", sequence: 1,
-  x: 0, y: 0, width: 268, tags: ["sha256"], metrics: [],
-  record: { model_name: "RootDeliveryManifestV1", schema_version: "root-delivery-manifest/v1", payload: {} },
-};
-
-describe("matchesNode", () => {
-  it("searches business labels, exact task kinds and schema model names", () => {
-    expect(matchesNode(node, "Manifest")).toBe(true);
-    expect(matchesNode(node, "root-delivery")).toBe(true);
-    expect(matchesNode(node, "sha256")).toBe(true);
-    expect(matchesNode(node, "mysql grant")).toBe(false);
-  });
-  it("keeps all nodes when query is blank", () => expect(matchesNode(node, "  ")).toBe(true));
-});
-