[backport core/1.30] Fix partial execution inside subgraphs (#6704)

Backport of #6487 to `core/1.30`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6704-backport-core-1-30-Fix-partial-execution-inside-subgraphs-2ab6d73d365081d09667e6c44528ea74)
by [Unito](https://www.unito.io)

Co-authored-by: AustinMroz <austin@comfy.org>
This commit is contained in:
Comfy Org PR Bot
2025-11-15 03:55:53 +09:00
committed by GitHub
parent bf24b6e729
commit fe9f423b9a
4 changed files with 102 additions and 43 deletions

View File

@@ -501,6 +501,15 @@ export function useCoreCommands(): ComfyCommand[] {
// Get execution IDs for all selected output nodes and their descendants
const executionIds =
getExecutionIdsForSelectedNodes(selectedOutputNodes)
if (executionIds.length === 0) {
toastStore.add({
severity: 'error',
summary: t('toastMessages.failedToQueue'),
detail: t('toastMessages.failedExecutionPathResolution'),
life: 3000
})
return
}
await app.queuePrompt(0, batchCount, executionIds)
}
},

View File

@@ -1456,6 +1456,8 @@
"toastMessages": {
"nothingToQueue": "Nothing to queue",
"pleaseSelectOutputNodes": "Please select output nodes",
"failedToQueue": "Failed to queue",
"failedExecutionPathResolution": "Could not resolve path to selected nodes",
"no3dScene": "No 3D scene to apply texture",
"failedToApplyTexture": "Failed to apply texture",
"no3dSceneToExport": "No 3D scene to export",

View File

@@ -520,8 +520,16 @@ export function collectFromNodes<T = LGraphNode, C = void>(
* @returns Array of execution IDs for selected nodes and all nodes within selected subgraphs
*/
export function getExecutionIdsForSelectedNodes(
selectedNodes: LGraphNode[]
selectedNodes: LGraphNode[],
startGraph = selectedNodes[0]?.graph
): NodeExecutionId[] {
if (!startGraph) return []
const rootGraph = startGraph.rootGraph
const parentPath = startGraph.isRootGraph
? ''
: findPartialExecutionPathToGraph(startGraph, rootGraph)
if (parentPath === undefined) return []
return collectFromNodes<NodeExecutionId, string>(selectedNodes, {
collector: (node, parentExecutionId) => {
const nodeId = String(node.id)
@@ -531,7 +539,22 @@ export function getExecutionIdsForSelectedNodes(
const nodeId = String(node.id)
return parentExecutionId ? `${parentExecutionId}:${nodeId}` : nodeId
},
initialContext: '',
initialContext: parentPath,
expandSubgraphs: true
})
}
function findPartialExecutionPathToGraph(
target: LGraph,
root: LGraph
): string | undefined {
for (const node of root.nodes) {
if (!node.isSubgraphNode()) continue
if (node.subgraph === target) return `${node.id}`
const subpath = findPartialExecutionPathToGraph(target, node.subgraph)
if (subpath !== undefined) return node.id + ':' + subpath
}
return undefined
}