Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compound type propagation for selectOutput #4763

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/client/hmi-client/src/services/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
mwdchang marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
Loading