7a7a841733
活动回合快照与Direct事件统一管理生命周期,避免历史终态回放恢复忙碌态 用户消息显示发送时间,历史信封保存时间并通过独立映射回读 完成后统一折叠中间输出和工具调用,最终回复与失败提示保持可见 同步回归用例与规范文档,保留原生实机验收待办
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
directThreadHistoryItemsToMessages,
|
|
isDirectTurnInProgress,
|
|
} from '../src/features/project-workspace/directThreadEvents';
|
|
|
|
describe('Direct 回合状态与历史时间', () => {
|
|
it('终态和空状态不恢复为活动回合', () => {
|
|
for (const status of [
|
|
'completed',
|
|
'failed',
|
|
'interrupted',
|
|
null,
|
|
undefined,
|
|
]) {
|
|
expect(isDirectTurnInProgress(status)).toBe(false);
|
|
}
|
|
for (const status of ['accepted', 'running', 'streaming', 'finalizing']) {
|
|
expect(isDirectTurnInProgress(status)).toBe(true);
|
|
}
|
|
});
|
|
it('按消息 id 读取信封时间,旧记录不使用当前时间补造', () => {
|
|
const items = [
|
|
{
|
|
type: 'message',
|
|
role: 'user',
|
|
id: 'direct-codex:turn:user',
|
|
content: [{ type: 'input_text', text: '帮我修改游戏' }],
|
|
},
|
|
];
|
|
const timestamps = { 'direct-codex:turn:user': 1_800_000_000_001 };
|
|
expect(
|
|
directThreadHistoryItemsToMessages(items, timestamps)[0]?.updatedAt,
|
|
).toBe(1_800_000_000_001);
|
|
expect(directThreadHistoryItemsToMessages(items)[0]?.updatedAt).toBe(0);
|
|
expect(items[0]).not.toHaveProperty('recordedAt');
|
|
});
|
|
});
|