Jelajahi Sumber

fix: data connections were dropped on load once nodes gained a config handle

Connecting a trigger to a node and saving lost the connection, and reopening a
workflow showed only its configuration edges. I caused this two commits ago.

A single-input node rendered its data handle with no id, which was fine while
that was the node's only target handle - an edge stored as targetInput "data"
had nowhere else to land, so ReactFlow attached it anyway. Adding the config
handle on the left made a node have two target handles, one of them anonymous.
On load the stored "data" matched neither, ReactFlow dropped the edge, and the
next save wrote the workflow back without it. Retrying looked like it worked,
because the edge was accepted on the canvas and only disappeared on the next
load - which is why the affected workflow had ended up with six copies of the
same connection.

Every data handle now carries its own name as its id, single-input or not.

The duplicate connections this produced in the sdcpp workflow have been removed
separately; the workflow is back to its six real connections.
fszontagh 1 bulan lalu
induk
melakukan
6ad8da9414
1 mengubah file dengan 11 tambahan dan 2 penghapusan
  1. 11 2
      webui/src/components/workflow/WorkflowNode.tsx

+ 11 - 2
webui/src/components/workflow/WorkflowNode.tsx

@@ -126,13 +126,22 @@ export function WorkflowNode({ data, selected }: NodeProps) {
       style={getStatusStyle()}
     >
       {/* Input handles at top (not for triggers). A node that names more than
-          one input gets a handle each, spread the way outputs are. */}
+          one input gets a handle each, spread the way outputs are.
+
+          Every data handle carries its name as an id, even when there is only
+          one of them. It used to be left undefined in the single-input case,
+          which worked while that was a node's only target handle: an edge
+          stored as targetInput "data" had nowhere else to land. Adding the
+          config handle on the left made that ambiguous - two target handles,
+          one of them anonymous - and on reload the stored "data" matched
+          neither, so the edge was silently dropped and the save wrote the
+          workflow back without it. */}
       {!isTrigger && !isConfigurator && inputs.map((input, idx) => (
         <Handle
           key={input.name}
           type="target"
           position={Position.Top}
-          id={inputs.length > 1 ? input.name : undefined}
+          id={input.name}
           className="!w-3 !h-3 !bg-gray-400 dark:!bg-gray-500 !border-2 !border-white dark:!border-slate-800"
           style={inputs.length > 1 ? { left: `${calculateHandlePosition(idx, inputs.length)}%` } : undefined}
         />