Improve execution logic / Fix group node execution (#4422)

This commit is contained in:
filtered
2025-07-11 17:40:48 +10:00
committed by GitHub
parent 998abbbdbd
commit 5c119fcbda
5 changed files with 258 additions and 71 deletions

View File

@@ -0,0 +1,53 @@
import {
type ExecutableLGraphNode,
ExecutableNodeDTO,
type ExecutionId,
type LGraphNode,
type NodeId,
type SubgraphNode
} from '@comfyorg/litegraph'
import type { GroupNodeHandler } from '@/extensions/core/groupNode'
export class ExecutableGroupNodeChildDTO extends ExecutableNodeDTO {
groupNodeHandler?: GroupNodeHandler
constructor(
/** The actual node that this DTO wraps. */
node: LGraphNode | SubgraphNode,
/** A list of subgraph instance node IDs from the root graph to the containing instance. @see {@link id} */
subgraphNodePath: readonly NodeId[],
/** A flattened map of all DTOs in this node network. Subgraph instances have been expanded into their inner nodes. */
nodesByExecutionId: Map<ExecutionId, ExecutableLGraphNode>,
/** The actual subgraph instance that contains this node, otherise undefined. */
subgraphNode?: SubgraphNode | undefined,
groupNodeHandler?: GroupNodeHandler
) {
super(node, subgraphNodePath, nodesByExecutionId, subgraphNode)
this.groupNodeHandler = groupNodeHandler
}
override resolveInput(slot: number) {
const inputNode = this.node.getInputNode(slot)
if (!inputNode) return
const link = this.node.getInputLink(slot)
if (!link) throw new Error('Failed to get input link')
const id = String(inputNode.id).split(':').at(-1)
if (id === undefined) throw new Error('Invalid input node id')
const inputNodeDto = this.nodesByExecutionId?.get(id)
if (!inputNodeDto) {
throw new Error(
`Failed to get input node ${id} for group node child ${this.id} with slot ${slot}`
)
}
return {
node: inputNodeDto,
origin_id: inputNode.id,
origin_slot: link.origin_slot
}
}
}