[bugfix] Fix refresh node definitions for subgraph nodes (#5222)

The refreshComboInNodes function was only iterating over top-level nodes,
missing nodes inside subgraphs. This caused file lists and combo widget
options to not update properly when new models were added, unless users
created completely new nodes.

Changes:
- Replace graph.nodes iteration with forEachNode() for hierarchical traversal
- Import forEachNode utility from graphTraversalUtil
- Change early continue to early return for callback function

Fixes #5196

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Christian Byrne
2025-08-26 19:59:55 -07:00
committed by GitHub
parent 48b1ebf6cc
commit cd444b6e59

View File

@@ -63,6 +63,7 @@ import { ExtensionManager } from '@/types/extensionTypes'
import type { NodeExecutionId } from '@/types/nodeIdentification'
import { ColorAdjustOptions, adjustColor } from '@/utils/colorUtil'
import { graphToPrompt } from '@/utils/executionUtil'
import { forEachNode } from '@/utils/graphTraversalUtil'
import {
getNodeByExecutionId,
triggerCallbackOnAllNodes
@@ -1700,12 +1701,13 @@ export class ComfyApp {
for (const nodeId in defs) {
this.registerNodeDef(nodeId, defs[nodeId])
}
for (const node of this.graph.nodes) {
// Refresh combo widgets in all nodes including those in subgraphs
forEachNode(this.graph, (node) => {
const def = defs[node.type]
// Allow primitive nodes to handle refresh
node.refreshComboInNode?.(defs)
if (!def?.input) continue
if (!def?.input) return
if (node.widgets) {
const nodeInputs = def.input
@@ -1732,7 +1734,7 @@ export class ComfyApp {
}
}
}
}
})
await useExtensionService().invokeExtensionsAsync(
'refreshComboInNodes',