From 55d2b300a62ae1e1dfd6f0b91aeb55545d2fbc9a Mon Sep 17 00:00:00 2001 From: AustinMroz Date: Mon, 20 Oct 2025 10:02:41 -0700 Subject: [PATCH] Fix link resolution of virtual nodes (#6135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some virtual nodes (like get/set nodes) perform link redirection at prompt resolution. The prior implementation incorrectly tried to return the source of the virtual link after resolution, but this causes things to break when the source of the virtual link is a subgraph IO. Instead, this PR changes the code section to restart resolution from the destination of the virtual link so that the existing subgraph boundary resolution code is applied. Also fix a bug with reconnection of complex/any types on conversion to subgraph. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6135-Fix-link-resolution-of-virtual-nodes-2916d73d36508183b891ef6eb39bad4c) by [Unito](https://www.unito.io) --- src/lib/litegraph/src/LGraph.ts | 2 +- .../src/subgraph/ExecutableNodeDTO.ts | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib/litegraph/src/LGraph.ts b/src/lib/litegraph/src/LGraph.ts index 7f32a7c52..b588baa74 100644 --- a/src/lib/litegraph/src/LGraph.ts +++ b/src/lib/litegraph/src/LGraph.ts @@ -1665,7 +1665,7 @@ export class LGraph continue } - const input = subgraphNode.findInputSlotByType(link.type, true, true) + const input = subgraphNode.inputs[i - 1] outputNode.connectSlots(output, subgraphNode, input, link.parentId) } diff --git a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts index f041376f6..2dea0ebcd 100644 --- a/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts +++ b/src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts @@ -294,25 +294,21 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { // Fallback check for nodes performing link redirection const virtualLink = this.node.getInputLink(slot) if (virtualLink) { - const outputNode = this.graph.getNodeById(virtualLink.origin_id) - if (!outputNode) + const { inputNode } = virtualLink.resolve(this.graph) + if (!inputNode) throw new InvalidLinkError( `Virtual node failed to resolve parent [${this.id}] slot [${slot}]` ) - const outputNodeExecutionId = [ + const inputNodeExecutionId = [ ...this.subgraphNodePath, - outputNode.id + inputNode.id ].join(':') - const outputNodeDto = this.nodesByExecutionId.get(outputNodeExecutionId) - if (!outputNodeDto) - throw new Error(`No output node DTO found for id [${outputNode.id}]`) + const inputNodeDto = this.nodesByExecutionId.get(inputNodeExecutionId) + if (!inputNodeDto) + throw new Error(`No input node DTO found for id [${inputNode.id}]`) - return outputNodeDto.resolveOutput( - virtualLink.origin_slot, - type, - visited - ) + return inputNodeDto.resolveInput(virtualLink.target_slot, visited, type) } // Virtual nodes without a matching input should be discarded.