From 5cb018e15d7beb3e5e4d6648bd939c320ad0b79a Mon Sep 17 00:00:00 2001 From: Yi Date: Wed, 4 Sep 2024 14:59:30 +0800 Subject: [PATCH] update the method to check if a node is in iteration --- .../components/workflow/hooks/use-workflow-run.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts index 89fc9b3e66..b7eb13d72b 100644 --- a/web/app/components/workflow/hooks/use-workflow-run.ts +++ b/web/app/components/workflow/hooks/use-workflow-run.ts @@ -141,8 +141,6 @@ export const useWorkflowRun = () => { tracing: [], resultText: '', }) - - let isInIteration = false let iterationLength = 0 let ttsUrl = '' @@ -251,7 +249,9 @@ export const useWorkflowRun = () => { setEdges, transform, } = store.getState() - if (isInIteration) { + const nodes = getNodes() + const nodeParentId = nodes.find(node => node.id === data.node_id)!.parentId + if (nodeParentId) { setWorkflowRunningData(produce(workflowRunningData!, (draft) => { const tracing = draft.tracing! const iterations = tracing[tracing.length - 1] @@ -263,7 +263,6 @@ export const useWorkflowRun = () => { })) } else { - const nodes = getNodes() setWorkflowRunningData(produce(workflowRunningData!, (draft) => { draft.tracing!.push({ ...data, @@ -312,8 +311,9 @@ export const useWorkflowRun = () => { getNodes, setNodes, } = store.getState() - - if (isInIteration) { + const nodes = getNodes() + const nodeParentId = nodes.find(node => node.id === data.node_id)!.parentId + if (nodeParentId) { setWorkflowRunningData(produce(workflowRunningData!, (draft) => { const tracing = draft.tracing! const iterations = tracing[tracing.length - 1] // the iteration node @@ -344,7 +344,6 @@ export const useWorkflowRun = () => { })) } else { - const nodes = getNodes() setWorkflowRunningData(produce(workflowRunningData!, (draft) => { const currentIndex = draft.tracing!.findIndex((trace) => { if (!trace.execution_metadata?.parallel_id) @@ -392,7 +391,6 @@ export const useWorkflowRun = () => { details: [], } as any) })) - isInIteration = true iterationLength = data.metadata.iterator_length const { @@ -477,7 +475,6 @@ export const useWorkflowRun = () => { status: NodeRunningStatus.Succeeded, } as any })) - isInIteration = false const newNodes = produce(nodes, (draft) => { const currentNode = draft.find(node => node.id === data.node_id)!