mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-27 11:29:53 +00:00
* [fix] resolve group node execution error when connecting to external nodes Fixed ExecutableGroupNodeChildDTO.resolveInput to properly handle connections from group node children to external nodes. The method now tries to find nodes by their full ID first (for external nodes) before falling back to the shortened ID (for internal group nodes). Added comprehensive unit tests to prevent regression. * [feat] Add error check for unsupported group nodes inside subgraphs Added validation to detect when group node children are executing within subgraph contexts (execution ID has >2 segments) and provide clear error message directing users to convert to subgraphs instead. Includes comprehensive test coverage for the new validation.
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import type { GroupNodeHandler } from '@/extensions/core/groupNode'
|
|
import {
|
|
type ExecutableLGraphNode,
|
|
ExecutableNodeDTO,
|
|
type ExecutionId,
|
|
type LGraphNode,
|
|
type NodeId,
|
|
type SubgraphNode
|
|
} from '@/lib/litegraph/src/litegraph'
|
|
|
|
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) {
|
|
// Check if this group node is inside a subgraph (unsupported)
|
|
if (this.id.split(':').length > 2) {
|
|
throw new Error(
|
|
'Group nodes inside subgraphs are not supported. Please convert the group node to a subgraph instead.'
|
|
)
|
|
}
|
|
|
|
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 inputNodeId = String(inputNode.id)
|
|
|
|
// Try to find the node using the full ID first (for nodes outside the group)
|
|
let inputNodeDto = this.nodesByExecutionId?.get(inputNodeId)
|
|
|
|
// If not found, try with just the last part of the ID (for nodes inside the group)
|
|
if (!inputNodeDto) {
|
|
const id = inputNodeId.split(':').at(-1)
|
|
if (id !== undefined) {
|
|
inputNodeDto = this.nodesByExecutionId?.get(id)
|
|
}
|
|
}
|
|
|
|
if (!inputNodeDto) {
|
|
throw new Error(
|
|
`Failed to get input node ${inputNodeId} for group node child ${this.id} with slot ${slot}`
|
|
)
|
|
}
|
|
|
|
return {
|
|
node: inputNodeDto,
|
|
origin_id: inputNodeId,
|
|
origin_slot: link.origin_slot
|
|
}
|
|
}
|
|
}
|