656c89e4b2
新增 agent/direct_thread_raw_item.rs:把 Codex 原始 response item 与 app-server item 收敛成同一形状的脱敏原始条目,只做挑字段、脱敏、截断,不再生成卡片的 kind / 标题 / 折叠摘要 删除 agent/direct_chat_entry.rs:工具卡片形状不再由 Rust 生产 历史切片改为返回脱敏原始条目列表,不再在 Rust 侧合并 function_call 与 function_call_output 新增前端 directThreadItemProjection.ts:工具卡片 kind / 标题 / 摘要 / 状态与可见性判定全部在前端完成 directThreadChat reducer 改用同一投影函数处理运行态事件,新增 mergeDirectHistoryItems 走同一份投影与合并规则 DirectThreadHistorySlice 去掉 entries 与 itemTimestamps,改为 items + firstItemId
49 lines
1.4 KiB
TypeScript
49 lines
1.4 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('条目时间来自搬运后的 at,前端不自己补造时间', () => {
|
|
const items = [
|
|
{
|
|
itemId: 'direct-codex:turn:user',
|
|
itemType: 'message',
|
|
role: 'user',
|
|
text: '帮我修改游戏',
|
|
completed: true,
|
|
at: 1_800_000_000_001,
|
|
},
|
|
{
|
|
itemId: 'direct-codex:turn:assistant',
|
|
itemType: 'message',
|
|
role: 'assistant',
|
|
text: '好的',
|
|
completed: true,
|
|
},
|
|
];
|
|
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');
|
|
});
|
|
});
|