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'); }); });