- {fmtTokens(displayedTokens.input + displayedTokens.output) || "—"}
+ {formatTokens(displayedTokens.input + displayedTokens.output) || "—"}
{t("{count} tasks", { count: displayedTokens.taskCount })}
@@ -741,7 +736,7 @@ export default function DashboardPage() {
{label}
- {fmtTokens(value)}
+ {formatTokens(value)}
fmtTokens(Number(v))}
+ tickFormatter={(v) => formatTokens(Number(v))}
tickLine={false}
axisLine={false}
tick={{ fontSize: 10 }}
@@ -851,7 +846,7 @@ export default function DashboardPage() {
{(dailyTrendConfig as Record)[String(name)]?.label ??
String(name)}
- {fmtTokens(Number(value))}
+ {formatTokens(Number(value))}
)}
/>
diff --git a/web/src/app/(main)/function/assets/page.tsx b/web/src/app/(main)/function/assets/page.tsx
index ad50d7f57..74bd07d77 100644
--- a/web/src/app/(main)/function/assets/page.tsx
+++ b/web/src/app/(main)/function/assets/page.tsx
@@ -61,6 +61,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { api } from "@/lib/api";
import { parseCompanyScopeText } from "@/lib/company-scope";
import { httpHref } from "@/lib/http-href";
+import { httpStatusTone } from "@/lib/status";
import type { Asset, Company, CompanyScopeRule } from "@/lib/types";
import { cn } from "@/lib/utils";
import { useActiveCompanyID } from "@/stores/company/company-store";
@@ -90,14 +91,6 @@ function MethodBadge({ method }: { method: string }) {
);
}
-function statusTone(code: number) {
- if (code >= 500) return "text-red-500";
- if (code >= 400) return "text-amber-500";
- if (code >= 300) return "text-blue-500";
- if (code >= 200) return "text-emerald-500";
- return "text-muted-foreground";
-}
-
const PAGE_SIZES = [25, 50, 100, 200];
const TABS: { key: string; label: string; icon: LucideIcon }[] = [
@@ -646,7 +639,9 @@ export default function AssetsPage() {
{a.port || "—"}
{a.status_code != null ? (
-
+
{a.status_code}
) : (
diff --git a/web/src/app/(main)/function/commands/page.tsx b/web/src/app/(main)/function/commands/page.tsx
index 9f7d7c2c2..abcb2d1c3 100644
--- a/web/src/app/(main)/function/commands/page.tsx
+++ b/web/src/app/(main)/function/commands/page.tsx
@@ -13,19 +13,10 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@/components/ui/sheet";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { api } from "@/lib/api";
+import { formatShortDateTime } from "@/lib/format";
import type { CommandRecord, ToolStat } from "@/lib/types";
import { cn } from "@/lib/utils";
-import { intlLocale, t } from "@/i18n";
-
-function fmtTime(ts: string) {
- return new Date(ts).toLocaleString(intlLocale, {
- month: "2-digit",
- day: "2-digit",
- hour: "2-digit",
- minute: "2-digit",
- second: "2-digit",
- });
-}
+import { t } from "@/i18n";
// toolInput renders a tool's raw input for display. Bash's {"command":"..."} is
// unwrapped to the bare command; other tools show their pretty-printed JSON args.
@@ -235,7 +226,7 @@ export default function CommandsPage() {
onClick={() => setSelected(cmd)}
>
- {fmtTime(cmd.created_at)}
+ {formatShortDateTime(cmd.created_at)}
#{cmd.exploration_id}
@@ -340,7 +331,7 @@ export default function CommandsPage() {
<>
{t("Tool execution details")}
- {fmtTime(selected.created_at)}
+ {formatShortDateTime(selected.created_at)}
#{selected.exploration_id}
diff --git a/web/src/app/(main)/function/findings/_components/findings-table.tsx b/web/src/app/(main)/function/findings/_components/findings-table.tsx
index 7eab950df..9f75d7093 100644
--- a/web/src/app/(main)/function/findings/_components/findings-table.tsx
+++ b/web/src/app/(main)/function/findings/_components/findings-table.tsx
@@ -36,6 +36,7 @@ import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Spinner } from "@/components/ui/spinner";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
+import { formatShortDateTime } from "@/lib/format";
import { statusMeta, type Tone, toneClasses } from "@/lib/status";
import type {
ActiveFindingRetest,
@@ -46,7 +47,7 @@ import type {
VerificationStatus,
} from "@/lib/types";
import { cn } from "@/lib/utils";
-import { intlLocale, t } from "@/i18n";
+import { t } from "@/i18n";
export const SEVERITIES: Severity[] = ["critical", "high", "medium", "low"];
@@ -155,15 +156,6 @@ export function isSameFinding(left: Finding, right: Finding): boolean {
return findingRowKey(left) === findingRowKey(right);
}
-export function fmtTime(ts: string) {
- return new Date(ts).toLocaleString(intlLocale, {
- month: "2-digit",
- day: "2-digit",
- hour: "2-digit",
- minute: "2-digit",
- });
-}
-
const COLUMN_COUNT = 10;
interface FindingsTableProps {
@@ -374,7 +366,9 @@ export function FindingsTable({
—
)}
- {fmtTime(f.ts)}
+
+ {formatShortDateTime(f.ts, { seconds: false })}
+
e.stopPropagation()}>
{retest ? (
diff --git a/web/src/app/(main)/function/findings/page.tsx b/web/src/app/(main)/function/findings/page.tsx
index 78a7ec08e..824c48f6a 100644
--- a/web/src/app/(main)/function/findings/page.tsx
+++ b/web/src/app/(main)/function/findings/page.tsx
@@ -41,6 +41,7 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import { api } from "@/lib/api";
+import { formatShortDateTime } from "@/lib/format";
import { getLocalStorageValue, setLocalStorageValue } from "@/lib/local-storage.client";
import { statusMeta } from "@/lib/status";
import type {
@@ -65,7 +66,6 @@ import {
type FindingReport,
FindingsTable,
findingRowKey,
- fmtTime,
isSameFinding,
REPORT_STATE_META,
SEVERITIES,
@@ -1350,7 +1350,7 @@ export default function FindingsPage() {
);
})}
- {fmtTime(group.last_found_at)}
+ {formatShortDateTime(group.last_found_at, { seconds: false })}
{group.task_id !== null && (
- {e.dir ? "—" : fmtSize(e.size)}
+ {e.dir ? "—" : formatBytes(e.size)}
+
+
+ {formatShortDateTime(e.mtime, { year: true, seconds: false })}
-
{fmtTime(e.mtime)}
{!e.dir && (
@@ -303,7 +290,7 @@ export default function WorkspacePage() {
{edit.file.path}
-
{fmtSize(edit.file.size)}
+
{formatBytes(edit.file.size)}
{edit.file.binary || edit.file.too_large ? (
diff --git a/web/src/app/(main)/system/intercept/page.tsx b/web/src/app/(main)/system/intercept/page.tsx
index 106e773b6..56a8f1cd2 100644
--- a/web/src/app/(main)/system/intercept/page.tsx
+++ b/web/src/app/(main)/system/intercept/page.tsx
@@ -52,6 +52,7 @@ import { Card, CardContent } from "@/components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { intlLocale, t } from "@/i18n";
import { api } from "@/lib/api";
+import { formatTokens } from "@/lib/format";
import type {
InterceptAction,
InterceptRule,
@@ -62,13 +63,6 @@ import type {
Tool,
} from "@/lib/types";
-// fmtTokens compacts token counts (1.2k / 3.4M) for approval usage stats.
-function fmtTokens(n: number): string {
- if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + "M";
- if (n >= 1000) return (n / 1000).toFixed(1) + "k";
- return String(n);
-}
-
// tRich translates a sentence whose {placeholders} are rendered as React nodes (e.g. emphasised spans or code).
function tRich(key: string, nodes: Record
): React.ReactNode[] {
return t(key)
@@ -101,7 +95,11 @@ function JudgeSparkbars({ daily }: { daily: JudgeDayUsage[] }) {
return (
@@ -342,10 +340,10 @@ function JudgeCard() {
-
-
-
-
+
+
+
+
{usage.daily.length > 0 && (
diff --git a/web/src/app/(main)/system/skills/page.tsx b/web/src/app/(main)/system/skills/page.tsx
index c289b75fd..099c9620d 100644
--- a/web/src/app/(main)/system/skills/page.tsx
+++ b/web/src/app/(main)/system/skills/page.tsx
@@ -41,21 +41,12 @@ import {
SheetTitle,
} from "@/components/ui/sheet";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { formatShortDateTime } from "@/lib/format";
import { cn } from "@/lib/utils";
import { api } from "@/lib/api";
-import { intlLocale, t } from "@/i18n";
+import { t } from "@/i18n";
import type { Agent, SkillItem, MCPServer, SkillCall, MissingSkill } from "@/lib/types";
-function fmtTime(ts?: string) {
- if (!ts) return t("Never called");
- return new Date(ts).toLocaleString(intlLocale, {
- month: "2-digit",
- day: "2-digit",
- hour: "2-digit",
- minute: "2-digit",
- });
-}
-
// ── Tree node ──────────────────────────────────────────────────────────────
interface TreeNode {
name: string;
@@ -264,7 +255,9 @@ function SkillsOverview({
className="flex w-full items-center gap-2 rounded px-1.5 py-1 text-left hover:bg-muted"
>
{s.name}
- {fmtTime(s.last_used)}
+
+ {formatShortDateTime(s.last_used, { seconds: false, empty: t("Never called") })}
+
))}
@@ -738,7 +731,9 @@ export default function SkillsPage() {
{m.skill}
{t("{count} calls", { count: m.calls })}
- {fmtTime(m.last_used)}
+
+ {formatShortDateTime(m.last_used, { seconds: false, empty: t("Never called") })}
+
))}
@@ -804,7 +799,10 @@ export default function SkillsPage() {
{s.calls > 0 && (
{s.calls}
@@ -893,8 +891,14 @@ export default function SkillsPage() {
{t("Tasks covered")}
-
- {fmtTime(selectedSkill.last_used)}
+
+ {formatShortDateTime(selectedSkill.last_used, { seconds: false, empty: t("Never called") })}
{t("Last called")}
@@ -917,7 +921,9 @@ export default function SkillsPage() {
{usageCalls.map((c, i) => (
-
{fmtTime(c.ts)}
+
+ {formatShortDateTime(c.ts, { seconds: false, empty: t("Never called") })}
+
{c.agent_key || "—"}
{c.task_id > 0 ? t("Task #{id}", { id: c.task_id }) : c.session_id ? t("Chat session") : "—"}
diff --git a/web/src/components/approval-records.tsx b/web/src/components/approval-records.tsx
index 7441b513e..fd5a052f2 100644
--- a/web/src/components/approval-records.tsx
+++ b/web/src/components/approval-records.tsx
@@ -46,20 +46,10 @@ import type {
InterceptReviewInput,
InterceptRisk,
} from "@/lib/types";
+import { formatShortDateTime } from "@/lib/format";
import { cn } from "@/lib/utils";
import { setVisibleInterval } from "@/lib/polling";
-import { intlLocale, t } from "@/i18n";
-
-function fmtTime(value?: string) {
- if (!value) return "—";
- return new Date(value).toLocaleString(intlLocale, {
- month: "2-digit",
- day: "2-digit",
- hour: "2-digit",
- minute: "2-digit",
- second: "2-digit",
- });
-}
+import { t } from "@/i18n";
function source(row: InterceptApprovalRow) {
if (row.decision_source) return row.decision_source;
@@ -477,9 +467,9 @@ export function ApprovalDetail({
{t("Requested at")}
- {fmtTime(row.created_at)}
+ {formatShortDateTime(row.created_at, { empty: "—" })}
{t("Decided at")}
- {fmtTime(current.decided_at)}
+ {formatShortDateTime(current.decided_at, { empty: "—" })}
{t("Decided by")}
@@ -585,7 +575,7 @@ export function ApprovalDetail({
{t("Visible conversation context")}
{t('Conversation record excerpt saved at {time}. What the model actually used follows "Model review input".', {
- time: fmtTime(audit.captured_at),
+ time: formatShortDateTime(audit.captured_at, { empty: "—" }),
})}
{audit.context_truncated ? (
@@ -645,7 +635,11 @@ export function ApprovalDetail({
{t("Model review input SHA-256: {value}", { value: audit.model_input_digest })}
) : null}
{audit.execution_ended_at ? (
- {t("Result recorded at: {time}", { time: fmtTime(audit.execution_ended_at) })}
+
+ {t("Result recorded at: {time}", {
+ time: formatShortDateTime(audit.execution_ended_at, { empty: "—" }),
+ })}
+
) : null}
@@ -805,10 +799,10 @@ function ApprovalTable({
- {fmtTime(row.created_at)}
+ {formatShortDateTime(row.created_at, { empty: "—" })}
- {fmtTime(row.decided_at)}
+ {formatShortDateTime(row.decided_at, { empty: "—" })}
{open ? (
diff --git a/web/src/components/http-code-block.tsx b/web/src/components/http-code-block.tsx
index d21189363..b447656d2 100644
--- a/web/src/components/http-code-block.tsx
+++ b/web/src/components/http-code-block.tsx
@@ -6,17 +6,10 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
+import { httpStatusTone } from "@/lib/status";
import { cn, copyText } from "@/lib/utils";
import { t } from "@/i18n";
-export function statusTone(status: number) {
- if (status >= 500) return "text-red-500";
- if (status >= 400) return "text-amber-500";
- if (status >= 300) return "text-blue-500";
- if (status >= 200) return "text-emerald-500";
- return "text-muted-foreground";
-}
-
function StartLine({ line }: { line: string }) {
const response = /^(HTTP\/\S+)(\s+)(\d{3})(.*)$/.exec(line);
if (response) {
@@ -24,7 +17,7 @@ function StartLine({ line }: { line: string }) {
<>
{response[1]}
{response[2]}
-
{response[3]}
+
{response[3]}
{response[4]}
>
);
diff --git a/web/src/components/transcript.tsx b/web/src/components/transcript.tsx
index 44f2dd08c..6fac8558a 100644
--- a/web/src/components/transcript.tsx
+++ b/web/src/components/transcript.tsx
@@ -24,6 +24,7 @@ import { Button } from "@/components/ui/button";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import { ApprovalDetail } from "@/components/approval-records";
import { reportsBashExit127 } from "@/lib/bash-exit-status";
+import { formatBytes } from "@/lib/format";
import type { Activity, InterceptPending } from "@/lib/types";
// ---- per-agent lane color (planner + work#1/#2/#3 …) ---------------------------
@@ -565,18 +566,6 @@ function MessageBlock({
);
}
-// UserRow renders a right-aligned chat bubble: either a human turn (the message you
-// sent the main agent) or, in a worker session, the LLM-generated intent that leads
-// it (intent=true) — same bubble, but a target icon instead of the human avatar.
-// summary is a truncated first line, so the full message is pulled from the detail
-// and shown in full (bubble is whitespace-pre-wrap, so long/multi-line text wraps).
-// fmtBytes renders a human file size for attachment chips.
-function fmtBytes(n: number): string {
- if (n >= 1 << 20) return `${(n / (1 << 20)).toFixed(1)} MB`;
- if (n >= 1 << 10) return `${(n / (1 << 10)).toFixed(1)} KB`;
- return `${n} B`;
-}
-
type MsgAttachment = { name: string; path: string; size: number };
// parseUserBody splits a user turn's body into text + attachments. The backend stores
@@ -641,7 +630,7 @@ function UserRow({ step, intent, getDetail }: { step: Activity; intent?: boolean
>
{a.name}
-
{fmtBytes(a.size)}
+
{formatBytes(a.size)}
))}
diff --git a/web/src/lib/format.ts b/web/src/lib/format.ts
new file mode 100644
index 000000000..f623f9f1a
--- /dev/null
+++ b/web/src/lib/format.ts
@@ -0,0 +1,55 @@
+// Shared display formatters (sizes, token counts, durations, timestamps), so every
+// page renders the same value the same way.
+
+import { intlLocale } from "@/i18n";
+
+const BYTE_UNITS = ["B", "KB", "MB", "GB"] as const;
+
+/** Human file size: 512 B, 1.5 KB, 3.2 MB, 2.0 GB. Missing or non-positive sizes render as `empty` (default "0 B"). */
+export function formatBytes(bytes: number | null | undefined, { empty = "0 B" }: { empty?: string } = {}): string {
+ if (bytes == null || !Number.isFinite(bytes) || bytes <= 0) return empty;
+ let value = bytes;
+ let unit = 0;
+ while (value >= 1024 && unit < BYTE_UNITS.length - 1) {
+ value /= 1024;
+ unit++;
+ }
+ return unit === 0 ? `${value} B` : `${value.toFixed(1)} ${BYTE_UNITS[unit]}`;
+}
+
+/** Compact token count: 950, 1.2k, 25k, 1.5M, 12M (one decimal only below 10k / 10M). */
+export function formatTokens(n: number): string {
+ if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`;
+ if (n >= 1000) return `${(n / 1000).toFixed(n >= 10_000 ? 0 : 1)}k`;
+ return String(n);
+}
+
+/** Elapsed time from milliseconds: 42s, 3m05s, 2h07m. */
+export function formatDurationMs(ms: number): string {
+ const s = Math.floor(ms / 1000);
+ if (s < 60) return `${s}s`;
+ const m = Math.floor(s / 60);
+ if (m < 60) return `${m}m${String(s % 60).padStart(2, "0")}s`;
+ const h = Math.floor(m / 60);
+ return `${h}h${String(m % 60).padStart(2, "0")}m`;
+}
+
+/**
+ * Short local timestamp: "11-26 14:03:22" (month-day hour:minute:second in the UI locale).
+ * `seconds: false` drops the seconds, `year: true` prefixes a 2-digit year, and a
+ * missing value renders as `empty`.
+ */
+export function formatShortDateTime(
+ value: string | number | null | undefined,
+ { seconds = true, year = false, empty = "" }: { seconds?: boolean; year?: boolean; empty?: string } = {},
+): string {
+ if (value == null || value === "") return empty;
+ return new Date(value).toLocaleString(intlLocale, {
+ ...(year ? { year: "2-digit" as const } : {}),
+ month: "2-digit",
+ day: "2-digit",
+ hour: "2-digit",
+ minute: "2-digit",
+ ...(seconds ? { second: "2-digit" as const } : {}),
+ });
+}
diff --git a/web/src/lib/status.ts b/web/src/lib/status.ts
index 725e03353..86c248daa 100644
--- a/web/src/lib/status.ts
+++ b/web/src/lib/status.ts
@@ -128,3 +128,12 @@ export type StatusDomain = keyof typeof maps;
export function statusMeta(domain: StatusDomain, key: string): StatusMeta {
return maps[domain][key] ?? { label: t(key), tone: "neutral" };
}
+
+// HTTP response status code → text colour (5xx red, 4xx amber, 3xx blue, 2xx green).
+export function httpStatusTone(code: number): string {
+ if (code >= 500) return "text-red-500";
+ if (code >= 400) return "text-amber-500";
+ if (code >= 300) return "text-blue-500";
+ if (code >= 200) return "text-emerald-500";
+ return "text-muted-foreground";
+}