11import { useCallback , useEffect , useMemo , useState } from "react" ;
22import { useDebugOverlayStore } from "../../../stores/debugOverlayStore" ;
3- import type { NodeType } from "../../../stores/flow" ;
3+ import { useFileStore } from "../../../stores/fileStore" ;
4+ import type { EdgeType , NodeType } from "../../../stores/flow" ;
45import { useLocalFileStore } from "../../../stores/localFileStore" ;
56import { useDebugRunProfileStore } from "../../../stores/debugRunProfileStore" ;
67import { applyDebugNodeTarget } from "../nodeTargetActions" ;
@@ -24,6 +25,7 @@ import {
2425} from "../types" ;
2526
2627interface UseDebugNodeExecutionControllerInput {
28+ flowEdges : EdgeType [ ] ;
2729 flowNodes : NodeType [ ] ;
2830 liveSummary : DebugTraceSummary ;
2931 nodeExecutionAttributionMode : DebugExecutionAttributionMode ;
@@ -36,6 +38,7 @@ interface UseDebugNodeExecutionControllerInput {
3638}
3739
3840export function useDebugNodeExecutionController ( {
41+ flowEdges,
3942 flowNodes,
4043 liveSummary,
4144 nodeExecutionAttributionMode,
@@ -58,11 +61,51 @@ export function useDebugNodeExecutionController({
5861 const resourcePaths = useDebugRunProfileStore (
5962 ( state ) => state . profile . resourcePaths ,
6063 ) ;
64+ const fileSnapshotKey = useFileStore ( ( state ) =>
65+ JSON . stringify ( {
66+ currentFile : {
67+ fileName : state . currentFile . fileName ,
68+ filePath : state . currentFile . config . filePath ,
69+ prefix : state . currentFile . config . prefix ,
70+ relativePath : state . currentFile . config . relativePath ,
71+ } ,
72+ files : state . files . map ( ( file ) => ( {
73+ fileName : file . fileName ,
74+ filePath : file . config . filePath ,
75+ prefix : file . config . prefix ,
76+ relativePath : file . config . relativePath ,
77+ nodeCount : file . nodes . length ,
78+ edgeCount : file . edges . length ,
79+ } ) ) ,
80+ } ) ,
81+ ) ;
6182 const flowNodeIds = useMemo (
6283 ( ) => new Set ( flowNodes . map ( ( node ) => node . id ) ) ,
6384 [ flowNodes ] ,
6485 ) ;
86+ const flowSnapshotKey = useMemo (
87+ ( ) =>
88+ JSON . stringify ( {
89+ edges : flowEdges . map ( ( edge ) => ( {
90+ id : edge . id ,
91+ source : edge . source ,
92+ sourceHandle : edge . sourceHandle ,
93+ target : edge . target ,
94+ targetHandle : edge . targetHandle ,
95+ jumpBack : edge . attributes ?. jump_back ,
96+ anchor : edge . attributes ?. anchor ,
97+ } ) ) ,
98+ nodes : flowNodes . map ( ( node ) => ( {
99+ id : node . id ,
100+ label : node . data . label ,
101+ type : node . type ,
102+ } ) ) ,
103+ } ) ,
104+ [ flowEdges , flowNodes ] ,
105+ ) ;
65106 const debugResolver = useMemo ( ( ) => {
107+ void fileSnapshotKey ;
108+ void flowSnapshotKey ;
66109 const bundle = buildDebugSnapshotBundle ( localFiles , resourcePaths ) ;
67110 return {
68111 edges : bundle . resolverSnapshot . edges ,
@@ -71,7 +114,7 @@ export function useDebugNodeExecutionController({
71114 ) ,
72115 allNodes : bundle . resolverSnapshot . nodes ,
73116 } ;
74- } , [ flowNodeIds , localFiles , resourcePaths ] ) ;
117+ } , [ fileSnapshotKey , flowNodeIds , flowSnapshotKey , localFiles , resourcePaths ] ) ;
75118 const resolverEdges = debugResolver . edges ;
76119 const resolverEdgeIndex = useMemo (
77120 ( ) => createDebugResolverEdgeIndex ( resolverEdges ) ,
0 commit comments