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.
This commit is contained in:
10 files changed
+73
-59
No files matched your search
@@ -7,6 +7,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { duration } from "@/lib/format";
|
||||
import { stepIcon } from "./step-icons";
|
||||
import { stepTitle, type StepNodeData } from "./workflow-graph";
|
||||
|
||||
@@ -72,12 +73,7 @@ const badge = computed(() => {
|
||||
});
|
||||
const number = computed(() => (props.data.step ? `${Number(props.data.step)}.` : ""));
|
||||
|
||||
function duration(ms?: number): string {
|
||||
if (ms === undefined) return "";
|
||||
if (ms < 1000) return `${ms} ms`;
|
||||
const seconds = Math.round(ms / 1000);
|
||||
return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
||||
}
|
||||
|
||||
|
||||
const card = ref<HTMLElement | null>(null);
|
||||
let observer: ResizeObserver | undefined;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/** Naming and numbers shared by the workflow tables. */
|
||||
|
||||
import { duration } from "../lib/format.ts";
|
||||
|
||||
const WORKFLOW_LABELS: Record<string, string> = {
|
||||
implement: "Implement",
|
||||
tdd: "TDD",
|
||||
@@ -27,8 +29,5 @@ export function pct(
|
||||
|
||||
export function formatMs(ms: number | undefined | null): string {
|
||||
if (!ms) return "–";
|
||||
if (ms < 1000) return `${ms} ms`;
|
||||
const secs = ms / 1000;
|
||||
if (secs < 60) return `${secs.toFixed(1)} s`;
|
||||
return `${(secs / 60).toFixed(1)} min`;
|
||||
return duration(ms);
|
||||
}
|
||||
Reference in new issue
Block a user