Skip to content

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

feat(frontend): classify every timestamp surface by its reading

zchpeter88201a006dc9
diff --git a/docs/design/timestamp-display.md b/docs/design/timestamp-display.md
index 8bb3dd80f6..3d41216df0 100644
--- a/docs/design/timestamp-display.md
+++ b/docs/design/timestamp-display.md
@@ -99,7 +99,7 @@ GitHub behavior).
The history views — database changelog, revision table, task-run history — flip to **absolute
date-time always**, consistent with the audit log. They are records of execution, not queues.
-**D5 (proposed) — Operational times: absolute with explicit timezone, minute precision.**
+**D5 — Operational times: absolute with explicit timezone, minute precision.**
Wall-clock renderings of scheduled rollouts and expirations show the absolute date-time with the
short timezone name in the visible string: "Sep 15, 2026, 9:00 AM GMT+8". Two refinements from
review: (a) preset-written expirations (`now() + N days`) carry real sub-minute tails, so a
@@ -107,8 +107,8 @@ minute display floors the enforced cutoff by ≤59s — in the safe direction, e
tooltip; alternatives are keeping seconds for expirations or normalizing preset writes (a
write-path change, out of scope). (b) The rule targets wall-clock strings only — a pure countdown
("expires in 3h20m") cannot be misread across timezones and stays permitted with the D6 tooltip.
-Driven by BYT-10023 — see Operational times below. Proposed, pending confirmation; the pickers
-that write these values are deferred.
+Driven by BYT-10023 — see Operational times below. The pickers that write these values are
+deferred.
**D6 — Full date-time tooltip on every reduced display.**
Any timestamp that does not show the full form — relative, date-only after the switch, or the
@@ -117,7 +117,7 @@ tooltip. This is the universal escape hatch that keeps every reduced cell recove
a context that cannot host a tooltip — i18n-interpolated strings, exports, titles — carries the
full-precision string itself.
-**D7 (proposed) — History views carry two precision tiers.**
+**D7 — History views carry two precision tiers.**
*A history row orients; a history record testifies.* Full precision (seconds + timezone,
`formatAbsoluteDateTime`) where the time itself is the evidence: the audit log — exportable, and
the export must preserve the same instant at no less precision than the screen (the export writes
@@ -226,7 +226,7 @@ their list views render relative. D4 makes each list agree with its own detail v
- All strings locale-aware via `Intl` with the active i18n locale — no hardcoded formats, no new
locale keys needed.
-**History views**: absolute always; precision comes in two tiers under D7 (assignment proposed):
+**History views**: absolute always; precision comes in two tiers under D7:
| History-view occurrence | Space | Tier |
|---|---|---|
@@ -305,24 +305,25 @@ no seconds per D5. Relative age may accompany it in the tooltip.
part of the complaint survives. Mitigation: tooltip; escalation path if it recurs is lowering the
threshold (D3) or a GitLab-style preference (D1 rejected-for-now).
-## Open items awaiting ruling
-
-Confirmed since the first draft: release list = work queue; comment/activity timelines = feed;
-D6 (full date-time tooltip on every reduced display). Still open:
-
-1. **D7 tier assignment/format** — compact (date + hh:mm) vs full for the embedded history lists.
- Mockups of both options exist for the changelog table and the 704px task-run sheet;
- recommendation is compact per the orient/testify principle.
-2. **D5 precision refinement** — operational times at minute precision (no seconds). Pickers
- write minutes, but day/second-count presets write `now() + offset` with sub-minute tails, so
- minute display floors the enforced cutoff by ≤59s (safe direction; full value in the tooltip).
- Alternatives: full seconds for expiration values, or normalizing preset writes to the minute
- (write-path change, out of scope here).
-3. Scheduled rollout pill shows the operational format inline ("Sep 15, 2026, 9:00 AM GMT+8");
- relative age moves to the tooltip.
-4. The bare-format expiration displays are fixed in this effort rather than filed as follow-up
- cleanup: masking exemption and role-grant details adopt the operational mode; the member
- preview — an i18n-interpolated string — gets the full-precision string per the corollary
- (or the `Trans`-slot refactor if minute display is preferred there).
-5. Tooltip on *full* cells may show the relative age (inverse tooltip). Alternative: repeat the
- full string (GitHub parity).
+## Resolutions
+
+Every item above is decided and implemented. D5 and D7 landed as recommended: operational times at
+minute precision, compact tier on the embedded history lists. The scheduled rollout pill shows the
+operational format inline, and the bare-format expirations — masking exemption, role-grant detail —
+adopt it too, while the i18n-interpolated member preview carries the full-precision string. Three
+points where the implementation had to choose:
+
+1. **The relative age on a full cell** (previously open item 5) is rendered as a component the
+ tooltip mounts only when it opens, not as a string computed with the row. A string would freeze
+ at whatever the row last rendered, which the staleness rule forbids; this way a closed tooltip
+ holds no place on the shared clock and an open one keeps counting.
+2. **The operational tooltip carries the full date-time, not the relative age.** D6 owns that slot,
+ and the pill's reduced minute precision is what needs recovering.
+3. **The zh renderings put the timezone before the time** — "2026年9月15日 GMT+8 09:00", where the
+ examples above show it trailing. That is ICU's pattern for the locale; the strings come from
+ `Intl` rather than being assembled, so the locale's own order wins.
+
+The staleness rule is enforced by `useNow`, a single shared clock: subscribers declare the instant
+their rendering next changes rather than a cadence, since the relative buckets turn over relative
+to the timestamp, not the wall clock. It replaced the ad-hoc interval behind the plan-detail
+created time and covers the SQL-editor grant countdown, which had none.
diff --git a/frontend/src/components/HumanizeTs.test.tsx b/frontend/src/components/HumanizeTs.test.tsx
index 938933bbe7..fa273e6d6a 100644
--- a/frontend/src/components/HumanizeTs.test.tsx
+++ b/frontend/src/components/HumanizeTs.test.tsx
@@ -6,7 +6,7 @@ vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (k: string) => k, i18n: { language: "en" } }),
}));
-vi.mock("@/utils", () => ({
+vi.mock("@/utils/datetime", () => ({
// 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}`,
@@ -14,7 +14,7 @@ vi.mock("@/utils", () => ({
formatCompactDateTime: (ms: number) => `compact:${ms}`,
formatOperationalDateTime: (ms: number) => `operational:${ms}`,
formatAbsoluteDateTime: (ms: number) => `absolute:${ms}`,
- formatRelativeTime: (ms: number) => `relative:${ms}`,
+ formatRelativeTime: (ms: number) => `relative:${Date.now() - ms}`,
}));
import { HumanizeTs } from "./HumanizeTs";
@@ -88,17 +88,27 @@ describe("HumanizeTs", () => {
act(() => root.unmount());
});
- test("inverts the tooltip on a full cell, where age is the missing reading", async () => {
+ test("offers the age on a full cell, which is the reading its label lacks", async () => {
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 mode="datetime" ts={1000} />));
- expect(container.textContent).toContain("absolute:1000000");
+ act(() => root.render(<HumanizeTs mode="datetime" ts={ts} />));
+ expect(container.textContent).toContain("absolute:");
await focus(container.querySelector("span"));
const overlay = document.getElementById("bb-react-layer-overlay");
- expect(overlay?.textContent).toContain("relative:1000000");
+ // The tooltip opens 100ms after focus, which the age already reflects.
+ expect(overlay?.textContent).toContain("relative:30100");
+
+ // An age that froze at whatever the row last rendered would be worse than
+ // no age at all, so the open tooltip holds its own place on the clock.
+ act(() => {
+ vi.advanceTimersByTime(60_000);
+ });
+ expect(overlay?.textContent).toContain("relative:90100");
act(() => root.unmount());
});
diff --git a/frontend/src/components/HumanizeTs.tsx b/frontend/src/components/HumanizeTs.tsx
index 1662fc5929..fdea0c2672 100644
--- a/frontend/src/components/HumanizeTs.tsx
+++ b/frontend/src/components/HumanizeTs.tsx
@@ -8,7 +8,7 @@ import {
formatQueueTime,
formatRelativeTime,
nextRelativeChangeAt,
-} from "@/utils";
+} from "@/utils/datetime";
/**
* Which reading a surface supports, per `docs/design/timestamp-display.md`.
@@ -44,14 +44,17 @@ const FORMATTERS: Record<TimeDisplayMode, (tsMs: number) => string> = {
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,
-};
+/**
+ * The age of a full-precision cell, which is the one reading its label lacks.
+ *
+ * A component rather than a string because the tooltip mounts it only while
+ * open: closed, it costs nothing and holds no place on the shared clock; open,
+ * it keeps counting rather than freezing at whatever the row last rendered.
+ */
+function RelativeAge({ tsMs }: { tsMs: number }) {
+ useNow(nextRelativeChangeAt(tsMs));
+ return <>{formatRelativeTime(tsMs)}</>;
+}
/**
* Renders a timestamp in the form its surface calls for, and by default
@@ -77,5 +80,12 @@ export function HumanizeTs({
if (!tooltip) {
return label;
}
- return <Tooltip content={TOOLTIPS[mode](tsMs)}>{label}</Tooltip>;
+ // Every reduced form hides the exact instant, so its tooltip restores it.
+ const content =
+ mode === "datetime" ? (
+ <RelativeAge tsMs={tsMs} />
+ ) : (
+ formatAbsoluteDateTime(tsMs)
+ );
+ return <Tooltip content={content}>{label}</Tooltip>;
}
diff --git a/frontend/src/components/IAMRemindDialog.tsx b/frontend/src/components/IAMRemindDialog.tsx
index 00b9db13d2..75d37d6280 100644
--- a/frontend/src/components/IAMRemindDialog.tsx
+++ b/frontend/src/components/IAMRemindDialog.tsx
@@ -5,6 +5,7 @@ import {
useCurrentRoute,
useNavigate,
} from "@/app/router";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
@@ -16,7 +17,7 @@ import {
writeJson,
} from "@/stores/app/utils";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import { displayRoleTitle, formatAbsoluteDateTime } from "@/utils";
+import { displayRoleTitle } from "@/utils";
import { storageKeyIamRemind, workspaceCacheScope } from "@/utils/storage-keys";
interface IAMRemindDialogProps {
@@ -106,7 +107,10 @@ export function IAMRemindDialog({ project }: IAMRemindDialogProps) {
<li key={role.name}>
{displayRoleTitle(role.name)}:{" "}
<span className="text-error">
- {formatAbsoluteDateTime(expiration.getTime())}
+ <HumanizeTs
+ mode="operational"
+ ts={expiration.getTime() / 1000}
+ />
</span>
</li>
))}
diff --git a/frontend/src/components/plan-check/PlanCheckSection.tsx b/frontend/src/components/plan-check/PlanCheckSection.tsx
index c8a65bd1b1..43dfb82332 100644
--- a/frontend/src/components/plan-check/PlanCheckSection.tsx
+++ b/frontend/src/components/plan-check/PlanCheckSection.tsx
@@ -11,6 +11,7 @@ import {
} from "lucide-react";
import { type ReactNode, useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { Button } from "@/components/ui/button";
import {
Sheet,
@@ -359,11 +360,14 @@ export function PlanCheckResultsDrawer({
</Tooltip>
)}
{group.createTime && (
- <span className="text-xs text-control-light">
- {getDateForPbTimestampProtoEs(
- group.createTime
- )?.toLocaleString() ?? ""}
- </span>
+ <HumanizeTs
+ className="text-xs text-control-light"
+ ts={
+ (getDateForPbTimestampProtoEs(
+ group.createTime
+ )?.getTime() ?? 0) / 1000
+ }
+ />
)}
</div>
</div>
diff --git a/frontend/src/components/release/ReleaseInfoCard.tsx b/frontend/src/components/release/ReleaseInfoCard.tsx
index aec99750b7..bc023cc2e3 100644
--- a/frontend/src/components/release/ReleaseInfoCard.tsx
+++ b/frontend/src/components/release/ReleaseInfoCard.tsx
@@ -1,9 +1,9 @@
-import dayjs from "dayjs";
import type { TFunction } from "i18next";
import { ExternalLink, Loader2, Package } from "lucide-react";
import type { ReactNode } from "react";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { RouterLink } from "@/components/RouterLink";
import { cn } from "@/lib/utils";
import { State, VCSType } from "@/types/proto-es/v1/common_pb";
@@ -96,10 +96,8 @@ function NotFoundBlock() {
function ReleaseBlock({ release }: Readonly<{ release: Release }>) {
const { t } = useTranslation();
const displayedFiles = release.files.slice(0, MAX_DISPLAYED_RELEASE_FILES);
- const createdTime = release.createTime
- ? dayjs(getDateForPbTimestampProtoEs(release.createTime)).format(
- "YYYY-MM-DD HH:mm:ss"
- )
+ const createdTimeMs = release.createTime
+ ? getDateForPbTimestampProtoEs(release.createTime)?.getTime()
: undefined;
return (
@@ -171,8 +169,11 @@ function ReleaseBlock({ release }: Readonly<{ release: Release }>) {
</div>
)}
- {createdTime && (
- <div className="text-xs text-control-light">{createdTime}</div>
+ {createdTimeMs !== undefined && (
+ <HumanizeTs
+ className="text-xs text-control-light"
+ ts={createdTimeMs / 1000}
+ />
)}
</div>
</div>
diff --git a/frontend/src/components/task-run-log/SectionContent.tsx b/frontend/src/components/task-run-log/SectionContent.tsx
index 5a8291f484..aef71e8c43 100644
--- a/frontend/src/components/task-run-log/SectionContent.tsx
+++ b/frontend/src/components/task-run-log/SectionContent.tsx
@@ -1,7 +1,9 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
+import { Tooltip } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
+import { formatAbsoluteDateTime } from "@/utils";
import type { Section } from "./types";
const ITEM_HEIGHT = 20;
@@ -49,9 +51,17 @@ export function SectionContent({
<span className="w-6 shrink-0 text-right text-control-placeholder tabular-nums">
{index + 1}
</span>
- <span className="shrink-0 text-control-placeholder tabular-nums">
- {item.time}
- </span>
+ {item.timeMs > 0 ? (
+ <Tooltip content={formatAbsoluteDateTime(item.timeMs)}>
+ <span className="shrink-0 text-control-placeholder tabular-nums">
+ {item.time}
+ </span>
+ </Tooltip>
+ ) : (
+ <span className="shrink-0 text-control-placeholder tabular-nums">
+ {item.time}
+ </span>
+ )}
{item.relativeTime ? (
<span className="shrink-0 text-control-placeholder tabular-nums">
{item.relativeTime}
diff --git a/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx b/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
index bef191eda0..1692298acf 100644
--- a/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
+++ b/frontend/src/components/task-run-log/TaskRunLogViewer.test.tsx
@@ -18,6 +18,7 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
useTranslation: () => ({
t: (key: string, options?: Record<string, unknown> | number | string) => {
if (key === "task-run.log-viewer.summary" && options) {
@@ -298,6 +299,7 @@ describe("TaskRunLogViewer", () => {
items: Array.from({ length: 60 }, (_, index) => ({
key: `item-${index}`,
time: `12:00:${String(index).padStart(2, "0")}.000`,
+ timeMs: new Date("2026-03-02T12:00:00Z").getTime() + index * 1000,
relativeTime: "",
levelIndicator: "✓",
levelClass: "text-green-600",
diff --git a/frontend/src/components/task-run-log/model.ts b/frontend/src/components/task-run-log/model.ts
index c1745e11f3..fc7bbd4974 100644
--- a/frontend/src/components/task-run-log/model.ts
+++ b/frontend/src/components/task-run-log/model.ts
@@ -480,6 +480,7 @@ const buildDisplayItems = (
return {
key: `${idPrefix ?? "section"}-${groupIndex}-${entryIndex}`,
time: formatTime(entry.logTime),
+ timeMs: entryTime,
relativeTime: relativeMs > 0 ? formatRelativeTime(relativeMs) : "",
levelIndicator: entryHasError ? "\u2717" : "\u2713",
levelClass: entryHasError ? "text-error" : "text-success",
diff --git a/frontend/src/components/task-run-log/types.ts b/frontend/src/components/task-run-log/types.ts
index 0e8ef30675..3947d73df1 100644
--- a/frontend/src/components/task-run-log/types.ts
+++ b/frontend/src/components/task-run-log/types.ts
@@ -8,7 +8,10 @@ export type SectionStatus = "success" | "error" | "running" | "pending";
export interface DisplayItem {
key: string;
+ /** Dense time-of-day; the date lives on the run header and in the tooltip. */
time: string;
+ /** Backs that tooltip. 0 when the entry carries no timestamp. */
+ timeMs: number;
relativeTime: string;
levelIndicator: string;
levelClass: string;
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
index 6346bfd7ed..c7c42b299c 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
@@ -30,6 +30,7 @@ vi.mock("@/components/DatabaseTargetDisplay", () => ({
}));
vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
useTranslation: mocks.useTranslation,
}));
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
index 12469d7f08..d6780bcad4 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.tsx
@@ -4,9 +4,11 @@ import { RouterLink } from "@/components/RouterLink";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Tooltip } from "@/components/ui/tooltip";
+import { useNow } from "@/hooks/useNow";
import { cn } from "@/lib/utils";
import type { AccessGrant } from "@/types/proto-es/v1/access_grant_service_pb";
import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
+import { formatAbsoluteDateTime } from "@/utils";
import {
getAccessGrantDisplayStatus,
getAccessGrantDisplayStatusText,
@@ -15,6 +17,9 @@ import {
getAccessGrantStatusTagType,
} from "@/utils/accessGrant";
+const MINUTE_MS = 60_000;
+const DAY_MS = 24 * 60 * MINUTE_MS;
+
function mapTagTypeToBadgeVariant(
tagType: "success" | "warning" | "error" | "default"
): "default" | "secondary" | "destructive" | "warning" | "success" {
@@ -52,6 +57,20 @@ export function AccessGrantItem({
const statusTagType = getAccessGrantStatusTagType(displayStatus);
const badgeVariant = mapTagTypeToBadgeVariant(statusTagType);
+ // A countdown that stops counting is worse than no countdown, so hold a place
+ // on the shared clock until the grant has lapsed: at the minute while the
+ // remaining time is shown as one, and otherwise at the moment the display
+ // turns from an absolute time into a countdown.
+ useNow(
+ (() => {
+ if (expireTimeMs === undefined || isExpired) return undefined;
+ const remainingMs = expireTimeMs - Date.now();
+ if (remainingMs <= 0) return undefined;
+ if (remainingMs > DAY_MS) return expireTimeMs - DAY_MS;
+ return Date.now() + (remainingMs % MINUTE_MS || MINUTE_MS);
+ })()
+ );
+
const expirationText = (() => {
if (displayStatus !== "ACTIVE" && displayStatus !== "EXPIRED") return;
const info = getAccessGrantExpirationText(grant);
@@ -142,11 +161,18 @@ export function AccessGrantItem({
</Badge>
)}
</div>
- {expirationText && (
- <span className="text-xs text-control-placeholder shrink-0">
- {expirationText}
- </span>
- )}
+ {expirationText &&
+ (expireTimeMs !== undefined ? (
+ <Tooltip content={formatAbsoluteDateTime(expireTimeMs)}>
+ <span className="text-xs text-control-placeholder shrink-0">
+ {expirationText}
+ </span>
+ </Tooltip>
+ ) : (
+ <span className="text-xs text-control-placeholder shrink-0">
+ {expirationText}
+ </span>
+ ))}
</div>
<Tooltip
diff --git a/frontend/src/modules/sql-editor/components/HistoryPane.test.tsx b/frontend/src/modules/sql-editor/components/HistoryPane.test.tsx
index d90fd34cac..62a2d975ca 100644
--- a/frontend/src/modules/sql-editor/components/HistoryPane.test.tsx
+++ b/frontend/src/modules/sql-editor/components/HistoryPane.test.tsx
@@ -35,6 +35,7 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
useTranslation: mocks.useTranslation,
}));
diff --git a/frontend/src/modules/sql-editor/components/HistoryPane.tsx b/frontend/src/modules/sql-editor/components/HistoryPane.tsx
index c281ce18ac..b1029ed7cd 100644
--- a/frontend/src/modules/sql-editor/components/HistoryPane.tsx
+++ b/frontend/src/modules/sql-editor/components/HistoryPane.tsx
@@ -1,4 +1,3 @@
-import dayjs from "dayjs";
import { Copy, Link2, Loader2, X } from "lucide-react";
import {
useCallback,
@@ -12,6 +11,7 @@ import { useTranslation } from "react-i18next";
import { router } from "@/app/router";
import { SQL_EDITOR_QUERY_HISTORY_MODULE } from "@/app/router/handles";
import { HighlightLabelText } from "@/components/HighlightLabelText";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { Button } from "@/components/ui/button";
import { writeTextToClipboard } from "@/lib/clipboard";
import { cn } from "@/lib/utils";
@@ -29,7 +29,11 @@ import {
import { useAppStore } from "@/stores/app";
import { DEBOUNCE_SEARCH_DELAY, getDateForPbTimestampProtoEs } from "@/types";
import type { QueryHistory } from "@/types/proto-es/v1/query_history_service_pb";
-import { extractProjectResourceName, extractQueryHistoryUID } from "@/utils";
+import {
+ extractProjectResourceName,
+ extractQueryHistoryUID,
+ formatAbsoluteDateTime,
+} from "@/utils";
import { HistorySearchInput } from "./HistorySearchInput";
/**
@@ -117,9 +121,10 @@ export function HistoryPane() {
[resetPageToken, historyQuery]
);
+ // Feeds a tab title, which cannot host a tooltip, so it stays full precision.
const titleOfQueryHistory = (h: QueryHistory) =>
- dayjs(getDateForPbTimestampProtoEs(h.createTime)).format(
- "YYYY-MM-DD HH:mm:ss"
+ formatAbsoluteDateTime(
+ (getDateForPbTimestampProtoEs(h.createTime) as Date).getTime()
);
const handleHistoryClick = async (history: QueryHistory) => {
@@ -201,9 +206,15 @@ export function HistoryPane() {
>
<div className="w-full flex flex-row justify-between items-center">
<div className="flex items-start gap-x-1">
- <span className="text-xs text-control-placeholder">
- {titleOfQueryHistory(history)}
- </span>
+ <HumanizeTs
+ className="text-xs text-control-placeholder"
+ mode="compact"
+ ts={
+ (
+ getDateForPbTimestampProtoEs(history.createTime) as Date
+ ).getTime() / 1000
+ }
+ />
</div>
<div className="flex items-center gap-x-1">
<Button
diff --git a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
index 2a2c6c5ba2..7111b38e33 100644
--- a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
+++ b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
@@ -1,4 +1,3 @@
-import dayjs from "dayjs";
import { debounce, omit } from "lodash-es";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -50,6 +49,7 @@ import {
extractInstanceResourceName,
extractProjectResourceName,
extractSavedQueryID,
+ formatAbsoluteDateTime,
generateSimpleSelectAllStatement,
getDatabaseEngine,
getSheetStatement,
@@ -411,9 +411,9 @@ export function SQLEditorRouteShell() {
}
}
- const title = `Query history at ${dayjs(
- getDateForPbTimestampProtoEs(history.createTime)
- ).format("YYYY-MM-DD HH:mm:ss")}`;
+ const title = `Query history at ${formatAbsoluteDateTime(
+ (getDateForPbTimestampProtoEs(history.createTime) as Date).getTime()
+ )}`;
const tab = getSQLEditorTabsState().addTab(
{
title,
diff --git a/frontend/src/routes/project/ProjectAccessGrantsPage.tsx b/frontend/src/routes/project/ProjectAccessGrantsPage.tsx
index da5b8d577f..6e7b0a543b 100644
--- a/frontend/src/routes/project/ProjectAccessGrantsPage.tsx
+++ b/frontend/src/routes/project/ProjectAccessGrantsPage.tsx
@@ -10,6 +10,7 @@ import {
import { ComponentPermissionGuard } from "@/components/ComponentPermissionGuard";
import { EngineIcon } from "@/components/EngineIcon";
import { FeatureAttention } from "@/components/FeatureAttention";
+import { HumanizeTs } from "@/components/HumanizeTs";
import {
ProjectPageContent,
ProjectPageFooter,
@@ -53,10 +54,10 @@ import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
import {
type AccessGrantDisplayStatus,
- formatAbsoluteDateTime,
getAccessGrantDisplayStatus,
getAccessGrantDisplayStatusText,
getAccessGrantExpirationText,
+ getAccessGrantExpireTimeMs,
getAccessGrantStatusTagType,
getDefaultPagination,
hasProjectPermissionV2,
@@ -747,13 +748,17 @@ function AccessGrantRow({
const { t } = useTranslation();
const status = getAccessGrantDisplayStatus(grant, issue);
- const createdAt = grant.createTime
- ? formatAbsoluteDateTime(getTimeForPbTimestampProtoEs(grant.createTime))
- : "-";
+ const createdTimeMs = grant.createTime
+ ? getTimeForPbTimestampProtoEs(grant.createTime)
+ : undefined;
const expirationInfo = getAccessGrantExpirationText(grant);
- const expiration =
- expirationInfo.type === "datetime" ? expirationInfo.value : "-";
+ // The roster's creation column is meta on a management list, read for
+ // freshness; the grant's operational fact is when it lapses.
+ const expireTimeMs =
+ expirationInfo.type === "datetime"
+ ? getAccessGrantExpireTimeMs(grant)
+ : undefined;
return (
<TableRow>
@@ -766,10 +771,22 @@ function AccessGrantRow({
<EllipsisText text={extractUserEmail(grant.creator)} />
</TableCell>
<TableCell>
- <EllipsisText text={createdAt} />
+ {createdTimeMs !== undefined ? (
+ <HumanizeTs className="block truncate" ts={createdTimeMs / 1000} />
+ ) : (
+ "-"
+ )}
</TableCell>
<TableCell>
- <EllipsisText text={expiration} />
+ {expireTimeMs !== undefined ? (
+ <HumanizeTs
+ className="block truncate"
+ mode="operational"
+ ts={expireTimeMs / 1000}
+ />
+ ) : (
+ "-"
+ )}
</TableCell>
<TableCell>
<div className="flex items-center gap-x-1 overflow-hidden">
diff --git a/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx b/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
index 36bf924bc5..02557b4b58 100644
--- a/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
+++ b/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
@@ -1,5 +1,4 @@
import { create } from "@bufbuild/protobuf";
-import dayjs from "dayjs";
import { ChevronRight, ShieldCheck } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -15,6 +14,7 @@ import {
import { classificationLevelBackgroundClasses } from "@/components/classification-level";
import { FeatureAttention } from "@/components/FeatureAttention";
import { FeatureBadge } from "@/components/FeatureBadge";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { RouterLink } from "@/components/RouterLink";
import { UserHoverCard } from "@/components/UserHoverCard";
import { Button } from "@/components/ui/button";
@@ -1119,9 +1119,11 @@ function ExemptionGrantSection({
<span className="font-medium text-sm">{title}</span>
{grant.expirationTimestamp && isExpired ? (
<>
- <span className="text-xs text-control-light line-through">
- {dayjs(grant.expirationTimestamp).format("YYYY-MM-DD HH:mm")}
- </span>
+ <HumanizeTs
+ className="text-xs text-control-light line-through"
+ mode="operational"
+ ts={grant.expirationTimestamp / 1000}
+ />
<span className="text-xs text-control-light">
({t("sql-editor.expired")})
</span>
@@ -1132,7 +1134,12 @@ function ExemptionGrantSection({
{expiryLabel}
</span>
<span className="text-xs text-control-light">
- ({dayjs(grant.expirationTimestamp).format("YYYY-MM-DD HH:mm")})
+ (
+ <HumanizeTs
+ mode="operational"
+ ts={grant.expirationTimestamp / 1000}
+ />
+ )
</span>
</>
) : (
diff --git a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx
index 07db64291c..899ec0f7ef 100644
--- a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx
+++ b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx
@@ -102,6 +102,7 @@ export function DatabaseChangelogTable({
<TableCell className="text-main">
{changelog.createTime ? (
<HumanizeTs
+ mode="compact"
ts={
(
getDateForPbTimestampProtoEs(
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 1815bb6eb2..61bf89b33c 100644
--- a/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx
+++ b/frontend/src/routes/project/database-detail/panels/DatabaseOverviewPanel.test.tsx
@@ -68,12 +68,8 @@ 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),
};
});
@@ -147,17 +143,22 @@ vi.mock("@/stores/app/databaseCatalog", () => ({
getTableCatalog: mocks.getTableCatalog,
}));
+vi.mock("@/utils/datetime", () => ({
+ formatQueueTime: mocks.formatRelativeTime,
+ formatCompactDateTime: mocks.formatAbsoluteDateTime,
+ formatOperationalDateTime: mocks.formatAbsoluteDateTime,
+ formatAbsoluteDateTime: mocks.formatAbsoluteDateTime,
+ formatRelativeTime: mocks.formatRelativeTime,
+ nextRelativeChangeAt: () => Number.POSITIVE_INFINITY,
+}));
+
vi.mock("@/utils", () => ({
bytesToString: mocks.bytesToString,
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,
@@ -394,8 +395,6 @@ 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/routes/project/database-detail/revision/DatabaseRevisionTable.tsx b/frontend/src/routes/project/database-detail/revision/DatabaseRevisionTable.tsx
index 4fee5d8ae8..4b2317cdbc 100644
--- a/frontend/src/routes/project/database-detail/revision/DatabaseRevisionTable.tsx
+++ b/frontend/src/routes/project/database-detail/revision/DatabaseRevisionTable.tsx
@@ -107,6 +107,7 @@ export function DatabaseRevisionTable({
<TableCell>
{revision.createTime ? (
<HumanizeTs
+ mode="compact"
ts={
(
getDateForPbTimestampProtoEs(revision.createTime) as Date
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx
index 7853fb4943..2fc3425c91 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.test.tsx
@@ -25,6 +25,7 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
useTranslation: () => ({
t: (key: string) => key,
}),
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
index 47a9dfd169..1c1197a69b 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
@@ -2,13 +2,17 @@ import { Download, EyeOff, Loader2, Shield } from "lucide-react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { DatabaseTargetDisplay } from "@/components/DatabaseTargetDisplay";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { useProjectByName } from "@/hooks/useProjectByName";
import { useAppStore } from "@/stores/app";
import { projectNamePrefix } from "@/stores/modules/v1/common";
import { isValidDatabaseName } from "@/types";
import type { AccessGrant } from "@/types/proto-es/v1/access_grant_service_pb";
import { extractProjectResourceName, hasProjectPermissionV2 } from "@/utils";
-import { getAccessGrantExpirationText } from "@/utils/accessGrant";
+import {
+ getAccessGrantExpirationText,
+ getAccessGrantExpireTimeMs,
+} from "@/utils/accessGrant";
import { useIssueDetailContext } from "../context/IssueDetailContext";
export function IssueDetailAccessGrantDetails() {
@@ -174,7 +178,14 @@ export function IssueDetailAccessGrantDetails() {
// post-activation (input-only proto field); we
// can't recover it without double-counting the
// approval wait. Bot review #3370767734.
- expirationInfo.value}
+ accessGrant && (
+ <HumanizeTs
+ mode="operational"
+ ts={
+ (getAccessGrantExpireTimeMs(accessGrant) ?? 0) / 1000
+ }
+ />
+ )}
</div>
</div>
</div>
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailRoleGrantDetails.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailRoleGrantDetails.tsx
index 34402c1fa9..71bc2e80dc 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailRoleGrantDetails.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailRoleGrantDetails.tsx
@@ -1,6 +1,6 @@
-import dayjs from "dayjs";
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { DDLWarningCallout } from "@/components/role-grant/DDLWarningCallout";
import {
Table,
@@ -159,9 +159,14 @@ export function IssueDetailRoleGrantDetails() {
{t("issue.role-grant.expired-at")}
</span>
<div className="text-base">
- {condition?.expiredTime
- ? dayjs(new Date(condition.expiredTime)).format("LLL")
- : t("project.members.never-expires")}
+ {condition?.expiredTime ? (
+ <HumanizeTs
+ mode="operational"
+ ts={new Date(condition.expiredTime).getTime() / 1000}
+ />
+ ) : (
+ t("project.members.never-expires")
+ )}
</div>
</div>
</div>
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx
index 2ea2d129ab..7bd151f8f3 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx
@@ -22,12 +22,7 @@ import { useAppStore } from "@/stores/app";
import { projectNamePrefix } from "@/stores/modules/v1/common";
import { getDateForPbTimestampProtoEs } from "@/types";
import type { Task, TaskRun } from "@/types/proto-es/v1/rollout_service_pb";
-import {
- databaseForTask,
- extractTaskUID,
- formatAbsoluteDateTime,
- humanizeDurationV1,
-} from "@/utils";
+import { databaseForTask, extractTaskUID, humanizeDurationV1 } from "@/utils";
import { useIssueDetailContext } from "../context/IssueDetailContext";
export function IssueDetailTaskRunTable({
@@ -182,10 +177,8 @@ function IssueDetailTaskRunComment({ taskRun }: { taskRun: TaskRun }) {
function IssueDetailTaskRunDateCell({
date,
- format = "humanized",
}: {
date?: Parameters<typeof getDateForPbTimestampProtoEs>[0];
- format?: "absolute" | "humanized";
}) {
if (!date) {
return <span className="text-control-light">-</span>;
@@ -195,16 +188,10 @@ function IssueDetailTaskRunDateCell({
if (!parsedDate) {
return <span className="text-control-light">-</span>;
}
- if (format === "absolute") {
- return (
- <span className="text-sm text-control">
- {formatAbsoluteDateTime(parsedDate.getTime())}
- </span>
- );
- }
return (
<HumanizeTs
+ mode="compact"
ts={parsedDate.getTime() / 1000}
className="text-sm text-control"
/>
diff --git a/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx b/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
index f00f797286..8099013bc9 100644
--- a/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
+++ b/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
@@ -1,6 +1,6 @@
import { create } from "@bufbuild/protobuf";
import { Plus, X } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { issueServiceClientConnect } from "@/api";
import { HumanizeTs } from "@/components/HumanizeTs";
@@ -28,25 +28,14 @@ export function PlanDetailMeta() {
const page = usePlanDetailContext();
const { patchState } = page;
const project = page.project;
- const [now, setNow] = useState(Date.now());
-
- useEffect(() => {
- if (page.isCreating) return;
- // Only consumer is the plan-creation timestamp, which never advances
- // faster than once a minute — no need for a 1s tick.
- const timer = window.setInterval(() => setNow(Date.now()), 60_000);
- return () => window.clearInterval(timer);
- }, [page.isCreating]);
-
const creatorEmail = useMemo(
() => extractUserEmail(page.plan.creator),
[page.plan.creator]
);
- const createdTimeTs = useMemo(() => {
- // Reference `now` so the relative label re-renders on each tick.
- void now;
- return getTimeForPbTimestampProtoEs(page.plan.createTime, 0);
- }, [now, page.plan.createTime]);
+ const createdTimeTs = useMemo(
+ () => getTimeForPbTimestampProtoEs(page.plan.createTime, 0),
+ [page.plan.createTime]
+ );
const allowChangeLabels = useMemo(() => {
if (!project || !page.issue || page.issue.status !== IssueStatus.OPEN) {
return false;
diff --git a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.tsx b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.tsx
index 2f0334843b..3b40738245 100644
--- a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.tsx
+++ b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskHeader.tsx
@@ -87,7 +87,7 @@ export function DeployTaskHeader({
{isExpanded && scheduledTimeTs > 0 && (
<span className="flex shrink-0 items-center gap-x-1 rounded-full bg-info/10 px-2 py-0.5 text-xs text-info">
<LoaderCircle className="size-3 animate-spin motion-reduce:animate-none" />
- <HumanizeTs ts={scheduledTimeTs} />
+ <HumanizeTs mode="operational" ts={scheduledTimeTs} />
</span>
)}
</div>
@@ -104,7 +104,7 @@ export function DeployTaskHeader({
<span className="flex items-center gap-x-1 text-info">
<LoaderCircle className="size-3 animate-spin motion-reduce:animate-none" />
{scheduledTimeTs > 0 ? (
- <HumanizeTs ts={scheduledTimeTs} />
+ <HumanizeTs mode="operational" ts={scheduledTimeTs} />
) : (
timingDisplay
)}
diff --git a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskRunHistorySheet.tsx b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskRunHistorySheet.tsx
index 361cd33177..865668b319 100644
--- a/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskRunHistorySheet.tsx
+++ b/frontend/src/routes/project/plan-detail/components/deploy/DeployTaskRunHistorySheet.tsx
@@ -142,7 +142,7 @@ function TaskRunHistoryItem({
)}
</span>
<span className="flex shrink-0 items-center gap-x-3 text-xs text-control-light">
- {startTs > 0 && <HumanizeTs ts={startTs / 1000} />}
+ {startTs > 0 && <HumanizeTs mode="compact" ts={startTs / 1000} />}
{duration && (
<span className="flex items-center gap-x-1">
<Clock3 className="size-3" />
diff --git a/frontend/src/routes/workspace/MembersPage.tsx b/frontend/src/routes/workspace/MembersPage.tsx
index 8d9ca77aee..caecfc703f 100644
--- a/frontend/src/routes/workspace/MembersPage.tsx
+++ b/frontend/src/routes/workspace/MembersPage.tsx
@@ -26,6 +26,7 @@ import { DatabaseResourceSelector as DatabaseResourceSelectorComponent } from "@
import { EnvironmentSelect } from "@/components/EnvironmentSelect";
import { ExprEditor, type OptionConfig } from "@/components/ExprEditor";
import { FeatureBadge } from "@/components/FeatureBadge";
+import { HumanizeTs } from "@/components/HumanizeTs";
import { LearnMoreLink } from "@/components/LearnMoreLink";
import { PermissionGuard } from "@/components/PermissionGuard";
import {
@@ -864,15 +865,11 @@ function computeExpirationTimestamp(days?: number): number | undefined {
return Date.now() + days * 86400000;
}
+// Interpolated into an i18n sentence, which cannot host a tooltip, so this
+// carries the full precision itself rather than a reduced form.
function formatExpirationDate(timestampMs?: number): string {
if (!timestampMs) return "";
- return new Date(timestampMs).toLocaleDateString(undefined, {
- year: "numeric",
- month: "short",
- day: "numeric",
- hour: "2-digit",
- minute: "2-digit",
- });
+ return formatAbsoluteDateTime(timestampMs);
}
// Validates the form's expiration against the workspace cap. "Never" (no
@@ -1892,11 +1889,14 @@ function EditMemberRoleDrawer({
{row.databaseResource?.table ?? "*"}
</TableCell>
<TableCell>
- {row.expiration
- ? formatAbsoluteDateTime(
- row.expiration.getTime()
- )
- : t("project.members.never-expires")}
+ {row.expiration ? (
+ <HumanizeTs
+ mode="operational"
+ ts={row.expiration.getTime() / 1000}
+ />
+ ) : (
+ t("project.members.never-expires")
+ )}
</TableCell>
</TableRow>
))}