diff --git a/web/app/components/workflow/nodes/_base/components/error-handle/constants.ts b/web/app/components/workflow/nodes/_base/components/error-handle/constants.ts deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/web/app/components/workflow/nodes/_base/hooks/use-output-var-list.ts b/web/app/components/workflow/nodes/_base/hooks/use-output-var-list.ts index c7bce2ef07a9c0..6cf15c32d5f04f 100644 --- a/web/app/components/workflow/nodes/_base/hooks/use-output-var-list.ts +++ b/web/app/components/workflow/nodes/_base/hooks/use-output-var-list.ts @@ -1,12 +1,14 @@ import { useCallback, useState } from 'react' import produce from 'immer' import { useBoolean } from 'ahooks' -import { type OutputVar } from '../../code/types' +import type { CodeNodeType, type OutputVar } from '../../code/types' import type { ValueSelector } from '@/app/components/workflow/types' -import { VarType } from '@/app/components/workflow/types' +import { BlockEnum, VarType } from '@/app/components/workflow/types' import { useWorkflow, } from '@/app/components/workflow/hooks' +import { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types' +import { getDefaultValue } from '@/app/components/workflow/nodes/_base/components/error-handle/utils' type Params = { id: string @@ -29,6 +31,9 @@ function useOutputVarList({ const handleVarsChange = useCallback((newVars: OutputVar, changedIndex?: number, newKey?: string) => { const newInputs = produce(inputs, (draft: any) => { draft[varKey] = newVars + + if ((inputs as CodeNodeType).type === BlockEnum.Code && (inputs as CodeNodeType).error_strategy === ErrorHandleTypeEnum.defaultValue && varKey === 'outputs') + draft.default_value = getDefaultValue(draft as any) }) setInputs(newInputs) @@ -59,6 +64,9 @@ function useOutputVarList({ children: null, }, } + + if ((inputs as CodeNodeType).type === BlockEnum.Code && (inputs as CodeNodeType).error_strategy === ErrorHandleTypeEnum.defaultValue && varKey === 'outputs') + draft.default_value = getDefaultValue(draft as any) }) setInputs(newInputs) onOutputKeyOrdersChange([...outputKeyOrders, newKey]) @@ -84,6 +92,9 @@ function useOutputVarList({ const newInputs = produce(inputs, (draft: any) => { delete draft[varKey][key] + + if ((inputs as CodeNodeType).type === BlockEnum.Code && (inputs as CodeNodeType).error_strategy === ErrorHandleTypeEnum.defaultValue && varKey === 'outputs') + draft.default_value = getDefaultValue(draft as any) }) setInputs(newInputs) onOutputKeyOrdersChange(outputKeyOrders.filter((_, i) => i !== index))