From 8a90a9bd5dc65526bdd5f2af99d797508bf5a497 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 27 Dec 2024 18:28:41 +0800 Subject: [PATCH] fix: in steam mode trigger the error in change list --- .../workflow/run/utils/format-log/index.ts | 3 ++- .../run/utils/format-log/parallel/index.ts | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/web/app/components/workflow/run/utils/format-log/index.ts b/web/app/components/workflow/run/utils/format-log/index.ts index 6beae5eb2b..4e8f6c33c2 100644 --- a/web/app/components/workflow/run/utils/format-log/index.ts +++ b/web/app/components/workflow/run/utils/format-log/index.ts @@ -3,9 +3,10 @@ import formatIterationNode from './iteration' import formatParallelNode from './parallel' import formatRetryNode from './retry' import formatAgentNode from './agent' +import { cloneDeep } from 'lodash-es' const formatToTracingNodeList = (list: NodeTracing[], t: any) => { - const allItems = [...list].sort((a, b) => a.index - b.index) + const allItems = cloneDeep([...list]).sort((a, b) => a.index - b.index) /* * First handle not change list structure node * Because Handle struct node will put the node in different diff --git a/web/app/components/workflow/run/utils/format-log/parallel/index.ts b/web/app/components/workflow/run/utils/format-log/parallel/index.ts index 9501eec7ec..245337dc0c 100644 --- a/web/app/components/workflow/run/utils/format-log/parallel/index.ts +++ b/web/app/components/workflow/run/utils/format-log/parallel/index.ts @@ -69,8 +69,10 @@ function addTitle({ } // list => group by parallel_id(parallel tree). -const format = (list: NodeTracing[], t: any): NodeTracing[] => { - // console.log(list) +const format = (list: NodeTracing[], t: any, isPrint?: boolean): NodeTracing[] => { + if (isPrint) + console.log(list) + const result: NodeTracing[] = [...list] const parallelFirstNodeMap: Record = {} // list to tree by parent_parallel_start_node_id and branch by parallel_start_node_id. Each parallel may has more than one branch. @@ -119,6 +121,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => { // append to parallel start node and after the same branch const parallelStartNode = result.find(item => item.node_id === parallelFirstNodeMap[parallel_id]) + if (parallelStartNode && parallelStartNode.parallelDetail && parallelStartNode!.parallelDetail!.children) { const sameBranchNodesLastIndex = parallelStartNode.parallelDetail.children.findLastIndex((node) => { const currStartNodeId = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null @@ -153,12 +156,14 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => { }) // print node structure for debug - // filteredInParallelSubNodes.forEach((node) => { - // const now = Date.now() - // console.log(`----- p: ${now} start -----`) - // printNodeStructure(node, 0) - // console.log(`----- p: ${now} end -----`) - // }) + if (isPrint) { + filteredInParallelSubNodes.forEach((node) => { + const now = Date.now() + console.log(`----- p: ${now} start -----`) + printNodeStructure(node, 0) + console.log(`----- p: ${now} end -----`) + }) + } addTitle({ list: filteredInParallelSubNodes,