Open History to see the last commit
1import { splitsSurrogatePair } from "@t3tools/shared/assistantCitations";
2
3export function formatDiagnosticsDuration(value: number): string {
4 const milliseconds = Math.round(value);
5 if (milliseconds < 1_000) return `${milliseconds} ms`;
6 return `${(value / 1_000).toFixed(value >= 10_000 ? 1 : 2).replace(/\.0+$/, "")} s`;
7}
8
9export function formatProcessName(command: string): string {
10 const firstToken = command.trim().split(/\s+/)[0];
11 if (!firstToken) return command;
12 const normalized = firstToken.replace(/^['"]|['"]$/g, "");
13 const segments = normalized.split(/[\\/]/).filter(Boolean);
14 return segments.at(-1) ?? normalized;
15}
16
17export function formatShortProcessName(command: string): string {
18 const name = formatProcessName(command);
19 if (name.length <= 42) return name;
20 // Never end on the first half of an emoji.
21 return `${name.slice(0, splitsSurrogatePair(name, 39) ? 38 : 39)}...`;
22}