fdc48fe725
- directThreadItemProjection.ts 直接消费生成的 DirectThreadItem,工具卡片 kind / 标题 / 摘要 / 状态与可见性判定都在这里 - directThreadChat.ts 聊天条目只留一个 itemId:去掉 callId 概念,去掉 deltaText 缓冲,增量直接追加到运行态条目正文 - 合并规则收成先到者赢、后到只补空:正文只增不减、工具状态允许从 running 升级到终态 - 回合结束把运行态条目并入历史并清空 live,条目既不消失也不重复 - directThreadEvents.ts 改为转发 ts-rs 绑定,只保留历史条目转消息的过渡函数 - ToolCallGroup 与 toolCallGroupPresentation 改用去掉回合身份的 DirectChatToolCard - generated/index.ts 补上 DirectThread* 绑定导出 - 回退本仓库其它模块仍在改的 DirectCodexUser* 绑定重新生成(避免误改他人进行中的契约) - 两个 vitest 用例文件按新 API 重写,11 条用例通过
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
directThreadHistoryItemsToMessages,
|
|
isDirectTurnInProgress,
|
|
} from '../src/features/project-workspace/directThreadEvents';
|
|
import type { DirectThreadItem } from '../src/features/project-workspace/directThreadItemProjection';
|
|
|
|
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('条目时间来自搬运后的 at,前端不自己补造时间', () => {
|
|
const items = [
|
|
{
|
|
itemId: 'direct-codex:turn:user',
|
|
itemType: 'message',
|
|
role: 'user',
|
|
text: '帮我修改游戏',
|
|
at: 1_800_000_000_001,
|
|
},
|
|
{
|
|
itemId: 'direct-codex:turn:assistant',
|
|
itemType: 'message',
|
|
role: 'assistant',
|
|
text: '好的',
|
|
at: 0,
|
|
},
|
|
] satisfies DirectThreadItem[];
|
|
expect(directThreadHistoryItemsToMessages(items)[0]?.updatedAt).toBe(
|
|
1_800_000_000_001,
|
|
);
|
|
// Rust 拿不到条目时间时给 0,前端不得用"当前时间"补造。
|
|
expect(directThreadHistoryItemsToMessages(items)[1]?.updatedAt).toBe(0);
|
|
expect(items[0]).not.toHaveProperty('recordedAt');
|
|
});
|
|
});
|