Show persistent timestamps for operation and teacher messages

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

View File

@@ -142,6 +142,8 @@ export type ConversationContentBlock =
export interface ConversationMessageNode {
kind: 'message';
id: string;
/** Epoch ms: user send time / assistant completion time. Absent for undated history. */
timestamp?: number;
sourceEntryId?: string;
clientRequestId?: string;
role: 'user' | 'assistant';

View File

@@ -96,6 +96,8 @@ export interface TeacherRequest {
text: string;
references: TeacherReference[];
createdAt: string;
/** Actual terminal time, absent in older history; never inferred from topic.updatedAt. */
finishedAt?: string;
sourceCursor: TeacherSourceContext['cursor'];
sourceCapturedAt: string;
includedSourceMessageIds: string[];

View File

@@ -0,0 +1,7 @@
/** Read only real, valid epoch milliseconds / ISO dates; never invent a history time. */
export function messageTimestamp(value: unknown): number | undefined {
const timestamp = typeof value === 'number' ? value
: typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T/.test(value) ? Date.parse(value) : NaN;
return Number.isFinite(timestamp) && timestamp >= 0 && !Number.isNaN(new Date(timestamp).getTime())
? timestamp : undefined;
}