From 0cd6e55bde663a8b5d16ea36231f65e0ade8a071 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 7 May 2025 15:03:30 +0800 Subject: [PATCH] chore: loop add node info --- .../workflow-panel/last-run/use-last-run.ts | 2 ++ .../nodes/loop/use-single-run-form-params.ts | 32 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts index 5648db6793..d58ebecc7b 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts @@ -128,6 +128,7 @@ const useLastRun = ({ showSingleRun, runResult, iterationRunResult, + loopRunResult, } = oneStepRunRes const { @@ -144,6 +145,7 @@ const useLastRun = ({ varSelectorsToVarInputs, runResult, iterationRunResult, + loopRunResult, }) const callRunApi = async (data: Record) => { diff --git a/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts b/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts index daed2b03a3..5359dec678 100644 --- a/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts +++ b/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts @@ -1,6 +1,36 @@ -const useSingleRunFormParams = () => { +import type { NodeTracing } from '@/types/workflow' +import { useMemo } from 'react' +import formatTracing from '@/app/components/workflow/run/utils/format-log' +import { useTranslation } from 'react-i18next' + +type Params = { + runResult: NodeTracing + loopRunResult: NodeTracing[] +} + +const useSingleRunFormParams = ({ + runResult, + loopRunResult, +}: Params) => { + const { t } = useTranslation() + const nodeInfo = useMemo(() => { + const formattedNodeInfo = formatTracing(loopRunResult, t)[0] + + if (runResult && formattedNodeInfo) { + return { + ...formattedNodeInfo, + execution_metadata: { + ...runResult.execution_metadata, + ...formattedNodeInfo.execution_metadata, + }, + } + } + + return formattedNodeInfo + }, [runResult, loopRunResult, t]) return { forms: [], + nodeInfo, } }