Show persistent timestamps for operation and teacher messages

This commit is contained in:
鲨鱼辣椒 committed 2026-09-29 18:02:54 +08:00
1 parent 3a175101c9
commit ead3407890
24 files changed
+355 -9

No files matched your search

+16
View File
@@ -58,6 +58,19 @@ function apply(
}
describe('Pi event projector', () => {
it.each(['stop', 'error', 'aborted'])('uses send time and terminal time for %s, never the assistant start time', async stopReason => {
let now = 2000;
const projector = new PiEventProjector({ createId: () => 'live-message', now: () => now });
let snapshot = emptySnapshot();
snapshot = apply(snapshot, await projector.project(snapshot, { type: 'message_start', message: { role: 'user', timestamp: 1000, content: [{ type: 'text', text: '你好' }] } }));
expect(snapshot.nodes[0]).toMatchObject({ role: 'user', timestamp: 1000 });
snapshot = apply(snapshot, await projector.project(snapshot, { type: 'message_start', message: { role: 'assistant', timestamp: 2000, content: [] } }));
expect(snapshot.nodes.at(-1)).not.toHaveProperty('timestamp');
now = 9000;
snapshot = apply(snapshot, await projector.project(snapshot, { type: 'message_end', message: { role: 'assistant', timestamp: 2000, stopReason, content: [{ type: 'text', text: '你好呀' }] } }));
expect(snapshot.nodes.at(-1)).toMatchObject({ role: 'assistant', timestamp: 9000 });
});
it('projects only subagent.v1 details and never exposes unknown raw details', async () => {
const projector = new PiEventProjector({ createId: () => 'unused' });
let snapshot = emptySnapshot();
@@ -157,6 +170,7 @@ describe('Pi event projector', () => {
it('keeps one assistant UI identity while content-index deltas become an authoritative message', async () => {
const projector = new PiEventProjector({
createId: () => 'assistant-ui-a',
now: () => 9000,
});
let snapshot = emptySnapshot();
const initialAssistant = {
@@ -217,6 +231,7 @@ describe('Pi event projector', () => {
kind: 'message',
id: 'assistant-ui-a',
role: 'assistant',
timestamp: 9000,
status: 'complete',
blocks: [{
kind: 'text',
@@ -624,6 +639,7 @@ describe('Pi event projector', () => {
kind: 'message',
id: 'user-ui-a',
clientRequestId: 'request-a',
timestamp: 20,
role: 'user',
status: 'complete',
blocks: [