get node via current graph

This commit is contained in:
bymyself
2025-09-09 19:58:23 -07:00
parent e885a0c93c
commit 017a1dc429

View File

@@ -161,7 +161,6 @@ import { ExecutedWsMessage } from '@/schemas/apiSchema'
import { app } from '@/scripts/app' import { app } from '@/scripts/app'
import { useExecutionStore } from '@/stores/executionStore' import { useExecutionStore } from '@/stores/executionStore'
import { useNodeOutputStore } from '@/stores/imagePreviewStore' import { useNodeOutputStore } from '@/stores/imagePreviewStore'
import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
import { cn } from '@/utils/tailwindUtil' import { cn } from '@/utils/tailwindUtil'
import { useVueElementTracking } from '../composables/useVueNodeResizeTracking' import { useVueElementTracking } from '../composables/useVueNodeResizeTracking'
@@ -404,19 +403,9 @@ const nodeOutputs = useNodeOutputStore()
const nodeImageUrls = ref<string[]>([]) const nodeImageUrls = ref<string[]>([])
const onNodeOutputsUpdate = (newOutputs: ExecutedWsMessage['output']) => { const onNodeOutputsUpdate = (newOutputs: ExecutedWsMessage['output']) => {
// Construct proper locator ID using subgraph ID from VueNodeData // Get the current graph context (subgraph if viewing one, otherwise root graph)
const locatorId = nodeData.subgraphId const currentGraph = app.canvas.graph || app.graph
? `${nodeData.subgraphId}:${nodeData.id}` const node = currentGraph?.getNodeById(Number(nodeData.id))
: nodeData.id
// Use root graph for getNodeByLocatorId since it needs to traverse from root
const rootGraph = app.graph?.rootGraph || app.graph
if (!rootGraph) {
nodeImageUrls.value = []
return
}
const node = getNodeByLocatorId(rootGraph, locatorId)
if (node && newOutputs?.images?.length) { if (node && newOutputs?.images?.length) {
const urls = nodeOutputs.getNodeImageUrls(node) const urls = nodeOutputs.getNodeImageUrls(node)
if (urls) { if (urls) {
@@ -442,4 +431,8 @@ watch(
// Provide nodeImageUrls to child components // Provide nodeImageUrls to child components
provide('nodeImageUrls', nodeImageUrls) provide('nodeImageUrls', nodeImageUrls)
provide(
'nodeId',
computed(() => String(nodeData.id))
)
</script> </script>