From c1bc464e9e19d29e75f643e0148ab4f23fde3635 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 22 May 2025 15:44:37 +0800 Subject: [PATCH] fix: use last run call api timing --- .../nodes/_base/components/workflow-panel/index.tsx | 2 ++ .../_base/components/workflow-panel/last-run/index.tsx | 9 ++++++--- .../components/workflow-panel/last-run/use-last-run.ts | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index 57ae5b145c..44170c23df 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -148,6 +148,7 @@ const BasePanel: FC = ({ getInputVars, toVarInputs, tabType, + isRunAfterSingleRun, setTabType, singleRunParams, nodeInfo, @@ -326,6 +327,7 @@ const BasePanel: FC = ({ nodeId={id} canSingleRun={isSupportSingleRun} runningStatus={runningStatus} + isRunAfterSingleRun={isRunAfterSingleRun} onSingleRunClicked={handleSingleRun} nodeInfo={nodeInfo} singleRunResult={runResult!} diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx index 9f0bf76a04..6ab1644ca1 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/index.tsx @@ -13,6 +13,7 @@ type Props = { appId: string nodeId: string canSingleRun: boolean + isRunAfterSingleRun: boolean nodeInfo?: NodeTracing runningStatus?: NodeRunningStatus onSingleRunClicked: () => void @@ -23,6 +24,7 @@ const LastRun: FC = ({ appId, nodeId, canSingleRun, + isRunAfterSingleRun, nodeInfo, runningStatus: oneStepRunRunningStatus, onSingleRunClicked, @@ -30,10 +32,11 @@ const LastRun: FC = ({ ...otherResultPanelProps }) => { const isRunning = oneStepRunRunningStatus === NodeRunningStatus.Running - const isOneStepRunFailed = oneStepRunRunningStatus === NodeRunningStatus.Failed - const { data: lastRunResult, isFetching, error } = useLastRun(appId, nodeId, !isOneStepRunFailed) + const isOneStepRunSucceed = oneStepRunRunningStatus === NodeRunningStatus.Succeeded + const canRunLastRun = !isRunAfterSingleRun || isOneStepRunSucceed + const { data: lastRunResult, isFetching, error } = useLastRun(appId, nodeId, canRunLastRun) const noLastRun = (error as any)?.status === 404 - const runResult = (isOneStepRunFailed ? singleRunResult : lastRunResult) || {} + const runResult = (canRunLastRun ? lastRunResult : singleRunResult) || {} if (isFetching) { return ( 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 366e59077b..d23eb0f5e9 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 @@ -154,13 +154,16 @@ const useLastRun = ({ } const [tabType, setTabType] = useState(TabType.settings) + const [isRunAfterSingleRun, setIsRunAfterSingleRun] = useState(false) const handleRunWithParams = async (data: Record) => { + setIsRunAfterSingleRun(true) setTabType(TabType.lastRun) callRunApi(data) hideSingleRun() } const handleTabClicked = useCallback((type: TabType) => { + setIsRunAfterSingleRun(false) setTabType(type) }, []) @@ -219,6 +222,7 @@ const useLastRun = ({ // no need to input params if (isAllVarsHasValue(singleRunParams?.getDependentVars?.())) { callRunApi({}) + setIsRunAfterSingleRun(true) setTabType(TabType.lastRun) } else { @@ -229,6 +233,7 @@ const useLastRun = ({ return { ...oneStepRunRes, tabType, + isRunAfterSingleRun, setTabType: handleTabClicked, singleRunParams, nodeInfo,