mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-04 20:50:06 +00:00
[feat] Update audio widgets to support NodeLocatorIds in subgraphs
- Import useWorkflowStore to access executionIdToCurrentId conversion - Update onNodeOutputsUpdated to convert execution IDs to local node IDs - Only update audio widgets for nodes in the current graph context - Add null checks to prevent errors when nodes are not found This ensures audio outputs from subgraph nodes are properly displayed in their audio widgets when the subgraph is active.
This commit is contained in:
@@ -9,6 +9,7 @@ import type { ResultItemType } from '@/schemas/apiSchema'
|
||||
import type { ComfyNodeDef } from '@/schemas/nodeDefSchema'
|
||||
import type { DOMWidget } from '@/scripts/domWidget'
|
||||
import { useToastStore } from '@/stores/toastStore'
|
||||
import { useWorkflowStore } from '@/stores/workflowStore'
|
||||
|
||||
import { api } from '../../scripts/api'
|
||||
import { app } from '../../scripts/app'
|
||||
@@ -142,13 +143,26 @@ app.registerExtension({
|
||||
}
|
||||
},
|
||||
onNodeOutputsUpdated(nodeOutputs: Record<number, any>) {
|
||||
for (const [nodeId, output] of Object.entries(nodeOutputs)) {
|
||||
const node = app.graph.getNodeById(nodeId)
|
||||
const workflowStore = useWorkflowStore()
|
||||
|
||||
for (const [executionId, output] of Object.entries(nodeOutputs)) {
|
||||
// Convert execution ID to local node ID for current graph context
|
||||
const localNodeId = workflowStore.executionIdToCurrentId(executionId)
|
||||
|
||||
// Skip if node is not in current graph context
|
||||
if (!localNodeId) continue
|
||||
|
||||
const node = app.graph.getNodeById(localNodeId)
|
||||
if (!node) continue
|
||||
|
||||
if ('audio' in output) {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
const audioUIWidget = node.widgets.find(
|
||||
(w) => w.name === 'audioUI'
|
||||
) as unknown as DOMWidget<HTMLAudioElement, string>
|
||||
|
||||
if (!audioUIWidget) continue
|
||||
|
||||
const audio = output.audio[0]
|
||||
audioUIWidget.element.src = api.apiURL(
|
||||
getResourceURL(audio.subfolder, audio.filename, audio.type)
|
||||
|
||||
Reference in New Issue
Block a user