diff --git a/web/app/components/workflow/nodes/assigner/components/var-list/index.tsx b/web/app/components/workflow/nodes/assigner/components/var-list/index.tsx index d61fc4ca06..ca57b4fd12 100644 --- a/web/app/components/workflow/nodes/assigner/components/var-list/index.tsx +++ b/web/app/components/workflow/nodes/assigner/components/var-list/index.tsx @@ -9,7 +9,8 @@ import { AssignerNodeInputType, WriteMode } from '../../types' import type { AssignerNodeOperation } from '../../types' import ListNoDataPlaceholder from '@/app/components/workflow/nodes/_base/components/list-no-data-placeholder' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' -import type { ValueSelector, Var, VarType } from '@/app/components/workflow/types' +import type { ValueSelector, Var } from '@/app/components/workflow/types' +import { VarType } from '@/app/components/workflow/types' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import ActionButton from '@/app/components/base/action-button' import Input from '@/app/components/base/input' @@ -60,16 +61,20 @@ const VarList: FC = ({ } }, [list, onChange]) - const handleOperationChange = useCallback((index: number) => { + const handleOperationChange = useCallback((index: number, varType: VarType) => { return (item: { value: string | number }) => { const newList = produce(list, (draft) => { draft[index].operation = item.value as WriteMode draft[index].value = '' // Clear value when operation changes if (item.value === WriteMode.set || item.value === WriteMode.increment || item.value === WriteMode.decrement - || item.value === WriteMode.multiply || item.value === WriteMode.divide) + || item.value === WriteMode.multiply || item.value === WriteMode.divide) { + if(varType === VarType.boolean) + draft[index].value = false draft[index].input_type = AssignerNodeInputType.constant - else + } + else { draft[index].input_type = AssignerNodeInputType.variable + } }) onChange(newList) } @@ -146,7 +151,7 @@ const VarList: FC = ({ value={item.operation} placeholder='Operation' disabled={!item.variable_selector || item.variable_selector.length === 0} - onSelect={handleOperationChange(index)} + onSelect={handleOperationChange(index, assignedVarType!)} assignedVarType={assignedVarType} writeModeTypes={writeModeTypes} writeModeTypesArr={writeModeTypesArr} diff --git a/web/app/components/workflow/nodes/assigner/default.ts b/web/app/components/workflow/nodes/assigner/default.ts index 6341305576..b47750efd7 100644 --- a/web/app/components/workflow/nodes/assigner/default.ts +++ b/web/app/components/workflow/nodes/assigner/default.ts @@ -33,7 +33,7 @@ const nodeDefault: NodeDefault = { if (value.operation === WriteMode.set || value.operation === WriteMode.increment || value.operation === WriteMode.decrement || value.operation === WriteMode.multiply || value.operation === WriteMode.divide) { - if (!value.value && typeof value.value !== 'number') + if (!value.value && value.value !== false && typeof value.value !== 'number') errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t('workflow.nodes.assigner.variable') }) } else if (!value.value?.length) { diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx index 2502db05e7..2f2f868acd 100644 --- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx +++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-modal.tsx @@ -148,7 +148,7 @@ const ChatVariableModal = ({ if (v === ChatVarType.String || v === ChatVarType.Number || v === ChatVarType.Object) setEditInJSON(false) if(v === ChatVarType.Boolean) - setValue(true) + setValue(false) if (v === ChatVarType.ArrayBoolean) setValue([false]) setType(v)