Skip to content

Commit 3269b54

Browse files
authored
Sync 2666 Execution Model Inversion (#312)
* Sync 2666 Execution Model Inversion * Fix unittest * Fallback compatible
1 parent 50c4c87 commit 3269b54

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

src/extensions/core/groupNode.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,13 @@ export class GroupNodeHandler {
11081108
const executed = handleEvent.call(
11091109
this,
11101110
'executed',
1111-
(d) => d?.node,
1112-
(d, id, node) => ({ ...d, node: id, merge: !node.resetExecution })
1111+
(d) => d?.display_node || d?.node,
1112+
(d, id, node) => ({
1113+
...d,
1114+
node: id,
1115+
display_node: id,
1116+
merge: !node.resetExecution
1117+
})
11131118
)
11141119

11151120
const onRemoved = node.onRemoved

src/extensions/core/widgetInputs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { LiteGraph } from '@comfyorg/litegraph'
55
import type { LGraphNode, INodeInputSlot, IWidget } from '@comfyorg/litegraph'
66

77
const CONVERTED_TYPE = 'converted-widget'
8-
const VALID_TYPES = ['STRING', 'combo', 'number', 'BOOLEAN']
8+
const VALID_TYPES = ['STRING', 'combo', 'number', 'toggle', 'BOOLEAN']
99
const CONFIG = Symbol()
1010
const GET_CONFIG = Symbol()
1111
const TARGET = Symbol() // Used for reroutes to specify the real target widget

src/scripts/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ class ComfyApi extends EventTarget {
171171
break
172172
case 'executing':
173173
this.dispatchEvent(
174-
new CustomEvent('executing', { detail: msg.data.node })
174+
new CustomEvent('executing', {
175+
detail: msg.data.display_node || msg.data.node
176+
})
175177
)
176178
break
177179
case 'executed':

src/scripts/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ export class ComfyApp {
16271627
this.workflowManager.activeWorkflow
16281628
)
16291629
return
1630-
const output = this.nodeOutputs[detail.node]
1630+
const output = this.nodeOutputs[detail.display_node || detail.node]
16311631
if (detail.merge && output) {
16321632
for (const k in detail.output ?? {}) {
16331633
const v = output[k]
@@ -1638,9 +1638,9 @@ export class ComfyApp {
16381638
}
16391639
}
16401640
} else {
1641-
this.nodeOutputs[detail.node] = detail.output
1641+
this.nodeOutputs[detail.display_node || detail.node] = detail.output
16421642
}
1643-
const node = this.graph.getNodeById(detail.node)
1643+
const node = this.graph.getNodeById(detail.display_node || detail.node)
16441644
if (node) {
16451645
// @ts-expect-error
16461646
if (node.onExecuted)

src/scripts/ui.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ class ComfyList {
272272
false
273273
)
274274
if ('outputs' in item) {
275-
app.nodeOutputs = item.outputs
275+
app.nodeOutputs = {}
276+
for (const [key, value] of Object.entries(item.outputs)) {
277+
const realKey = item['meta']?.[key]?.display_node ?? key
278+
app.nodeOutputs[realKey] = value
279+
}
276280
}
277281
}
278282
}),

tests-ui/tests/groupNode.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ describe('group node', () => {
578578
new CustomEvent('executed', {
579579
detail: {
580580
node: `${nodes.save.id}`,
581+
display_node: `${nodes.save.id}`,
581582
output: {
582583
images: [
583584
{
@@ -618,6 +619,7 @@ describe('group node', () => {
618619
new CustomEvent('executed', {
619620
detail: {
620621
node: `${group.id}:5`,
622+
display_node: `${group.id}:5`,
621623
output: {
622624
images: [
623625
{

0 commit comments

Comments
 (0)