feat:三个窗口接口联调版本
This commit is contained in:
@@ -222,7 +222,113 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
// 当前的展示的任务流程
|
||||
const currentTask = ref<IRawStepTask>()
|
||||
function setCurrentTask(task: IRawStepTask) {
|
||||
currentTask.value = task
|
||||
const existingTask = currentTask.value
|
||||
|
||||
// 🆕 智能判断:如果是同一个任务,保留用户修改过的数据(AgentSelection、TaskProcess、Collaboration_Brief_frontEnd)
|
||||
if (existingTask && existingTask.Id === task.Id) {
|
||||
currentTask.value = {
|
||||
...task,
|
||||
AgentSelection: existingTask.AgentSelection || task.AgentSelection,
|
||||
TaskProcess: existingTask.TaskProcess || task.TaskProcess,
|
||||
Collaboration_Brief_frontEnd:
|
||||
existingTask.Collaboration_Brief_frontEnd || task.Collaboration_Brief_frontEnd,
|
||||
}
|
||||
|
||||
// 🆕 同步更新主流程数据(让执行结果卡片和任务大纲都能联动)
|
||||
syncCurrentTaskToMainProcess(currentTask.value)
|
||||
|
||||
console.log('🔄 setCurrentTask: 保留同一任务的分支数据', {
|
||||
taskId: task.Id,
|
||||
taskName: task.StepName,
|
||||
preservedAgentSelection: currentTask.value.AgentSelection,
|
||||
preservedTaskProcessLength: currentTask.value.TaskProcess?.length || 0,
|
||||
})
|
||||
} else {
|
||||
// 不同任务:使用新任务数据
|
||||
currentTask.value = task
|
||||
console.log('🔄 setCurrentTask: 切换到不同任务', {
|
||||
taskId: task.Id,
|
||||
taskName: task.StepName,
|
||||
agentSelection: task.AgentSelection,
|
||||
taskProcessLength: task.TaskProcess?.length || 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 🆕 同步 currentTask 到主流程数据
|
||||
function syncCurrentTaskToMainProcess(updatedTask: IRawStepTask) {
|
||||
const collaborationProcess = agentRawPlan.value.data?.['Collaboration Process']
|
||||
if (!collaborationProcess) {
|
||||
console.warn('⚠️ syncCurrentTaskToMainProcess: collaborationProcess 不存在')
|
||||
return
|
||||
}
|
||||
|
||||
const taskIndex = collaborationProcess.findIndex((t) => t.Id === updatedTask.Id)
|
||||
if (taskIndex === -1) {
|
||||
console.warn('⚠️ syncCurrentTaskToMainProcess: 未找到对应任务', updatedTask.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// 使用 splice 确保 Vue 响应式更新
|
||||
collaborationProcess.splice(taskIndex, 1, {
|
||||
...collaborationProcess[taskIndex]!,
|
||||
AgentSelection: updatedTask.AgentSelection || [],
|
||||
TaskProcess: updatedTask.TaskProcess || [],
|
||||
Collaboration_Brief_frontEnd: updatedTask.Collaboration_Brief_frontEnd,
|
||||
})
|
||||
|
||||
console.log('✅ syncCurrentTaskToMainProcess: 已同步到主流程', {
|
||||
taskName: collaborationProcess[taskIndex]!.StepName,
|
||||
agentSelection: collaborationProcess[taskIndex]!.AgentSelection,
|
||||
taskProcessLength: collaborationProcess[taskIndex]!.TaskProcess?.length || 0,
|
||||
})
|
||||
}
|
||||
|
||||
// 🆕 设置当前任务的 TaskProcess 数据(用于切换分支时更新显示)
|
||||
function setCurrentTaskProcess(taskProcess: TaskProcess[]) {
|
||||
if (currentTask.value) {
|
||||
// 创建新的对象引用,确保响应式更新
|
||||
currentTask.value = {
|
||||
...currentTask.value,
|
||||
TaskProcess: JSON.parse(JSON.stringify(taskProcess)),
|
||||
}
|
||||
|
||||
// 🆕 同步到主流程数据(让执行结果卡片和任务大纲都能联动)
|
||||
syncCurrentTaskToMainProcess(currentTask.value)
|
||||
|
||||
console.log('✅ 已更新 currentTask.TaskProcess 并同步到主流程:', {
|
||||
taskId: currentTask.value.Id,
|
||||
agent数量: taskProcess.length,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 🆕 更新当前任务的 AgentSelection 和 TaskProcess(用于在 AgentAllocation 中切换 agent 组合)
|
||||
// 此函数专门用于强制更新,不会被 setCurrentTask 的"智能保留"逻辑阻止
|
||||
function updateCurrentAgentSelection(
|
||||
agentSelection: string[],
|
||||
taskProcess: TaskProcess[],
|
||||
collaborationBrief: any,
|
||||
) {
|
||||
if (currentTask.value) {
|
||||
// 直接更新 currentTask,不保留旧数据
|
||||
currentTask.value = {
|
||||
...currentTask.value,
|
||||
AgentSelection: agentSelection,
|
||||
TaskProcess: taskProcess,
|
||||
Collaboration_Brief_frontEnd: collaborationBrief,
|
||||
}
|
||||
|
||||
// 同步到主流程数据
|
||||
syncCurrentTaskToMainProcess(currentTask.value)
|
||||
|
||||
console.log('✅ 已强制更新 currentTask 的 AgentSelection 并同步到主流程:', {
|
||||
taskId: currentTask.value.Id,
|
||||
taskName: currentTask.value.StepName,
|
||||
newAgentSelection: agentSelection,
|
||||
taskProcessLength: taskProcess.length,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const agentRawPlan = ref<{ data?: IRawPlanResponse; loading?: boolean }>({ loading: false })
|
||||
@@ -315,6 +421,9 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
setSearchValue,
|
||||
currentTask,
|
||||
setCurrentTask,
|
||||
setCurrentTaskProcess, // 🆕 设置当前任务的 TaskProcess
|
||||
updateCurrentAgentSelection, // 🆕 强制更新 AgentSelection(用于 AgentAllocation 切换组合)
|
||||
syncCurrentTaskToMainProcess, // 🆕 同步 currentTask 到主流程
|
||||
agentRawPlan,
|
||||
setAgentRawPlan,
|
||||
executePlan,
|
||||
|
||||
Reference in New Issue
Block a user