Skip to content

Commit 6134452

Browse files
authored
Return SubgraphNode widget values during execution (#1114)
1 parent f90e7f1 commit 6134452

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/subgraph/ExecutableNodeDTO.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ export type ExecutionId = string
1919
export type ExecutableLGraphNode = Omit<ExecutableNodeDTO, "graph" | "node" | "subgraphNode">
2020

2121
type ResolvedInput = {
22+
/** DTO for the node that the link originates from. */
2223
node: ExecutableLGraphNode
23-
origin_id: NodeId
24+
/** Full unique execution ID of the node that the link originates from. */
25+
origin_id: ExecutionId
26+
/** The slot index of the output on the node that the link originates from. */
2427
origin_slot: number
28+
/** Actual value (e.g. for widgets). */
29+
value?: unknown
2530
}
2631

2732
/**
@@ -139,7 +144,18 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode {
139144

140145
// Nothing connected
141146
const linkId = subgraphNodeInput.link
142-
if (linkId == null) return
147+
if (linkId == null) {
148+
const widget = subgraphNode.getWidgetFromSlot(subgraphNodeInput)
149+
if (!widget) return
150+
151+
// Special case: SubgraphNode widget.
152+
return {
153+
node: this,
154+
origin_id: this.id,
155+
origin_slot: slot,
156+
value: widget.value,
157+
}
158+
}
143159

144160
const outerLink = subgraphNode.graph.getLink(linkId)
145161
if (!outerLink) throw new InvalidLinkError(`No outer link found for slot [${link.origin_slot}] ${input.name}`)

0 commit comments

Comments
 (0)