From dc5fdd7358db0d67a9677fb5584460acc3333a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=9C=88?= Date: Wed, 13 May 2026 16:37:07 +0800 Subject: [PATCH] fix(dashboard): address ELK layout review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What: Fix three non-blocking issues from PR #232 review. Why: Code quality — unhandled promise rejection risk, type safety, and project convention compliance. Changes: - packages/workflow-dashboard/src/components/workflow-graph/types.ts: add elkLabelX/elkLabelY fields to ConditionEdgeData type (number | null, not optional — per project no-optional-properties rule) - packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts: remove 'as ConditionEdgeData' type assertion (now unnecessary), add .catch() to computeLayout promise - packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx: remove redundant inline type extension, use ConditionEdgeData directly Ref: PR #232 review comments --- .../components/workflow-graph/condition-edge.tsx | 2 +- .../src/components/workflow-graph/types.ts | 2 ++ .../src/components/workflow-graph/use-layout.ts | 15 +++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx b/packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx index fffc9d4..a147c3d 100644 --- a/packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx +++ b/packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx @@ -20,7 +20,7 @@ export function ConditionEdge(props: EdgeProps) { data, markerEnd, } = props; - const edgeData = data as (ConditionEdgeData & { elkLabelX?: number | null; elkLabelY?: number | null }) | undefined; + const edgeData = data as ConditionEdgeData | undefined; const isFallback = edgeData?.isFallback ?? false; const isSelfLoop = source === target; diff --git a/packages/workflow-dashboard/src/components/workflow-graph/types.ts b/packages/workflow-dashboard/src/components/workflow-graph/types.ts index 0c509ce..01c639a 100644 --- a/packages/workflow-dashboard/src/components/workflow-graph/types.ts +++ b/packages/workflow-dashboard/src/components/workflow-graph/types.ts @@ -21,6 +21,8 @@ export type ConditionEdgeData = { condition: string; conditionDescription: string | null; isFallback: boolean; + elkLabelX: number | null; + elkLabelY: number | null; [key: string]: unknown; }; diff --git a/packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts b/packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts index ac022ad..76fddbb 100644 --- a/packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts +++ b/packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts @@ -99,7 +99,7 @@ function buildEdge(e: WorkflowGraphEdge, elkEdgeMap: Map, nodeStates: input.nodeStates, }; - computeLayout(parsed).then((result) => { - if (!cancelled) setLayout(result); - }); + computeLayout(parsed) + .then((result) => { + if (!cancelled) setLayout(result); + }) + .catch((err: unknown) => { + if (!cancelled) { + // biome-ignore lint/suspicious/noConsole: layout error reporting + console.error("ELK layout failed:", err); + } + }); return () => { cancelled = true; };