diff --git a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts index 769804a20b..591368219e 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts @@ -94,6 +94,8 @@ const varTypeToInputVarType = (type: VarType, { return InputVarType.paragraph if (type === VarType.number) return InputVarType.number + if (type === VarType.boolean) + return InputVarType.boolean if ([VarType.object, VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject].includes(type)) return InputVarType.json if (type === VarType.file) @@ -185,11 +187,11 @@ const useOneStepRun = ({ const isPaused = isPausedRef.current // The backend don't support pause the single run, so the frontend handle the pause state. - if(isPaused) + if (isPaused) return const canRunLastRun = !isRunAfterSingleRun || runningStatus === NodeRunningStatus.Succeeded - if(!canRunLastRun) { + if (!canRunLastRun) { doSetRunResult(data) return } @@ -199,9 +201,9 @@ const useOneStepRun = ({ const { getNodes } = store.getState() const nodes = getNodes() appendNodeInspectVars(id, vars, nodes) - if(data?.status === NodeRunningStatus.Succeeded) { + if (data?.status === NodeRunningStatus.Succeeded) { invalidLastRun() - if(isStartNode) + if (isStartNode) invalidateSysVarValues() invalidateConversationVarValues() // loop, iteration, variable assigner node can update the conversation variables, but to simple the logic(some nodes may also can update in the future), all nodes refresh. } @@ -218,21 +220,21 @@ const useOneStepRun = ({ }) } const checkValidWrap = () => { - if(!checkValid) + if (!checkValid) return { isValid: true, errorMessage: '' } const res = checkValid(data, t, moreDataForCheckValid) - if(!res.isValid) { - handleNodeDataUpdate({ - id, - data: { - ...data, - _isSingleRun: false, - }, - }) - Toast.notify({ - type: 'error', - message: res.errorMessage, - }) + if (!res.isValid) { + handleNodeDataUpdate({ + id, + data: { + ...data, + _isSingleRun: false, + }, + }) + Toast.notify({ + type: 'error', + message: res.errorMessage, + }) } return res } @@ -251,7 +253,6 @@ const useOneStepRun = ({ const { isValid } = checkValidWrap() setCanShowSingleRun(isValid) } - // eslint-disable-next-line react-hooks/exhaustive-deps }, [data._isSingleRun]) useEffect(() => { @@ -293,9 +294,9 @@ const useOneStepRun = ({ if (!isIteration && !isLoop) { const isStartNode = data.type === BlockEnum.Start const postData: Record = {} - if(isStartNode) { + if (isStartNode) { const { '#sys.query#': query, '#sys.files#': files, ...inputs } = submitData - if(isChatMode) + if (isChatMode) postData.conversation_id = '' postData.inputs = inputs @@ -317,7 +318,7 @@ const useOneStepRun = ({ { onWorkflowStarted: noop, onWorkflowFinished: (params) => { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -396,7 +397,7 @@ const useOneStepRun = ({ setIterationRunResult(newIterationRunResult) }, onError: () => { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -420,7 +421,7 @@ const useOneStepRun = ({ { onWorkflowStarted: noop, onWorkflowFinished: (params) => { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -500,7 +501,7 @@ const useOneStepRun = ({ setLoopRunResult(newLoopRunResult) }, onError: () => { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -522,7 +523,7 @@ const useOneStepRun = ({ hasError = true invalidLastRun() if (!isIteration && !isLoop) { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -544,11 +545,11 @@ const useOneStepRun = ({ }) } } - if(isPausedRef.current) + if (isPausedRef.current) return if (!isIteration && !isLoop && !hasError) { - if(isPausedRef.current) + if (isPausedRef.current) return handleNodeDataUpdate({ id, @@ -587,7 +588,7 @@ const useOneStepRun = ({ } } return { - label: item.label || item.variable, + label: (typeof item.label === 'object' ? item.label.variable : item.label) || item.variable, variable: item.variable, type: varTypeToInputVarType(originalVar.type, { isSelect: !!originalVar.isSelect, 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 394ab9b16f..6a1b6b20f0 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 @@ -107,7 +107,7 @@ const useSingleRunFormParams = ({ }, [runResult, loopRunResult, t]) const setInputVarValues = useCallback((newPayload: Record) => { - setRunInputData(newPayload) + setRunInputData(newPayload) }, [setRunInputData]) const inputVarValues = (() => { @@ -149,16 +149,15 @@ const useSingleRunFormParams = ({ }) payload.loop_variables?.forEach((loopVariable) => { - if(loopVariable.value_type === ValueType.variable) + if (loopVariable.value_type === ValueType.variable) allInputs.push(loopVariable.value) }) const inputVarsFromValue: InputVar[] = [] const varInputs = [...varSelectorsToVarInputs(allInputs), ...inputVarsFromValue] - const existVarsKey: Record = {} const uniqueVarInputs: InputVar[] = [] varInputs.forEach((input) => { - if(!input) + if (!input) return if (!existVarsKey[input.variable]) { existVarsKey[input.variable] = true @@ -191,7 +190,7 @@ const useSingleRunFormParams = ({ if (condition.variable_selector) vars.push(condition.variable_selector) - if(condition.sub_variable_condition && condition.sub_variable_condition.conditions?.length) + if (condition.sub_variable_condition && condition.sub_variable_condition.conditions?.length) vars.push(...getVarFromCaseItem(condition.sub_variable_condition)) return vars } @@ -203,7 +202,7 @@ const useSingleRunFormParams = ({ vars.push(...conditionVars) }) payload.loop_variables?.forEach((loopVariable) => { - if(loopVariable.value_type === ValueType.variable) + if (loopVariable.value_type === ValueType.variable) vars.push(loopVariable.value) }) const hasFilterLoopVars = vars.filter(item => item[0] !== id)