diff --git a/src/components/WorkflowCanvas.tsx b/src/components/WorkflowCanvas.tsx index ea3d636b..d2cae88c 100644 --- a/src/components/WorkflowCanvas.tsx +++ b/src/components/WorkflowCanvas.tsx @@ -961,12 +961,14 @@ export function WorkflowCanvas() { sourceHandleIdForNewNode = handleType; } } else if (nodeType === "switch") { - // Switch accepts any type on generic-input, outputs match that type - targetHandleId = "generic-input"; + // Switch input: use the actual type so the edge stores the correct handle type + // (onConnect bypasses resolveSwitchHandle, so we must resolve here) + targetHandleId = handleType || "generic-input"; + if (handleType) { + updateNodeData(newNodeId, { inputType: handleType as HandleType }); + } // Switch outputs use dynamic handle IDs (switch entry IDs) - // For connection purposes, we'll connect to the first switch output - // The resolveSwitchHandle will update inputType when input connects - sourceHandleIdForNewNode = null; // Switch outputs are dynamic, no static handle ID + sourceHandleIdForNewNode = null; } else if (handleType === "image") { if (nodeType === "annotation" || nodeType === "output" || nodeType === "splitGrid" || nodeType === "outputGallery" || nodeType === "imageCompare") { targetHandleId = "image"; diff --git a/src/components/nodes/SwitchNode.tsx b/src/components/nodes/SwitchNode.tsx index e015f428..2a5b14d6 100644 --- a/src/components/nodes/SwitchNode.tsx +++ b/src/components/nodes/SwitchNode.tsx @@ -26,7 +26,10 @@ export const SwitchNode = memo(({ id, data, selected }: NodeProps) // Derive inputType from incoming edge connection const derivedInputType = useMemo(() => { const inputEdge = edges.find((e) => e.target === id); - return inputEdge?.targetHandle as HandleType | undefined; + const handle = inputEdge?.targetHandle; + // "generic-input" means the edge hasn't been resolved to a real type yet + if (!handle || handle === "generic-input") return undefined; + return handle as HandleType; }, [edges, id]); // Update stored inputType when derived type changes