From d876fddab09278e8631bb014f7e348f21df114c4 Mon Sep 17 00:00:00 2001 From: zhsama Date: Tue, 10 Feb 2026 20:00:11 +0800 Subject: [PATCH] Revert "feat(workflow): refine variable validation and scoping for workflow nodes, remove redundant End block checks" This reverts commit 32fcbcdc626334718e97889affd4e4c70621f332. --- .../workflow-variable-block/component.tsx | 19 +++---------------- .../workflow/hooks/use-available-blocks.ts | 4 ++-- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx index 6401ba0c54..e2040af375 100644 --- a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx +++ b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx @@ -70,27 +70,14 @@ const WorkflowVariableBlockComponent = ({ )() const [localWorkflowNodesMap, setLocalWorkflowNodesMap] = useState(workflowNodesMap) const [localNodeOutputVars, setLocalNodeOutputVars] = useState(nodeOutputVars || []) - const scopedNodeOutputVars = useMemo(() => { - if (!localNodeOutputVars.length) - return [] - - const candidateNodeIds = [variables[0], variables[1]].filter(Boolean) - if (!candidateNodeIds.length) - return localNodeOutputVars - - return localNodeOutputVars.filter(item => candidateNodeIds.includes(item.nodeId)) - }, [localNodeOutputVars, variables]) const node = localWorkflowNodesMap![variables[isRagVar ? 1 : 0]] const isContextVariable = (node?.type === BlockEnum.Agent || node?.type === BlockEnum.LLM) && variables[variablesLength - 1] === 'context' const isException = isExceptionVariable(varName, node?.type) const variableValid = useMemo(() => { - if (localNodeOutputVars.length) { - if (!scopedNodeOutputVars.length) - return false - return isValueSelectorInNodeOutputVars(variables, scopedNodeOutputVars) - } + if (localNodeOutputVars.length) + return isValueSelectorInNodeOutputVars(variables, localNodeOutputVars) let variableValid = true const isEnv = isENV(variables) @@ -115,7 +102,7 @@ const WorkflowVariableBlockComponent = ({ variableValid = !!node } return variableValid - }, [variables, node, environmentVariables, conversationVariables, isRagVar, ragVariables, localNodeOutputVars, scopedNodeOutputVars]) + }, [variables, node, environmentVariables, conversationVariables, isRagVar, ragVariables, localNodeOutputVars]) const reactflow = useReactFlow() const store = useStoreApi() diff --git a/web/app/components/workflow/hooks/use-available-blocks.ts b/web/app/components/workflow/hooks/use-available-blocks.ts index 888e126474..3d92142b10 100644 --- a/web/app/components/workflow/hooks/use-available-blocks.ts +++ b/web/app/components/workflow/hooks/use-available-blocks.ts @@ -30,7 +30,7 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, inContainer?: boolean) return availableNodesType }, [availableNodesType, nodeType]) const availableNextBlocks = useMemo(() => { - if (!nodeType || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase) + if (!nodeType || nodeType === BlockEnum.End || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase) return [] return availableNodesType @@ -42,7 +42,7 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, inContainer?: boolean) availablePrevBlocks = [] let availableNextBlocks = availableNodesType - if (!nodeType || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase) + if (!nodeType || nodeType === BlockEnum.End || nodeType === BlockEnum.LoopEnd || nodeType === BlockEnum.KnowledgeBase) availableNextBlocks = [] return {