Open History to see the last commit
1export interface TimelineDurationMessage {
2 id: string;
3 role: "user" | "assistant" | "system";
4 createdAt: string;
5 completedAt?: string | undefined;
6}
7
8export function computeMessageDurationStart(
9 messages: ReadonlyArray<TimelineDurationMessage>,
10): Map<string, string> {
11 const result = new Map<string, string>();
12 let lastBoundary: string | null = null;
13
14 for (const message of messages) {
15 if (message.role === "user") {
16 lastBoundary = message.createdAt;
17 }
18 result.set(message.id, lastBoundary ?? message.createdAt);
19 if (message.role === "assistant" && message.completedAt) {
20 lastBoundary = message.completedAt;
21 }
22 }
23
24 return result;
25}
26
27export function normalizeCompactToolLabel(value: string): string {
28 return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
29}