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

+2 -5
View File
@@ -4,6 +4,7 @@ import { CircleCheck, CircleX } from "@lucide/vue";
import { computed } from "vue";
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
import { duration as formatDuration } from "@/lib/format";
import {
TraceCollapsible,
TraceCollapsibleContent,
@@ -52,11 +53,7 @@ const outcome = computed(
"",
);
const running = computed(() => !outcome.value && !failed.value && !!props.streaming);
const duration = computed(() => {
const ms = props.tool.duration_ms;
if (!ms) return "";
return ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(ms < 10000 ? 1 : 0)}s`;
});
const duration = computed(() => formatDuration(props.tool.duration_ms));
// The row shows the call's main value, as "git diff --stat" rather than its
// JSON: the first string argument, else its arguments as key: value pairs.
const argument = computed(() => {
+21 -7
View File
@@ -1,16 +1,30 @@
import { useAppearanceStore } from "../stores/appearance";
import type { ChatSession } from "./state";
const started = new Intl.DateTimeFormat(undefined, {
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
});
// One formatter per zone, cached: the zone chosen under Appearance is applied
// here like Timestamp applies it, not the browser's zone.
const startedCache = new Map<string, Intl.DateTimeFormat>();
function started(zone: string): Intl.DateTimeFormat {
const cached = startedCache.get(zone);
if (cached) return cached;
const format = new Intl.DateTimeFormat(undefined, {
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
...(zone ? { timeZone: zone } : {}),
});
startedCache.set(zone, format);
return format;
}
// An untitled conversation is named by when it began, which tells two apart
// where a raw id cannot.
export function sessionTitle(session: ChatSession): string {
const named = session.title || session.branch_name;
if (named) return named;
return session.created_at ? started.format(new Date(session.created_at)) : "New chat";
return session.created_at
? started(useAppearanceStore().timeZone).format(new Date(session.created_at))
: "New chat";
}