fix: retain cancellation labels after approval interruptions

This commit is contained in:
Ed1s0nZ committed 2026-10-06 03:11:11 +08:00
1 parent 054a77cdab
commit 9090e75a67
5 files changed
+105 -2

No files matched your search

+3 -1
View File
@@ -4206,7 +4206,9 @@ function handleStreamEvent(event, progressElement, progressId,
updateProgressConversation(progressId, event.data.conversationId);
}
if (progressTaskState.has(progressId)) {
finalizeProgressTask(progressId, typeof window.t === 'function' ? window.t('tasks.statusCompleted') : '已完成');
const outcome = progressDoneOutcome(event.data);
const labelKey = outcome.icon === '✅' ? 'tasks.statusCompleted' : outcome.key;
finalizeProgressTask(progressId, typeof window.t === 'function' ? window.t(labelKey) : outcome.fallback);
}
// 检查时间线中是否有错误项
@@ -6,3 +6,13 @@ test('done preserves cancelled and failed outcomes instead of showing success',(
}
assert.equal(c.progressDoneOutcome({status:'completed'}).icon,'✅');assert.equal(c.progressDoneOutcome({workflowStatus:'cancelled'}).icon,'⛔');
});
test('actual done branch cancels its progress control and outstanding tools',()=>{
const start=source.indexOf(" case 'done':"),end=source.indexOf('\n }',start);
for(const status of ['cancelled','failed','completed']){
const title={};let label,toolStatus;
const ctx=vm.createContext({event:{type:'done',data:{status}},progressId:'p',window:{},document:{querySelector:()=>title},timeline:null,progressTaskState:new Map([['p',{}]]),stopProgressElapsedClock(){},responseStreamStateByProgressId:new Map(),mainIterationStateByProgressId:new Map(),thinkingStreamStateByProgressId:new Map(),einoAgentReplyStreamStateByProgressId:new Map(),toolResultStreamStateByKey:new Map(),loadActiveTasks(){},setTimeout(){},finalizeProgressTask:(_,value)=>{label=value},finalizeOutstandingToolCallsForProgress:(_,value)=>{toolStatus=value}});
vm.runInContext(source.slice(source.indexOf('function progressDoneOutcome('),source.indexOf('function finalizeOutstandingToolCallsForProgress(')),ctx);
vm.runInContext('function run(){switch(event.type){'+source.slice(start,end)+'}}',ctx);ctx.run();
assert.equal(title.textContent.startsWith('✅'),status==='completed');assert.equal(label,status==='cancelled'?'任务已取消':status==='failed'?'任务执行失败':'渗透测试完成');assert.equal(toolStatus,status==='cancelled'?'cancelled':'failed');
}
});