feat:修复执行过程编排中初始分支删除单个节点bug
This commit is contained in:
@@ -2804,6 +2804,7 @@ def handle_delete_task_process_node(data):
|
||||
for branch in branches_list:
|
||||
if branch.get('id') == branch_id:
|
||||
# 找到目标分支,删除指定的节点
|
||||
target_branch_content = branch.get('branchContent') # 保存branchContent用于匹配flow_branches
|
||||
nodes = branch.get('nodes', [])
|
||||
tasks = branch.get('tasks', [])
|
||||
|
||||
@@ -2815,14 +2816,47 @@ def handle_delete_task_process_node(data):
|
||||
break
|
||||
|
||||
if node_to_delete:
|
||||
# 先获取 original_index(删除前获取,用于同步 flow_branches)
|
||||
node_data = node_to_delete.get('data', {})
|
||||
original_index = node_data.get('originalIndex')
|
||||
|
||||
# ========== 同步更新 flow_branches (在删除前执行) ==========
|
||||
if original_index is not None:
|
||||
flow_branches = existing_branches.get('flow_branches', [])
|
||||
if isinstance(flow_branches, list):
|
||||
# 在 nodes 中查找并删除
|
||||
for flow_branch in flow_branches:
|
||||
flow_nodes = flow_branch.get('nodes', [])
|
||||
if isinstance(flow_nodes, list):
|
||||
for flow_node in flow_nodes:
|
||||
flow_node_data = flow_node.get('data', {})
|
||||
task_data = flow_node_data.get('task', {})
|
||||
if task_data.get('Id') == step_id:
|
||||
task_process = task_data.get('TaskProcess', [])
|
||||
if 0 <= original_index < len(task_process):
|
||||
task_process.pop(original_index)
|
||||
task_data['TaskProcess'] = task_process
|
||||
break
|
||||
|
||||
# 在 tasks 中查找并删除
|
||||
for flow_branch in flow_branches:
|
||||
flow_tasks = flow_branch.get('tasks', [])
|
||||
if isinstance(flow_tasks, list):
|
||||
for task_item in flow_tasks:
|
||||
if task_item.get('Id') == step_id:
|
||||
task_process = task_item.get('TaskProcess', [])
|
||||
if 0 <= original_index < len(task_process):
|
||||
task_process.pop(original_index)
|
||||
task_item['TaskProcess'] = task_process
|
||||
break
|
||||
|
||||
existing_branches['flow_branches'] = flow_branches
|
||||
# ========== 同步更新 flow_branches 结束 ==========
|
||||
|
||||
# 从 nodes 中删除
|
||||
nodes = [n for n in nodes if n.get('id') != node_id]
|
||||
|
||||
# 从 tasks 中删除:使用 originalIndex 精确匹配
|
||||
# nodes 包含 root 节点,所以 agent 节点的 originalIndex 对应 tasks 的索引
|
||||
node_data = node_to_delete.get('data', {})
|
||||
original_index = node_data.get('originalIndex')
|
||||
|
||||
if original_index is not None and 0 <= original_index < len(tasks):
|
||||
tasks.pop(original_index)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user