diff --git a/web/app/components/base/chat/chat/answer/workflow-process.tsx b/web/app/components/base/chat/chat/answer/workflow-process.tsx index ced352eba3..1f17798f83 100644 --- a/web/app/components/base/chat/chat/answer/workflow-process.tsx +++ b/web/app/components/base/chat/chat/answer/workflow-process.tsx @@ -31,6 +31,7 @@ const WorkflowProcessItem = ({ grayBg, expand = false, hideInfo = false, + hideProcessDetail = false, }: WorkflowProcessProps) => { const { t } = useTranslation() const [collapse, setCollapse] = useState(!expand) @@ -109,6 +110,8 @@ const WorkflowProcessItem = ({ } diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts index 57e49f92e0..89fc9b3e66 100644 --- a/web/app/components/workflow/hooks/use-workflow-run.ts +++ b/web/app/components/workflow/hooks/use-workflow-run.ts @@ -255,7 +255,7 @@ export const useWorkflowRun = () => { setWorkflowRunningData(produce(workflowRunningData!, (draft) => { const tracing = draft.tracing! const iterations = tracing[tracing.length - 1] - const currIteration = [iterations.details![iterations.details!.length - 1]] + const currIteration = iterations.details![iterations.details!.length - 1] currIteration.push({ ...data, status: NodeRunningStatus.Running, diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index fdfc48bf5a..aa8c96f387 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -74,7 +74,7 @@ const NodePanel: FC = ({ onShowIterationDetail?.(nodeInfo.details || []) } return ( -
+
= ({ onClick={handleOnShowIterationDetail} > -
{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length || nodeInfo.details?.length })}
+
{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_index || nodeInfo.details?.length })}
{justShowIterationNavArrow ? ( @@ -142,7 +142,7 @@ const NodePanel: FC = ({
)} -
+
{nodeInfo.status === 'stopped' && (
{t('workflow.tracing.stopBy', { user: nodeInfo.created_by ? nodeInfo.created_by.name : 'N/A' })}
)} diff --git a/web/app/components/workflow/run/tracing-panel.tsx b/web/app/components/workflow/run/tracing-panel.tsx index 342956081e..d1d4012dd9 100644 --- a/web/app/components/workflow/run/tracing-panel.tsx +++ b/web/app/components/workflow/run/tracing-panel.tsx @@ -21,6 +21,8 @@ type TracingPanelProps = { list: NodeTracing[] onShowIterationDetail?: (detail: NodeTracing[][]) => void className?: string + hideNodeInfo?: boolean + hideNodeProcessDetail?: boolean } type TracingNodeProps = { @@ -30,6 +32,8 @@ type TracingNodeProps = { children: TracingNodeProps[] parallelTitle?: string branchTitle?: string + hideNodeInfo?: boolean + hideNodeProcessDetail?: boolean } function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { @@ -62,8 +66,8 @@ function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { // Count parallel children (for figuring out if we need to use letters) for (const node of nodes) { - const parent_parallel_id = node.execution_metadata?.parent_parallel_id ?? null - const parallel_id = node.execution_metadata?.parallel_id ?? null + const parent_parallel_id = node.parent_parallel_id ?? node.execution_metadata?.parent_parallel_id ?? null + const parallel_id = node.parallel_id ?? node.execution_metadata?.parallel_id ?? null if (parallel_id) { const parentKey = parent_parallel_id || 'root' @@ -75,15 +79,10 @@ function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { } for (const node of nodes) { - let parallel_id = node.execution_metadata?.parallel_id ?? null - const parent_parallel_id = node.execution_metadata?.parent_parallel_id ?? null - let parallel_start_node_id = node.execution_metadata?.parallel_start_node_id ?? null - const parent_parallel_start_node_id = node.execution_metadata?.parent_parallel_start_node_id ?? null - - if (node.node_type === BlockEnum.Iteration) { - parallel_id = node.parallel_id ?? null - parallel_start_node_id = node.parallel_start_node_id ?? null - } + const parallel_id = node.parallel_id ?? node.execution_metadata?.parallel_id ?? null + const parent_parallel_id = node.parent_parallel_id ?? node.execution_metadata?.parent_parallel_id ?? null + const parallel_start_node_id = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null + const parent_parallel_start_node_id = node.parent_parallel_start_node_id ?? node.execution_metadata?.parent_parallel_start_node_id ?? null if (!parallel_id || node.node_type === BlockEnum.End) { rootNodes.push({ @@ -106,7 +105,7 @@ function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { if (parent_parallel_id && parallelStacks[parent_parallel_id]) { const sameBranchIndex = parallelStacks[parent_parallel_id].children.findLastIndex(c => - c.data?.execution_metadata.parallel_start_node_id === parent_parallel_start_node_id, + c.data?.execution_metadata?.parallel_start_node_id === parent_parallel_start_node_id || c.data?.parallel_start_node_id === parent_parallel_start_node_id, ) parallelStacks[parent_parallel_id].children.splice(sameBranchIndex + 1, 0, newParallelGroup) newParallelGroup.parallelTitle = getParallelTitle(parent_parallel_id) @@ -128,7 +127,7 @@ function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { } else { let sameBranchIndex = parallelStacks[parallel_id].children.findLastIndex(c => - c.data?.execution_metadata.parallel_start_node_id === parallel_start_node_id, + c.data?.execution_metadata?.parallel_start_node_id === parallel_start_node_id || c.data?.parallel_start_node_id === parallel_start_node_id, ) if (parallelStacks[parallel_id].children[sameBranchIndex + 1]?.isParallel) sameBranchIndex++ @@ -147,7 +146,13 @@ function buildLogTree(nodes: NodeTracing[]): TracingNodeProps[] { return rootNodes } -const TracingPanel: FC = ({ list, onShowIterationDetail, className }) => { +const TracingPanel: FC = ({ + list, + onShowIterationDetail, + className, + hideNodeInfo = false, + hideNodeProcessDetail = false, +}) => { const treeNodes = buildLogTree(list) const [collapsedNodes, setCollapsedNodes] = useState>(new Set()) const [hoveredParallel, setHoveredParallel] = useState(null) @@ -235,6 +240,8 @@ const TracingPanel: FC = ({ list, onShowIterationDetail, clas nodeInfo={node.data!} onShowIterationDetail={onShowIterationDetail} justShowIterationNavArrow={true} + hideInfo={hideNodeInfo} + hideProcessDetail={hideNodeProcessDetail} />
) diff --git a/web/types/workflow.ts b/web/types/workflow.ts index bb57b0715d..0f826328c0 100644 --- a/web/types/workflow.ts +++ b/web/types/workflow.ts @@ -33,6 +33,7 @@ export type NodeTracing = { } metadata: { iterator_length: number + iterator_index: number } created_at: number created_by: { @@ -46,6 +47,8 @@ export type NodeTracing = { details?: NodeTracing[][] // iteration detail parallel_id?: string parallel_start_node_id?: string + parent_parallel_id?: string + parent_parallel_start_node_id?: string } export type FetchWorkflowDraftResponse = {