diff --git a/packages/client/hmi-client/src/services/workflow.ts b/packages/client/hmi-client/src/services/workflow.ts index 283e990c33..1d314c7be8 100644 --- a/packages/client/hmi-client/src/services/workflow.ts +++ b/packages/client/hmi-client/src/services/workflow.ts @@ -473,8 +473,35 @@ export class WorkflowWrapper { const targetPort = targetNode.inputs.find((port) => port.id === edge.targetPortId); if (!targetPort) return; edge.sourcePortId = selected.id; // Sync edge source port to selected output + + /** + * Handle compound type unwrangling, this is very similar to what + * we do in addEdge(...) but s already connected. + * */ + const selectedTypes = selected.type.split('|').map((d) => d.trim()); + const allowedInputTypes = targetPort.type.split('|').map((d) => d.trim()); + const intersectionTypes = _.intersection(selectedTypes, allowedInputTypes); + + // Sanity check: multiple matches found + if (intersectionTypes.length > 1) { + console.error(`Ambiguous matching types [${selectedTypes}] to [${allowedInputTypes}]`); + return; + } + // Sanity check: no matches found + if (intersectionTypes.length === 0) { + return; + } + + if (selectedTypes.length > 1) { + const concreteType = intersectionTypes[0]; + if (selected.value) { + targetPort.value = [selected.value[0][concreteType]]; + } + } else { + targetPort.value = selected.value; // mark + } + targetPort.label = selected.label; - targetPort.value = selected.value; } // Collect node cache