|
|
|
|
@ -142,7 +142,7 @@ const useOneStepRun = <T>({
|
|
|
|
|
const { handleNodeDataUpdate }: { handleNodeDataUpdate: (data: any) => void } = useNodeDataUpdate()
|
|
|
|
|
const [canShowSingleRun, setCanShowSingleRun] = useState(false)
|
|
|
|
|
const isShowSingleRun = data._isSingleRun && canShowSingleRun
|
|
|
|
|
const [iterationRunResult, setIterationRunResult] = useState<NodeTracing[][]>([])
|
|
|
|
|
const [iterationRunResult, setIterationRunResult] = useState<NodeTracing[]>([])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!checkValid) {
|
|
|
|
|
@ -173,7 +173,7 @@ const useOneStepRun = <T>({
|
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
workflowStore.getState().setShowSingleRunPanel(!!isShowSingleRun)
|
|
|
|
|
}, [isShowSingleRun])
|
|
|
|
|
}, [isShowSingleRun, workflowStore])
|
|
|
|
|
|
|
|
|
|
const hideSingleRun = () => {
|
|
|
|
|
handleNodeDataUpdate({
|
|
|
|
|
@ -211,7 +211,7 @@ const useOneStepRun = <T>({
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setIterationRunResult([])
|
|
|
|
|
let _iterationResult: NodeTracing[][] = []
|
|
|
|
|
let _iterationResult: NodeTracing[] = []
|
|
|
|
|
let _runResult: any = null
|
|
|
|
|
ssePost(
|
|
|
|
|
getIterationSingleNodeRunUrl(isChatMode, appId!, id),
|
|
|
|
|
@ -231,27 +231,43 @@ const useOneStepRun = <T>({
|
|
|
|
|
_runResult.created_by = iterationData.created_by.name
|
|
|
|
|
setRunResult(_runResult)
|
|
|
|
|
},
|
|
|
|
|
onIterationNext: () => {
|
|
|
|
|
// iteration next trigger time is triggered one more time than iterationTimes
|
|
|
|
|
if (_iterationResult.length >= iterationTimes!)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
onIterationStart: (params) => {
|
|
|
|
|
const newIterationRunResult = produce(_iterationResult, (draft) => {
|
|
|
|
|
draft.push([])
|
|
|
|
|
draft.push({
|
|
|
|
|
...params.data,
|
|
|
|
|
status: NodeRunningStatus.Running,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
_iterationResult = newIterationRunResult
|
|
|
|
|
setIterationRunResult(newIterationRunResult)
|
|
|
|
|
},
|
|
|
|
|
onIterationNext: () => {
|
|
|
|
|
// iteration next trigger time is triggered one more time than iterationTimes
|
|
|
|
|
if (_iterationResult.length >= iterationTimes!)
|
|
|
|
|
return _iterationResult.length >= iterationTimes!
|
|
|
|
|
},
|
|
|
|
|
onIterationFinish: (params) => {
|
|
|
|
|
_runResult = params.data
|
|
|
|
|
setRunResult(_runResult)
|
|
|
|
|
const iterationRunResult = _iterationResult
|
|
|
|
|
const currentIndex = iterationRunResult.findIndex(trace => trace.id === params.data.id)
|
|
|
|
|
const newIterationRunResult = produce(iterationRunResult, (draft) => {
|
|
|
|
|
if (currentIndex > -1) {
|
|
|
|
|
draft[currentIndex] = {
|
|
|
|
|
...draft[currentIndex],
|
|
|
|
|
...data,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
_iterationResult = newIterationRunResult
|
|
|
|
|
setIterationRunResult(newIterationRunResult)
|
|
|
|
|
},
|
|
|
|
|
onNodeStarted: (params) => {
|
|
|
|
|
const newIterationRunResult = produce(_iterationResult, (draft) => {
|
|
|
|
|
draft[draft.length - 1].push({
|
|
|
|
|
draft.push({
|
|
|
|
|
...params.data,
|
|
|
|
|
status: NodeRunningStatus.Running,
|
|
|
|
|
} as NodeTracing)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
_iterationResult = newIterationRunResult
|
|
|
|
|
setIterationRunResult(newIterationRunResult)
|
|
|
|
|
@ -260,18 +276,25 @@ const useOneStepRun = <T>({
|
|
|
|
|
const iterationRunResult = _iterationResult
|
|
|
|
|
|
|
|
|
|
const { data } = params
|
|
|
|
|
const currentIndex = iterationRunResult[iterationRunResult.length - 1].findIndex(trace => trace.node_id === data.node_id)
|
|
|
|
|
const currentIndex = iterationRunResult.findIndex(trace => trace.id === data.id)
|
|
|
|
|
const newIterationRunResult = produce(iterationRunResult, (draft) => {
|
|
|
|
|
if (currentIndex > -1) {
|
|
|
|
|
draft[draft.length - 1][currentIndex] = {
|
|
|
|
|
draft[currentIndex] = {
|
|
|
|
|
...draft[currentIndex],
|
|
|
|
|
...data,
|
|
|
|
|
status: NodeRunningStatus.Succeeded,
|
|
|
|
|
} as NodeTracing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
_iterationResult = newIterationRunResult
|
|
|
|
|
setIterationRunResult(newIterationRunResult)
|
|
|
|
|
},
|
|
|
|
|
onNodeRetry: (params) => {
|
|
|
|
|
const newIterationRunResult = produce(_iterationResult, (draft) => {
|
|
|
|
|
draft.push(params.data)
|
|
|
|
|
})
|
|
|
|
|
_iterationResult = newIterationRunResult
|
|
|
|
|
setIterationRunResult(newIterationRunResult)
|
|
|
|
|
},
|
|
|
|
|
onError: () => {
|
|
|
|
|
handleNodeDataUpdate({
|
|
|
|
|
id,
|
|
|
|
|
|