Files
archie/ui/src/chat/session.ts
T
sam 0dc5bf9a9b
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
fix(ui): times honour the Appearance zone, one duration formatter everywhere (#1761)
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.
2026-11-06 22:21:45 +11:00

31 lines
1.0 KiB
TypeScript

import { useAppearanceStore } from "../stores/appearance";
import type { ChatSession } from "./state";
// 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(useAppearanceStore().timeZone).format(new Date(session.created_at))
: "New chat";
}