fix(ui): times honour the Appearance zone, one duration formatter everywhere (#1761)
deploy / gate (push) Successful in 4m54s
Quality / check (push) Successful in 6m44s
deploy / archied-image (push) Successful in 3m44s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped

lib/format.ts gains shortTime(value, zone) and becomes the home of the
single duration() formatter (moved from timeline-event.ts, which
re-exports it so the stage rail and duration.test.ts are unchanged).
LogTable's time column, audit's From/To chips and chat session titles now
format in the zone chosen under Appearance instead of the browser's.
StepNode, schedule runDuration, labels formatMs and ChatToolCall all
delegate to duration(), removing the "12ms" vs "12 ms" vs "under 1 s"
split.
This commit is contained in:
sam committed 2026-11-06 22:21:45 +11:00
1 parent ca107f6977
commit 0dc5bf9a9b
10 files changed
+73 -59

No files matched your search

+6 -19
View File
@@ -5,33 +5,20 @@
* read them -- the timeline row and the stage rail's agent reports -- and a
* second copy would eventually disagree with this one.
*/
import { duration } from "../lib/format.ts";
import type { TaskEvent } from "./task-run";
// The one duration formatter lives in lib/format; re-exported so the stage
// rail renders a duration exactly the way the timeline does.
export { duration };
function words(value: unknown): string {
return String(value || "event")
.replaceAll("_", " ")
.replace(/\b\w/g, (letter) => letter.toUpperCase());
}
/** Exported so the stage rail renders a duration exactly the way the timeline
* does; a second formatter would eventually disagree with this one. */
export function duration(milliseconds: unknown): string {
const ms = Number(milliseconds);
if (!Number.isFinite(ms) || ms < 0) return "";
if (ms < 1000) return "under 1 s";
const seconds = ms / 1000;
// Under 60s: 1 dp when seconds < 10, 0 dp otherwise (40.6 s, but 41 s).
if (seconds < 60) return `${seconds.toFixed(seconds < 10 ? 1 : 0)} s`;
const roundedSeconds = Math.round(seconds);
const minutes = Math.floor(roundedSeconds / 60);
const remSec = roundedSeconds % 60;
if (minutes < 60)
return remSec === 0 ? `${minutes} min` : `${minutes} min ${remSec} s`;
const hours = Math.floor(minutes / 60);
const remMin = minutes - hours * 60;
return remMin === 0 ? `${hours} h` : `${hours} h ${remMin} min`;
}
function count(value: unknown): string {
const n = Number(value);
// Render only for positive counts; zero is treated as "no metric