fix: 使用终态答案校正流式输出
- DONE 事件携带后端汇总的完整最终正文 - 前端完成时替换可能受损的流式文本 - 补充文件 URL 终态校正回归测试
This commit is contained in:
@@ -298,6 +298,38 @@ describe('agentTimelineAdapter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('reconciles streamed text with the canonical final answer', () => {
|
||||
const items: any[] = [];
|
||||
|
||||
for (const delta of [
|
||||
'http://127.0.0.1:39',
|
||||
'0',
|
||||
'/easyflow/file.docx',
|
||||
]) {
|
||||
applyAgentSseEnvelope(items, {
|
||||
domain: 'LLM',
|
||||
type: 'MESSAGE',
|
||||
payload: { delta },
|
||||
});
|
||||
}
|
||||
applyAgentSseEnvelope(items, {
|
||||
domain: 'SYSTEM',
|
||||
type: 'DONE',
|
||||
payload: {
|
||||
finalText: 'http://127.0.0.1:39000/easyflow/file.docx',
|
||||
},
|
||||
});
|
||||
|
||||
const assistant = items.find(
|
||||
(item): item is ChatTimelineMessageItem =>
|
||||
item.type === 'message' && item.role === 'assistant',
|
||||
);
|
||||
expect(assistant?.parts[0]?.content).toBe(
|
||||
'http://127.0.0.1:39000/easyflow/file.docx',
|
||||
);
|
||||
expect(assistant?.status).toBe('done');
|
||||
});
|
||||
|
||||
it('applies streaming text, HITL approval and error envelopes', () => {
|
||||
const items: any[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user