feat:执行状态单例状态bug修复
This commit is contained in:
@@ -480,8 +480,14 @@ async function handlePauseResume() {
|
||||
// 正常恢复执行
|
||||
try {
|
||||
if (websocket.connected) {
|
||||
// 检查 execution_id 是否存在
|
||||
if (!currentExecutionId.value) {
|
||||
warning('无法恢复', '执行ID不存在,请等待执行开始')
|
||||
return
|
||||
}
|
||||
|
||||
await websocket.send('resume_execution', {
|
||||
execution_id: currentExecutionId.value || ''
|
||||
execution_id: currentExecutionId.value
|
||||
})
|
||||
|
||||
isPaused.value = false
|
||||
@@ -498,12 +504,19 @@ async function handlePauseResume() {
|
||||
// 暂停执行
|
||||
try {
|
||||
if (websocket.connected) {
|
||||
// 检查 execution_id 是否存在
|
||||
if (!currentExecutionId.value) {
|
||||
warning('无法暂停', '执行ID不存在,请等待执行开始')
|
||||
isPausing.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// 先设置 isPausing,允许接收当前正在执行的动作的结果
|
||||
isPausing.value = true
|
||||
info('暂停中', '正在等待当前动作完成')
|
||||
|
||||
await websocket.send('pause_execution', {
|
||||
execution_id: currentExecutionId.value || ''
|
||||
execution_id: currentExecutionId.value
|
||||
})
|
||||
|
||||
/*不立即设置 isPaused = true
|
||||
@@ -881,11 +894,14 @@ async function restartFromStep(stepIndex: number) {
|
||||
// 清空修改记录
|
||||
agentsStore.clearModifiedSteps()
|
||||
|
||||
// 保存旧的 execution_id 用于停止
|
||||
const oldExecutionId = currentExecutionId.value
|
||||
|
||||
// 停止旧的执行
|
||||
if (websocket.connected && currentExecutionId.value) {
|
||||
if (websocket.connected && oldExecutionId) {
|
||||
try {
|
||||
const stopResponse = await websocket.send('stop_execution', {
|
||||
execution_id: currentExecutionId.value || ''
|
||||
await websocket.send('stop_execution', {
|
||||
execution_id: oldExecutionId
|
||||
})
|
||||
// 等待一下确保后端完全停止
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
@@ -893,6 +909,13 @@ async function restartFromStep(stepIndex: number) {
|
||||
console.warn('⚠️ 停止旧执行失败(可能已经停止):', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 前端生成新的 execution_id(确保前端和后端使用同一个 ID)
|
||||
const generalGoal = agentsStore.agentRawPlan.data?.['General Goal'] || ''
|
||||
const newExecutionId = `${generalGoal.replace(/\s+/g, '_')}_${Date.now()}`
|
||||
currentExecutionId.value = newExecutionId
|
||||
console.log('🔄 [DEBUG] restartFromStep: 生成新的 execution_id =', newExecutionId)
|
||||
|
||||
// 构建截断后的 RehearsalLog
|
||||
const truncatedLog = buildTruncatedRehearsalLog(stepIndex)
|
||||
|
||||
@@ -936,7 +959,7 @@ async function restartFromStep(stepIndex: number) {
|
||||
isStreaming.value = true
|
||||
currentExecutionId.value = executionId
|
||||
},
|
||||
undefined,
|
||||
newExecutionId, // 传入前端生成的 execution_id
|
||||
stepIndex,
|
||||
truncatedLog
|
||||
)
|
||||
@@ -1007,8 +1030,41 @@ async function handleTaskProcess() {
|
||||
}
|
||||
|
||||
// 重置执行结果
|
||||
function handleRefresh() {
|
||||
async function handleRefresh() {
|
||||
// 如果有正在执行的任务,先通知后端停止
|
||||
if (websocket.connected && currentExecutionId.value) {
|
||||
try {
|
||||
await websocket.send('stop_execution', {
|
||||
execution_id: currentExecutionId.value
|
||||
})
|
||||
// 等待一下确保后端完全停止
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
} catch (err) {
|
||||
console.warn('⚠️ 停止执行失败(可能已经停止):', err)
|
||||
}
|
||||
}
|
||||
|
||||
// 重置所有状态
|
||||
agentsStore.setExecutePlan([])
|
||||
stepExecutionStatus.value = {}
|
||||
sentStepIds.value.clear()
|
||||
currentExecutionId.value = null
|
||||
isPaused.value = false
|
||||
isStreaming.value = false
|
||||
isPausing.value = false
|
||||
loading.value = false
|
||||
isRestarting.value = false
|
||||
|
||||
// 重置进度通知标题
|
||||
currentProgressTitle.value = '任务执行中'
|
||||
|
||||
// 关闭进度通知
|
||||
if (currentProgressNotificationId.value) {
|
||||
removeNotification(currentProgressNotificationId.value)
|
||||
currentProgressNotificationId.value = null
|
||||
}
|
||||
|
||||
success('已重置', '执行状态已重置')
|
||||
}
|
||||
|
||||
// 添加滚动状态指示器
|
||||
|
||||
Reference in New Issue
Block a user