Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(workflow): handle else condition branch addition error in if-else node (#10257)

GeorgeCaoJcca2e7876d67
diff --git a/web/app/components/workflow/nodes/if-else/use-config.ts b/web/app/components/workflow/nodes/if-else/use-config.ts
index d1210431a05..41e41f6b8bb 100644
--- a/web/app/components/workflow/nodes/if-else/use-config.ts
+++ b/web/app/components/workflow/nodes/if-else/use-config.ts
@@ -78,24 +78,24 @@ const useConfig = (id: string, payload: IfElseNodeType) => {
})
const handleAddCase = useCallback(() => {
- const newInputs = produce(inputs, () => {
- if (inputs.cases) {
+ const newInputs = produce(inputs, (draft) => {
+ if (draft.cases) {
const case_id = uuid4()
- inputs.cases.push({
+ draft.cases.push({
case_id,
logical_operator: LogicalOperator.and,
conditions: [],
})
- if (inputs._targetBranches) {
- const elseCaseIndex = inputs._targetBranches.findIndex(branch => branch.id === 'false')
+ if (draft._targetBranches) {
+ const elseCaseIndex = draft._targetBranches.findIndex(branch => branch.id === 'false')
if (elseCaseIndex > -1) {
- inputs._targetBranches = branchNameCorrect([
- ...inputs._targetBranches.slice(0, elseCaseIndex),
+ draft._targetBranches = branchNameCorrect([
+ ...draft._targetBranches.slice(0, elseCaseIndex),
{
id: case_id,
name: '',
},
- ...inputs._targetBranches.slice(elseCaseIndex),
+ ...draft._targetBranches.slice(elseCaseIndex),
])
}
}