Skip to content

Commit 607a22a

Browse files
authored
fix: tool constant params change cause page crashed (#11682)
1 parent 4b402c4 commit 607a22a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

web/app/components/workflow/nodes/tool/components/input-var-list.tsx

+4-12
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,12 @@ const InputVarList: FC<Props> = ({
6161
const newValue = produce(value, (draft: ToolVarInputs) => {
6262
const target = draft[variable]
6363
if (target) {
64-
if (!isSupportConstantValue || varKindType === VarKindType.variable) {
65-
if (isSupportConstantValue)
66-
target.type = VarKindType.variable
67-
68-
target.value = varValue as ValueSelector
69-
}
70-
else {
71-
target.type = VarKindType.constant
72-
target.value = varValue as string
73-
}
64+
target.type = varKindType
65+
target.value = varValue
7466
}
7567
else {
7668
draft[variable] = {
77-
type: VarKindType.variable,
69+
type: varKindType,
7870
value: varValue,
7971
}
8072
}
@@ -173,7 +165,7 @@ const InputVarList: FC<Props> = ({
173165
value={varInput?.type === VarKindType.constant ? (varInput?.value || '') : (varInput?.value || [])}
174166
onChange={handleNotMixedTypeChange(variable)}
175167
onOpen={handleOpen(index)}
176-
defaultVarKindType={isNumber ? VarKindType.constant : VarKindType.variable}
168+
defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
177169
isSupportConstantValue={isSupportConstantValue}
178170
filterVar={isNumber ? filterVar : undefined}
179171
availableVars={isSelect ? availableVars : undefined}

web/app/components/workflow/nodes/tool/use-config.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
132132
draft.tool_parameters = {}
133133
})
134134
setInputs(inputsWithDefaultValue)
135-
// eslint-disable-next-line react-hooks/exhaustive-deps
135+
// eslint-disable-next-line react-hooks/exhaustive-deps
136136
}, [currTool])
137137

138138
// setting when call
@@ -214,8 +214,13 @@ const useConfig = (id: string, payload: ToolNodeType) => {
214214
.map(k => inputs.tool_parameters[k])
215215

216216
const varInputs = getInputVars(hadVarParams.map((p) => {
217-
if (p.type === VarType.variable)
217+
if (p.type === VarType.variable) {
218+
// handle the old wrong value not crash the page
219+
if (!(p.value as any).join)
220+
return `{{#${p.value}#}}`
221+
218222
return `{{#${(p.value as ValueSelector).join('.')}#}}`
223+
}
219224

220225
return p.value as string
221226
}))

0 commit comments

Comments
 (0)