fix: success and set running just set running

pull/21369/head
Joel 11 months ago
parent 34f8c25263
commit 92ebfb065c

@ -3,7 +3,7 @@ import type { ResultPanelProps } from '@/app/components/workflow/run/result-pane
import ResultPanel from '@/app/components/workflow/run/result-panel'
import { NodeRunningStatus } from '@/app/components/workflow/types'
import type { FC } from 'react'
import React from 'react'
import React, { useMemo } from 'react'
import NoData from './no-data'
import { useLastRun } from '@/service/use-workflow'
import { RiLoader2Line } from '@remixicon/react'
@ -31,10 +31,15 @@ const LastRun: FC<Props> = ({
singleRunResult,
...otherResultPanelProps
}) => {
const isRunning = oneStepRunRunningStatus === NodeRunningStatus.Running
const isOneStepRunSucceed = oneStepRunRunningStatus === NodeRunningStatus.Succeeded
const canRunLastRun = !isRunAfterSingleRun || isOneStepRunSucceed
const { data: lastRunResult, isFetching, error } = useLastRun(appId, nodeId, canRunLastRun)
const isRunning = useMemo(() => {
if(!isRunAfterSingleRun)
return isFetching
return [NodeRunningStatus.Running, NodeRunningStatus.NotStart].includes(oneStepRunRunningStatus!)
}, [isFetching, isRunAfterSingleRun, oneStepRunRunningStatus])
const noLastRun = (error as any)?.status === 404
const runResult = (canRunLastRun ? lastRunResult : singleRunResult) || {}

@ -138,6 +138,7 @@ const useLastRun = <T>({
runResult,
iterationRunResult,
loopRunResult,
setNodeRunning,
} = oneStepRunRes
const {
@ -174,10 +175,11 @@ const useLastRun = <T>({
return formattedData
}, [isIterationNode, isLoopNode, singleRunParams?.allVarObject, id])
const callRunApi = (data: Record<string, any>) => {
const callRunApi = (data: Record<string, any>, cb?: () => void) => {
handleSyncWorkflowDraft(true, true, {
onSuccess() {
doCallRunApi(toSubmitData(data))
cb?.()
},
})
}
@ -254,9 +256,11 @@ const useLastRun = <T>({
const handleSingleRun = () => {
// no need to input params
if (isAllVarsHasValue(singleRunParams?.getDependentVars?.())) {
callRunApi({})
callRunApi({}, async () => {
setIsRunAfterSingleRun(true)
setNodeRunning()
setTabType(TabType.lastRun)
})
}
else {
showSingleRun()

@ -173,7 +173,6 @@ const useOneStepRun = <T>({
invalidateConversationVarValues,
} = useInspectVarsCrud()
const runningStatus = data._singleRunningStatus || NodeRunningStatus.NotStart
const isPaused = !data._isSingleRun
const setRunResult = useCallback(async (data: NodeRunResult | null) => {
// The backend don't support pause the single run, so the frontend handle the pause state.
@ -200,6 +199,15 @@ const useOneStepRun = <T>({
}, [isPaused, isRunAfterSingleRun, runningStatus, appId, id, store, appendNodeInspectVars, invalidLastRun, isStartNode, invalidateSysVarValues, invalidateConversationVarValues])
const { handleNodeDataUpdate }: { handleNodeDataUpdate: (data: any) => void } = useNodeDataUpdate()
const setNodeRunning = () => {
handleNodeDataUpdate({
id,
data: {
...data,
_singleRunningStatus: NodeRunningStatus.Running,
},
})
}
const [canShowSingleRun, setCanShowSingleRun] = useState(false)
const isShowSingleRun = data._isSingleRun && canShowSingleRun
const [iterationRunResult, setIterationRunResult] = useState<NodeTracing[]>([])
@ -250,6 +258,7 @@ const useOneStepRun = <T>({
data: {
...data,
_isSingleRun: true,
_singleRunningStatus: NodeRunningStatus.Running,
},
})
}
@ -616,6 +625,7 @@ const useOneStepRun = <T>({
runResult,
iterationRunResult,
loopRunResult,
setNodeRunning,
}
}

Loading…
Cancel
Save