Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(frontend): time display modes and a shared clock

zchpetere0c274896f4c
diff --git a/frontend/src/components/HumanizeTs.test.tsx b/frontend/src/components/HumanizeTs.test.tsx
index dd36f89503..938933bbe7 100644
--- a/frontend/src/components/HumanizeTs.test.tsx
+++ b/frontend/src/components/HumanizeTs.test.tsx
@@ -7,8 +7,14 @@ vi.mock("react-i18next", () => ({
}));
vi.mock("@/utils", () => ({
- formatRelativeTime: (ms: number) => `relative:${ms}`,
+ // Age-based so a label that never re-renders is visibly distinguishable from
+ // one that keeps up with the clock.
+ formatQueueTime: (ms: number) => `queue:${Date.now() - ms}`,
+ nextRelativeChangeAt: (ms: number) => ms + 60_000,
+ formatCompactDateTime: (ms: number) => `compact:${ms}`,
+ formatOperationalDateTime: (ms: number) => `operational:${ms}`,
formatAbsoluteDateTime: (ms: number) => `absolute:${ms}`,
+ formatRelativeTime: (ms: number) => `relative:${ms}`,
}));
import { HumanizeTs } from "./HumanizeTs";
@@ -36,13 +42,43 @@ describe("HumanizeTs", () => {
document.body.innerHTML = "";
});
- test("renders relative time and reveals the absolute time on hover", async () => {
+ test("renders the work-queue form by default and the full time on hover", async () => {
vi.useFakeTimers();
const { container, root } = mount();
// `ts` is in seconds; both labels are computed from milliseconds.
act(() => root.render(<HumanizeTs ts={1000} />));
- expect(container.textContent).toContain("relative:1000000");
+ expect(container.textContent).toContain("queue:");
+
+ await focus(container.querySelector("span"));
+
+ const overlay = document.getElementById("bb-react-layer-overlay");
+ expect(overlay?.textContent).toContain("absolute:1000000");
+
+ act(() => root.unmount());
+ });
+
+ test("renders the compact history tier and keeps full precision on hover", async () => {
+ vi.useFakeTimers();
+ const { container, root } = mount();
+
+ act(() => root.render(<HumanizeTs mode="compact" ts={1000} />));
+ expect(container.textContent).toContain("compact:1000000");
+
+ await focus(container.querySelector("span"));
+
+ const overlay = document.getElementById("bb-react-layer-overlay");
+ expect(overlay?.textContent).toContain("absolute:1000000");
+
+ act(() => root.unmount());
+ });
+
+ test("names the timezone inline for a time the reader will act on", async () => {
+ vi.useFakeTimers();
+ const { container, root } = mount();
+
+ act(() => root.render(<HumanizeTs mode="operational" ts={1000} />));
+ expect(container.textContent).toContain("operational:1000000");
await focus(container.querySelector("span"));
@@ -52,12 +88,27 @@ describe("HumanizeTs", () => {
act(() => root.unmount());
});
+ test("inverts the tooltip on a full cell, where age is the missing reading", async () => {
+ vi.useFakeTimers();
+ const { container, root } = mount();
+
+ act(() => root.render(<HumanizeTs mode="datetime" ts={1000} />));
+ expect(container.textContent).toContain("absolute:1000000");
+
+ await focus(container.querySelector("span"));
+
+ const overlay = document.getElementById("bb-react-layer-overlay");
+ expect(overlay?.textContent).toContain("relative:1000000");
+
+ act(() => root.unmount());
+ });
+
test("omits the tooltip when tooltip is false", async () => {
vi.useFakeTimers();
const { container, root } = mount();
act(() => root.render(<HumanizeTs ts={1000} tooltip={false} />));
- expect(container.textContent).toContain("relative:1000000");
+ expect(container.textContent).toContain("queue:");
await focus(container.querySelector("span"));
@@ -67,3 +118,55 @@ describe("HumanizeTs", () => {
act(() => root.unmount());
});
});
+
+describe("HumanizeTs freshness", () => {
+ afterEach(() => {
+ vi.useRealTimers();
+ document.body.innerHTML = "";
+ });
+
+ test("keeps a mounted work-queue label up with the clock", () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
+ const { container, root } = mount();
+ const ts = Math.floor(Date.now() / 1000) - 30;
+
+ act(() => root.render(<HumanizeTs ts={ts} tooltip={false} />));
+ expect(container.textContent).toBe("queue:30000");
+
+ act(() => {
+ vi.advanceTimersByTime(60_000);
+ });
+ expect(container.textContent).toBe("queue:90000");
+
+ act(() => root.unmount());
+ });
+
+ test.each(["compact", "datetime", "operational"] as const)(
+ "puts no %s display on the shared clock",
+ (mode) => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
+ const { root } = mount();
+ const ts = Math.floor(Date.now() / 1000) - 30;
+
+ act(() => root.render(<HumanizeTs mode={mode} ts={ts} tooltip={false} />));
+ expect(vi.getTimerCount()).toBe(0);
+
+ act(() => root.unmount());
+ }
+ );
+
+ test("releases the clock when the last subscriber unmounts", () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
+ const { root } = mount();
+ const ts = Math.floor(Date.now() / 1000) - 30;
+
+ act(() => root.render(<HumanizeTs ts={ts} tooltip={false} />));
+ expect(vi.getTimerCount()).toBe(1);
+
+ act(() => root.unmount());
+ expect(vi.getTimerCount()).toBe(0);
+ });
+});
diff --git a/frontend/src/components/HumanizeTs.tsx b/frontend/src/components/HumanizeTs.tsx
index ed2dc2b1eb..1662fc5929 100644
--- a/frontend/src/components/HumanizeTs.tsx
+++ b/frontend/src/components/HumanizeTs.tsx
@@ -1,10 +1,32 @@
import { useTranslation } from "react-i18next";
import { Tooltip } from "@/components/ui/tooltip";
-import { formatAbsoluteDateTime, formatRelativeTime } from "@/utils";
+import { useNow } from "@/hooks/useNow";
+import {
+ formatAbsoluteDateTime,
+ formatCompactDateTime,
+ formatOperationalDateTime,
+ formatQueueTime,
+ formatRelativeTime,
+ nextRelativeChangeAt,
+} from "@/utils";
+
+/**
+ * Which reading a surface supports, per `docs/design/timestamp-display.md`.
+ *
+ * - `queue` — freshness-first work queues and feeds: relative age, switching to
+ * an absolute date at 30 days.
+ * - `compact` — history rows scanned to locate a record: date and time to the
+ * minute.
+ * - `operational` — a future time the reader acts on, so the timezone is named
+ * in the visible string rather than left to a hover.
+ * - `datetime` — a record whose time is the evidence: full precision inline.
+ */
+export type TimeDisplayMode = "queue" | "compact" | "operational" | "datetime";
interface HumanizeTsProps {
/** Unix timestamp in seconds. */
ts: number;
+ mode?: TimeDisplayMode;
className?: string;
/**
* Whether to reveal the absolute timestamp on hover. Defaults to true.
@@ -15,18 +37,45 @@ interface HumanizeTsProps {
tooltip?: boolean;
}
+const FORMATTERS: Record<TimeDisplayMode, (tsMs: number) => string> = {
+ queue: formatQueueTime,
+ compact: formatCompactDateTime,
+ operational: formatOperationalDateTime,
+ datetime: formatAbsoluteDateTime,
+};
+
+// Every reduced form hides the exact instant, so its tooltip restores it. The
+// full form hides nothing but the age, so its tooltip supplies that instead.
+const TOOLTIPS: Record<TimeDisplayMode, (tsMs: number) => string> = {
+ queue: formatAbsoluteDateTime,
+ compact: formatAbsoluteDateTime,
+ operational: formatAbsoluteDateTime,
+ datetime: formatRelativeTime,
+};
+
/**
- * Renders a relative timestamp ("5 minutes ago") and, by default, reveals the
- * absolute timestamp on hover. This is the single canonical way to display a
- * relative time across the app.
+ * Renders a timestamp in the form its surface calls for, and by default
+ * reveals the full date-time on hover. This is the single canonical way to
+ * display a record timestamp across the app.
*/
-export function HumanizeTs({ ts, className, tooltip = true }: HumanizeTsProps) {
+export function HumanizeTs({
+ ts,
+ mode = "queue",
+ className,
+ tooltip = true,
+}: HumanizeTsProps) {
// Subscribe to locale changes so the rendered strings update on a language switch.
useTranslation();
const tsMs = ts * 1000;
- const label = <span className={className}>{formatRelativeTime(tsMs)}</span>;
+ // Only the work-queue form ages. The absolute modes render the same string
+ // forever, so they take no place on the shared clock -- which matters on the
+ // audit log, where thousands of full cells would otherwise subscribe for a
+ // label that never moves. The formatters read the clock themselves; this
+ // call is what brings the render back around.
+ useNow(mode === "queue" ? nextRelativeChangeAt(tsMs) : undefined);
+ const label = <span className={className}>{FORMATTERS[mode](tsMs)}</span>;
if (!tooltip) {
return label;
}
- return <Tooltip content={formatAbsoluteDateTime(tsMs)}>{label}</Tooltip>;
+ return <Tooltip content={TOOLTIPS[mode](tsMs)}>{label}</Tooltip>;
}
diff --git a/frontend/src/hooks/useNow.ts b/frontend/src/hooks/useNow.ts
new file mode 100644
index 0000000000..125fcbd0ed
--- /dev/null
+++ b/frontend/src/hooks/useNow.ts
@@ -0,0 +1,76 @@
+import { useEffect, useState } from "react";
+
+/**
+ * A single clock shared by every time-varying display, replacing the
+ * per-component intervals that used to tick independently.
+ *
+ * Each subscriber declares the instant at which its own rendering could next
+ * differ, so the clock holds one timeout — set to the earliest of those — and
+ * wakes only the subscribers whose instant has arrived. A display that never
+ * changes with time subscribes to nothing and costs nothing. This is the
+ * scheduling behavior of GitHub's `relative-time` element.
+ */
+type Subscriber = {
+ changesAtMs: number;
+ notify: () => void;
+};
+
+const subscribers = new Set<Subscriber>();
+let timer: ReturnType<typeof setTimeout> | undefined;
+
+// A boundary computed as already past would otherwise spin the event loop.
+const MIN_DELAY_MS = 16;
+
+function reschedule(): void {
+ if (timer !== undefined) {
+ clearTimeout(timer);
+ timer = undefined;
+ }
+ let earliest = Number.POSITIVE_INFINITY;
+ for (const subscriber of subscribers) {
+ earliest = Math.min(earliest, subscriber.changesAtMs);
+ }
+ if (!Number.isFinite(earliest)) {
+ return;
+ }
+ timer = setTimeout(
+ () => {
+ timer = undefined;
+ const nowMs = Date.now();
+ for (const subscriber of [...subscribers]) {
+ if (subscriber.changesAtMs <= nowMs) {
+ subscriber.notify();
+ }
+ }
+ reschedule();
+ },
+ Math.max(earliest - Date.now(), MIN_DELAY_MS)
+ );
+}
+
+/**
+ * Re-renders the caller once `changesAtMs` arrives, and returns the current
+ * time. Pass `undefined` for a display that does not vary with time — it then
+ * holds no subscription.
+ */
+export function useNow(changesAtMs: number | undefined): number {
+ const [nowMs, setNowMs] = useState(() => Date.now());
+
+ useEffect(() => {
+ if (changesAtMs === undefined || !Number.isFinite(changesAtMs)) {
+ return;
+ }
+ const subscriber: Subscriber = {
+ changesAtMs,
+ notify: () => setNowMs(Date.now()),
+ };
+ subscribers.add(subscriber);
+ reschedule();
+ return () => {
+ subscribers.delete(subscriber);
+ reschedule();
+ };
+ }, [changesAtMs]);
+
+ return nowMs;
+}
diff --git a/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx b/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx
index dfea49493d..1815bb6eb2 100644
--- a/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx
+++ b/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx
@@ -68,8 +68,12 @@ const mocks = vi.hoisted(() => {
instanceV1SupportsSequence: vi.fn(() => false),
instanceV1SupportsTrigger: vi.fn(() => false),
bytesToString: vi.fn((size: number) => `${size} B`),
+ formatQueueTime: vi.fn(() => "5 minutes ago"),
+ formatCompactDateTime: vi.fn(() => "Jan 1, 1970, 12:00 AM"),
+ formatOperationalDateTime: vi.fn(() => "Jan 1, 1970, 12:00 AM UTC"),
formatRelativeTime: vi.fn(() => "5 minutes ago"),
formatAbsoluteDateTime: vi.fn(() => "Jan 1, 1970, 12:00:01 AM UTC"),
+ nextRelativeChangeAt: vi.fn(() => Number.POSITIVE_INFINITY),
};
});
@@ -148,8 +152,12 @@ vi.mock("@/utils", () => ({
getDatabaseEngine: mocks.getDatabaseEngine,
getInstanceResource: mocks.getInstanceResource,
getDatabaseProject: mocks.getDatabaseProject,
+ formatQueueTime: mocks.formatQueueTime,
+ formatCompactDateTime: mocks.formatCompactDateTime,
+ formatOperationalDateTime: mocks.formatOperationalDateTime,
formatRelativeTime: mocks.formatRelativeTime,
formatAbsoluteDateTime: mocks.formatAbsoluteDateTime,
+ nextRelativeChangeAt: mocks.nextRelativeChangeAt,
hasIndexSizeProperty: mocks.hasIndexSizeProperty,
isDev: mocks.isDev,
hasProjectPermissionV2: mocks.hasProjectPermissionV2,
@@ -386,6 +394,8 @@ beforeEach(async () => {
mocks.instanceV1SupportsSequence.mockReturnValue(false);
mocks.bytesToString.mockReset();
mocks.bytesToString.mockImplementation((size: number) => `${size} B`);
+ mocks.formatQueueTime.mockReset();
+ mocks.formatQueueTime.mockReturnValue("5 minutes ago");
mocks.formatRelativeTime.mockReset();
mocks.formatRelativeTime.mockReturnValue("5 minutes ago");
mocks.dbSchemaStore.mockReset();
diff --git a/frontend/src/utils/datetime.test.ts b/frontend/src/utils/datetime.test.ts
index 1aa16defee..ed9a3739e8 100644
--- a/frontend/src/utils/datetime.test.ts
+++ b/frontend/src/utils/datetime.test.ts
@@ -1,16 +1,32 @@
// @vitest-environment node
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+// Absolute renderings below are asserted against literals from the design doc;
+// the fixed Asia/Shanghai zone they assume is pinned in vitest.config.ts.
+const i18n = vi.hoisted(() => ({ language: "en-US" }));
+
vi.mock("@/lib/i18n", () => ({
- default: {
- language: "en-US",
- },
+ default: i18n,
}));
+const withLocale = (language: string, run: () => void) => {
+ const previous = i18n.language;
+ i18n.language = language;
+ try {
+ run();
+ } finally {
+ i18n.language = previous;
+ }
+};
+
import {
formatAbsoluteDate,
formatAbsoluteDateTime,
+ formatCompactDateTime,
+ formatOperationalDateTime,
+ formatQueueTime,
formatRelativeTime,
+ nextRelativeChangeAt,
RELATIVE_THRESHOLD_MS,
} from "./datetime";
@@ -97,7 +113,7 @@ describe("formatAbsoluteDate", () => {
});
});
-describe("humanizeTs", () => {
+describe("formatQueueTime", () => {
beforeEach(() => {
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
@@ -107,19 +123,102 @@ describe("humanizeTs", () => {
vi.useRealTimers();
});
- test("returns relative time for recent timestamps", async () => {
- const { humanizeTs } = await import("./util");
- const recentTs = Math.floor(Date.now() / 1000) - 3600; // 1 hour ago
- const result = humanizeTs(recentTs);
- expect(result).toMatch(/hour/);
+ test("reads as relative age inside the 30-day window", () => {
+ expect(formatQueueTime(Date.now() - 6 * 86_400_000)).toBe("6 days ago");
+ });
+
+ test("still reads as relative age one day short of the threshold", () => {
+ expect(formatQueueTime(Date.now() - 29 * 86_400_000)).toBe("29 days ago");
+ });
+
+ test("switches to an absolute date at the threshold", () => {
+ expect(formatQueueTime(Date.now() - RELATIVE_THRESHOLD_MS)).toBe("Jan 31");
+ });
+
+ test("keeps the year on a date from another year", () => {
+ expect(formatQueueTime(Date.now() - 90 * 86_400_000)).toBe("Dec 2, 2025");
+ });
+
+ test("measures a future timestamp by the same threshold", () => {
+ expect(formatQueueTime(Date.now() + 2 * 86_400_000)).toBe("in 2 days");
+ expect(formatQueueTime(Date.now() + 40 * 86_400_000)).toBe("Apr 11");
+ });
+
+ test("renders both branches in the active locale", () => {
+ withLocale("zh-CN", () => {
+ expect(formatQueueTime(Date.now() - 6 * 86_400_000)).toBe("6天前");
+ expect(formatQueueTime(Date.now() - RELATIVE_THRESHOLD_MS)).toBe(
+ "1月31日"
+ );
+ });
+ });
+});
+
+describe("formatCompactDateTime", () => {
+ const ts = new Date("2026-08-26T06:03:22Z").getTime();
+
+ test("drops the seconds and the timezone a history row does not need", () => {
+ expect(formatCompactDateTime(ts)).toBe("Aug 26, 2026, 2:03 PM");
+ });
+
+ test("renders in the active locale", () => {
+ withLocale("zh-CN", () => {
+ expect(formatCompactDateTime(ts)).toBe("2026年8月26日 14:03");
+ });
+ });
+});
+
+describe("formatOperationalDateTime", () => {
+ // The value a reader is about to act on: 9am Shanghai, with a sub-minute
+ // tail of the kind a `now() + N days` expiration preset writes.
+ const ts = new Date("2026-09-15T01:00:22Z").getTime();
+
+ test("names the timezone in the visible string", () => {
+ expect(formatOperationalDateTime(ts)).toBe("Sep 15, 2026, 9:00 AM GMT+8");
+ });
+
+ test("floors to the minute rather than showing the seconds", () => {
+ expect(formatOperationalDateTime(ts)).toBe(
+ formatOperationalDateTime(new Date("2026-09-15T01:00:00Z").getTime())
+ );
+ });
+
+ test("renders in the active locale", () => {
+ withLocale("zh-CN", () => {
+ expect(formatOperationalDateTime(ts)).toBe("2026年9月15日 GMT+8 09:00");
+ });
+ });
+});
+
+describe("nextRelativeChangeAt", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ test("tracks the second while the label still counts seconds", () => {
+ expect(nextRelativeChangeAt(Date.now() - 30_000)).toBe(Date.now() + 1_000);
+ });
+
+ test("waits for the turn of the minute, not a fixed minute from now", () => {
+ expect(nextRelativeChangeAt(Date.now() - 90_000)).toBe(Date.now() + 30_000);
+ });
+
+ test("counts a future timestamp down to the same boundary", () => {
+ expect(nextRelativeChangeAt(Date.now() + 90_000)).toBe(Date.now() + 30_000);
+ });
+
+ test("wakes at the 30-day switch rather than at the next day", () => {
+ const ts = Date.now() - (RELATIVE_THRESHOLD_MS - 3_600_000);
+ expect(nextRelativeChangeAt(ts)).toBe(Date.now() + 3_600_000);
});
- test("returns absolute date for timestamps >30 days old", async () => {
- const { humanizeTs } = await import("./util");
- const oldTs =
- Math.floor(Date.now() / 1000) - RELATIVE_THRESHOLD_MS / 1000 - 86400; // 31 days ago
- const result = humanizeTs(oldTs);
- expect(result).not.toMatch(/ago/);
- expect(result).toContain("Jan");
+ test("never wakes for a label already showing an absolute date", () => {
+ const ts = Date.now() - RELATIVE_THRESHOLD_MS - 86_400_000;
+ expect(nextRelativeChangeAt(ts)).toBe(Number.POSITIVE_INFINITY);
});
});
diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts
index 53c15c3cb9..ef772fb697 100644
--- a/frontend/src/utils/datetime.ts
+++ b/frontend/src/utils/datetime.ts
@@ -68,3 +68,61 @@ export function formatAbsoluteDate(timestampMs: number): string {
year: "numeric",
}).format(date);
}
+
+export function formatQueueTime(timestampMs: number): string {
+ if (Math.abs(Date.now() - timestampMs) >= RELATIVE_THRESHOLD_MS) {
+ return formatAbsoluteDate(timestampMs);
+ }
+ return formatRelativeTime(timestampMs);
+}
+
+export function formatCompactDateTime(timestampMs: number): string {
+ return new Intl.DateTimeFormat(getActiveLocale(), {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ }).format(new Date(timestampMs));
+}
+
+export function formatOperationalDateTime(timestampMs: number): string {
+ return new Intl.DateTimeFormat(getActiveLocale(), {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ timeZoneName: "short",
+ }).format(new Date(timestampMs));
+}
+
+/**
+ * The instant at which `formatQueueTime` would next render this timestamp
+ * differently, or `Infinity` once it has settled on an absolute date.
+ *
+ * Buckets are measured from the timestamp, not from the wall clock: a row
+ * created at 10:00:30 turns over to "1 minute ago" at 10:01:30. A display that
+ * woke on a fixed cadence instead would lag by up to a whole bucket.
+ */
+export function nextRelativeChangeAt(timestampMs: number): number {
+ const nowMs = Date.now();
+ const ageMs = Math.abs(nowMs - timestampMs);
+ if (ageMs >= RELATIVE_THRESHOLD_MS) {
+ return Number.POSITIVE_INFINITY;
+ }
+ const bucketMs =
+ ageMs < 60_000
+ ? 1_000
+ : ageMs < 3_600_000
+ ? 60_000
+ : ageMs < 86_400_000
+ ? 3_600_000
+ : 86_400_000;
+ // A past timestamp grows into the next bucket; a future one shrinks back
+ // into the previous one.
+ const intoBucketMs = ageMs % bucketMs;
+ const untilBucketEdgeMs =
+ nowMs >= timestampMs ? bucketMs - intoBucketMs : intoBucketMs || bucketMs;
+ return nowMs + Math.min(untilBucketEdgeMs, RELATIVE_THRESHOLD_MS - ageMs);
+}
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index a42de584b7..918f4ae292 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -7,11 +7,6 @@ import utc from "dayjs/plugin/utc";
import DOMPurify from "dompurify";
import { escape as escapeHtml, escapeRegExp, round } from "lodash-es";
import semver from "semver";
-import {
- formatAbsoluteDate,
- formatRelativeTime,
- RELATIVE_THRESHOLD_MS,
-} from "./datetime";
dayjs.extend(dayOfYear);
dayjs.extend(duration);
@@ -26,15 +21,6 @@ export function isRelease(): boolean {
return import.meta.env.PROD;
}
-export function humanizeTs(ts: number): string {
- const timestampMs = ts * 1000;
- const diff = Math.abs(Date.now() - timestampMs);
- if (diff > RELATIVE_THRESHOLD_MS) {
- return formatAbsoluteDate(timestampMs);
- }
- return formatRelativeTime(timestampMs);
-}
-
export const humanizeDurationV1 = (duration: Duration | undefined) => {
if (!duration) return "-";
const { seconds, nanos } = duration;
diff --git a/frontend/src/utils/v1/common.ts b/frontend/src/utils/v1/common.ts
index d261c67704..54dcb26ed9 100644
--- a/frontend/src/utils/v1/common.ts
+++ b/frontend/src/utils/v1/common.ts
@@ -1,5 +1,4 @@
import { isEqual, snakeCase } from "lodash-es";
-import { humanizeTs } from "../util";
export const calcUpdateMask = (
a: Record<string, unknown>,
@@ -20,10 +19,6 @@ export const calcUpdateMask = (
return toSnakeCase ? keys.map(snakeCase) : keys;
};
-export const humanizeDate = (date: Date | undefined) => {
- return humanizeTs(Math.floor((date?.getTime() ?? 0) / 1000));
-};
-
// The list of supported encodings.
// Reference: https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
export const ENCODINGS = [
diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts
index fc24aad9c5..53d71cec6c 100644
--- a/frontend/vitest.config.ts
+++ b/frontend/vitest.config.ts
@@ -2,6 +2,14 @@ import { fileURLToPath } from "node:url";
import { configDefaults, defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "./vite.config";
+// Anything rendering a wall-clock time reads the process timezone, so without
+// a fixed one those assertions pass or fail by where the runner sits. Set it
+// here: this config is evaluated in the main process before any worker starts,
+// and assigning TZ resets Node's zone cache process-wide. A worker setting it
+// for itself would not -- the threads pool shares one process. Asia/Shanghai
+// rather than UTC so a missing zone conversion cannot pass on a zero offset.
+process.env.TZ = "Asia/Shanghai";
+
export default mergeConfig(
viteConfig,
defineConfig({