Repository navigation
Support primitives passing value to forceInput widgets #12201
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
base: main
Are you sure you want to change the base?
Changes from all commits
8f4081b
960cf20
aaa9498
57aa435
5219793
21f8c72
44b03d3
c9657c5
1f59708
ab89994
9819ea0
8ae0c43
2265c98
0aaa913
7bc87cf
9eaa21f
54249f6
1ce7d0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| { | ||
| "last_node_id": 2, | ||
| "last_link_id": 1, | ||
| "nodes": [ | ||
| { | ||
| "id": 1, | ||
| "type": "PrimitiveNode", | ||
| "pos": [50, 50], | ||
| "size": [300, 110], | ||
| "flags": {}, | ||
| "order": 0, | ||
| "mode": 0, | ||
| "inputs": [], | ||
| "outputs": [ | ||
| { | ||
| "name": "INT", | ||
| "type": "INT", | ||
| "links": [1], | ||
| "slot_index": 0, | ||
| "widget": { | ||
| "name": "int_input" | ||
| } | ||
| } | ||
| ], | ||
| "properties": { | ||
| "Run widget replace on values": false | ||
| }, | ||
| "widgets_values": [3, "fixed"] | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "type": "DevToolsNodeWithForceInput", | ||
| "pos": [450, 50], | ||
| "size": [315, 110], | ||
| "flags": {}, | ||
| "order": 1, | ||
| "mode": 0, | ||
| "inputs": [ | ||
| { | ||
| "name": "int_input", | ||
| "type": "INT", | ||
| "link": 1 | ||
| }, | ||
| { | ||
| "name": "float_input", | ||
| "type": "FLOAT", | ||
| "link": null, | ||
| "shape": 7 | ||
| } | ||
| ], | ||
| "outputs": [], | ||
| "properties": { | ||
| "Node name for S&R": "DevToolsNodeWithForceInput" | ||
| }, | ||
| "widgets_values": [1] | ||
| } | ||
| ], | ||
| "links": [[1, 1, 0, 2, 0, "INT"]], | ||
| "groups": [], | ||
| "config": {}, | ||
| "extra": { | ||
| "ds": { | ||
| "scale": 1, | ||
| "offset": [0, 0] | ||
| } | ||
| }, | ||
| "version": 0.4 | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||
| import type { | ||||||||||||
| LGraph, | ||||||||||||
| LGraphNode, | ||||||||||||
| LLink, | ||||||||||||
| Subgraph, | ||||||||||||
| SubgraphNode | ||||||||||||
| } from '@comfyorg/graph-model/entityRegistry' | ||||||||||||
|
|
@@ -41,6 +42,8 @@ type ResolvedInput = { | |||||||||||
| origin_slot: number | ||||||||||||
| /** Boxed widget value (e.g. for widgets). If this box is `undefined`, then an input link is connected, and widget values from the subgraph node are ignored. */ | ||||||||||||
| widgetInfo?: { value: unknown } | ||||||||||||
| /** `true` when {@link widgetInfo} is a virtual node's value, which only inputs without a widget accept. */ | ||||||||||||
| virtualValue?: true | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -231,10 +234,19 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Not part of a subgraph; use the original link | ||||||||||||
| return this._resolveGraphLink(link, input, visited, type) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private _resolveGraphLink( | ||||||||||||
| link: LLink, | ||||||||||||
| input: ExecutableNodeDTO['inputs'][number], | ||||||||||||
| visited: Set<string>, | ||||||||||||
| type?: ISlotType | ||||||||||||
| ): ResolvedInput | undefined { | ||||||||||||
| const outputNode = this.graph.getNodeById(link.origin_id) | ||||||||||||
| if (!outputNode) | ||||||||||||
| throw new InvalidLinkError( | ||||||||||||
| `No input node found for id [${this.id}] slot [${slot}] ${input.name}` | ||||||||||||
| `No input node found for id [${this.id}] slot [${link.target_slot}] ${input.name}` | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| const outputNodeExecutionId: ExecutionId = [ | ||||||||||||
|
|
@@ -247,11 +259,40 @@ export class ExecutableNodeDTO implements ExecutableLGraphNode { | |||||||||||
| `No output node DTO found for id [${outputNodeExecutionId}]` | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| return outputNodeDto.resolveOutput( | ||||||||||||
| const resolved = outputNodeDto.resolveOutput( | ||||||||||||
| link.origin_slot, | ||||||||||||
| type ?? input.type, | ||||||||||||
| visited | ||||||||||||
| ) | ||||||||||||
| if (this.node.inputs[link.target_slot]?.widget) | ||||||||||||
| return resolved?.virtualValue ? undefined : resolved | ||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| resolved ?? | ||||||||||||
| this._resolveWidgetlessVirtualValue(link, outputNode, outputNodeDto) | ||||||||||||
| ) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private _resolveWidgetlessVirtualValue( | ||||||||||||
| link: LLink, | ||||||||||||
| outputNode: LGraphNode, | ||||||||||||
| outputNodeDto: ExecutableLGraphNode | ||||||||||||
| ): ResolvedInput | undefined { | ||||||||||||
| if ( | ||||||||||||
| outputNodeDto.mode === LGraphEventMode.NEVER || | ||||||||||||
| outputNodeDto.mode === LGraphEventMode.BYPASS | ||||||||||||
| ) | ||||||||||||
| return | ||||||||||||
|
|
||||||||||||
| const value = outputNode.resolveVirtualValue?.(link.origin_slot) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Carry primitive values through subgraph and cross-graph forwarding. The A Primitive connected directly to a non-widget input supplies its value through the fallback at line 269. The same Primitive, reached through a subgraph output or a cross-graph virtual node, returns undefined from Resolve the fallback against the node that owns the forwarded output, not the immediate origin. The exact change depends on how the forwarding chain is walked, so this comment does not propose a patch.
|
||||||||||||
| if (value === undefined) return | ||||||||||||
|
Comment on lines
+287
to
+288
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip muted Primitives in the virtual-value fallback.
If muted Primitives should not feed these connections, add the guard before the fallback: Suggested fix
Widget inputs already receive muted Primitive values through Committable suggestion
|
||||||||||||
| return { | ||||||||||||
| node: outputNodeDto, | ||||||||||||
| origin_id: outputNodeDto.id, | ||||||||||||
| origin_slot: -1, | ||||||||||||
| widgetInfo: { value }, | ||||||||||||
| virtualValue: true | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.