From 1103ff957fca7cdf6f502476b90a08fdcab1891d Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 21 Apr 2026 19:48:04 +0800 Subject: [PATCH] feat: allow workflow step level adjustment --- .../agent-workflow-settings-client.tsx | 74 +++++++++++++++++-- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/app/(admin)/settings/agent-workflow/agent-workflow-settings-client.tsx b/app/(admin)/settings/agent-workflow/agent-workflow-settings-client.tsx index dd90ea7a3..42609a805 100644 --- a/app/(admin)/settings/agent-workflow/agent-workflow-settings-client.tsx +++ b/app/(admin)/settings/agent-workflow/agent-workflow-settings-client.tsx @@ -2812,6 +2812,24 @@ export function AgentWorkflowSettingsClient({ }); }; + const handlePromoteWorkflowStep = (stepKey: string, parentStepKey: string | null) => { + if (!parentStepKey) { + toast.error("一级模块不能继续升一级"); + return; + } + + handleMoveWorkflowStep(stepKey, parentStepKey, "after"); + }; + + const handleIndentWorkflowStep = (stepKey: string, previousSiblingStepKey: string | null) => { + if (!previousSiblingStepKey) { + toast.error("当前模块前面没有可作为父级的同级模块"); + return; + } + + handleMoveWorkflowStep(stepKey, previousSiblingStepKey, "inside"); + }; + const handleWorkflowStepDragStart = ( event: DragEvent, stepKey: string @@ -4068,7 +4086,9 @@ export function AgentWorkflowSettingsClient({ step: AgentWorkflowStepUiConfig, depth: number, indexPath: number[], - siblingCount = 0 + siblingCount = 0, + parentStepKey: string | null = null, + previousSiblingStepKey: string | null = null ) => { const stepLabel = indexPath.join("."); const levelLabel = getWorkflowLevelLabel(depth, "模块"); @@ -4080,6 +4100,10 @@ export function AgentWorkflowSettingsClient({ const isTopLevelStep = depth === 1; const canMoveTopLevelStepUp = isTopLevelStep && indexPath[0] > 1; const canMoveTopLevelStepDown = isTopLevelStep && indexPath[0] < siblingCount; + const subtreeDepth = getWorkflowStepSubtreeDepth(step); + const canPromoteStep = Boolean(parentStepKey); + const canIndentStep = + Boolean(previousSiblingStepKey) && depth + subtreeDepth <= AGENT_WORKFLOW_MAX_TREE_DEPTH; const canAddChildStep = depth < AGENT_WORKFLOW_MAX_TREE_DEPTH; const canPasteAsChild = Boolean(copiedWorkflowStep) && @@ -4185,6 +4209,30 @@ export function AgentWorkflowSettingsClient({ ) : null} + {canPromoteStep ? ( + + ) : null} + {canIndentStep ? ( + + ) : null} {canAddChildStep ? (