From b541792465c7b396a653028fd5ad66fe5a0a3891 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 12 Mar 2025 10:10:51 +0800 Subject: [PATCH] fix: workflow loop node break conditions (#15549) --- web/app/components/workflow/nodes/loop/default.ts | 3 --- web/app/components/workflow/nodes/loop/panel.tsx | 1 + web/app/components/workflow/nodes/loop/use-config.ts | 4 +++- web/i18n/en-US/workflow.ts | 1 + web/i18n/zh-Hans/workflow.ts | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/nodes/loop/default.ts b/web/app/components/workflow/nodes/loop/default.ts index ded8afc517..67b1f6edde 100644 --- a/web/app/components/workflow/nodes/loop/default.ts +++ b/web/app/components/workflow/nodes/loop/default.ts @@ -28,9 +28,6 @@ const nodeDefault: NodeDefault = { checkValid(payload: LoopNodeType, t: any) { let errorMessages = '' - if (!errorMessages && (!payload.break_conditions || payload.break_conditions.length === 0)) - errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t('workflow.nodes.loop.breakCondition') }) - payload.break_conditions!.forEach((condition) => { if (!errorMessages && (!condition.variable_selector || condition.variable_selector.length === 0)) errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.variable`) }) diff --git a/web/app/components/workflow/nodes/loop/panel.tsx b/web/app/components/workflow/nodes/loop/panel.tsx index e416e8d77e..e361749f6d 100644 --- a/web/app/components/workflow/nodes/loop/panel.tsx +++ b/web/app/components/workflow/nodes/loop/panel.tsx @@ -55,6 +55,7 @@ const Panel: FC> = ({
{t(`${i18nPrefix}.breakCondition`)}
} + tooltip={t(`${i18nPrefix}.breakConditionTip`)} > { const { nodesReadOnly: readOnly } = useNodesReadOnly() const { isNodeInLoop } = useIsNodeInLoop(id) const isChatMode = useIsChatMode() + const conversationVariables = useStore(s => s.conversationVariables) const { inputs, setInputs } = useNodeCrud(id, payload) @@ -35,7 +37,7 @@ const useConfig = (id: string, payload: LoopNodeType) => { const beforeNodes = getBeforeNodesInSameBranch(id) const loopChildrenNodes = getLoopNodeChildren(id) const canChooseVarNodes = [...beforeNodes, ...loopChildrenNodes] - const childrenNodeVars = toNodeOutputVars(loopChildrenNodes, isChatMode) + const childrenNodeVars = toNodeOutputVars(loopChildrenNodes, isChatMode, undefined, [], conversationVariables) // single run const loopInputKey = `${id}.input_selector` diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 704364b20a..a6dd4deb73 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -673,6 +673,7 @@ const translation = { loop_other: '{{count}} Loops', currentLoop: 'Current Loop', breakCondition: 'Loop Termination Condition', + breakConditionTip: 'Only variables within loops with termination conditions and conversation variables can be referenced.', loopMaxCount: 'Maximum Loop Count', loopMaxCountError: 'Please enter a valid maximum loop count, ranging from 1 to {{maxCount}}', errorResponseMethod: 'Error Response Method', diff --git a/web/i18n/zh-Hans/workflow.ts b/web/i18n/zh-Hans/workflow.ts index 7cf6853f87..523a93b46d 100644 --- a/web/i18n/zh-Hans/workflow.ts +++ b/web/i18n/zh-Hans/workflow.ts @@ -674,6 +674,7 @@ const translation = { loop_other: '{{count}} 个循环', currentLoop: '当前循环', breakCondition: '循环终止条件', + breakConditionTip: '支持引用终止条件循环内的变量和会话变量。', loopMaxCount: '最大循环次数', loopMaxCountError: '请输入正确的 最大循环次数,范围为 1 到 {{maxCount}}', errorResponseMethod: '错误响应方法',