Skip to content

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

refactor(frontend): last cleanups from the round-6 simplify pass

zchpeter4c536702b26d
diff --git a/frontend/src/components/task-run-log/SectionContent.tsx b/frontend/src/components/task-run-log/SectionContent.tsx
index 9a7bd68935..94a7e15a2a 100644
--- a/frontend/src/components/task-run-log/SectionContent.tsx
+++ b/frontend/src/components/task-run-log/SectionContent.tsx
@@ -6,6 +6,12 @@ import { cn } from "@/lib/utils";
import { formatAbsoluteDateTime } from "@/utils";
import type { Section } from "./types";
+// Mounts only while the tooltip is open, so the rows nobody hovers cost
+// nothing.
+function FullDateTime({ tsMs }: { tsMs: number }) {
+ return <>{formatAbsoluteDateTime(tsMs)}</>;
+}
+
const ITEM_HEIGHT = 20;
const MAX_VISIBLE_ITEMS = 10;
const MAX_RENDERED_ITEMS = 50;
@@ -53,7 +59,7 @@ export function SectionContent({
</span>
<Tooltip
content={
- item.timeMs > 0 ? formatAbsoluteDateTime(item.timeMs) : undefined
+ item.timeMs > 0 ? <FullDateTime tsMs={item.timeMs} /> : undefined
}
>
<span className="shrink-0 text-control-placeholder tabular-nums">
diff --git a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
index 540dde4707..55dde25d64 100644
--- a/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
+++ b/frontend/src/modules/sql-editor/components/AccessGrantItem.test.tsx
@@ -11,7 +11,6 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
const mocks = vi.hoisted(() => ({
useTranslation: vi.fn(() => ({ t: (key: string) => key })),
readStatus: vi.fn(),
- actualReadStatus: undefined as unknown as (input: never) => unknown,
getAccessGrantDisplayStatusText: vi.fn(),
getAccessGrantStatusTagType: vi.fn(),
}));
@@ -38,7 +37,6 @@ vi.mock("react-i18next", () => ({
// status boundary and the deadline stay real, so the clock wiring is exercised.
vi.mock("@/utils/accessGrant", async (importOriginal) => {
const actual = await importOriginal<typeof import("@/utils/accessGrant")>();
- mocks.actualReadStatus = actual.accessGrantStatusReading.read as never;
return {
...actual,
accessGrantStatusReading: {
@@ -334,10 +332,13 @@ describe("AccessGrantItem", () => {
unmount();
});
- test("counts down while mounted, then turns expired at the deadline", () => {
+ test("counts down while mounted, then turns expired at the deadline", async () => {
+ const actual = await vi.importActual<typeof import("@/utils/accessGrant")>(
+ "@/utils/accessGrant"
+ );
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-03-02T12:00:00Z"));
- mocks.readStatus.mockImplementation(mocks.actualReadStatus);
+ mocks.readStatus.mockImplementation(actual.accessGrantStatusReading.read);
mocks.useTranslation.mockReturnValue({
t: (key: string, options?: { time?: string }) =>
options?.time && key === "sql-editor.expire-in"
diff --git a/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx b/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
index 63bb039962..3c12254be3 100644
--- a/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
+++ b/frontend/src/routes/project/plan-detail/components/PlanDetailMeta.tsx
@@ -32,7 +32,7 @@ export function PlanDetailMeta() {
() => extractUserEmail(page.plan.creator),
[page.plan.creator]
);
- const createdTimeTs = getTimeForPbTimestampProtoEs(page.plan.createTime, 0);
+ const createdTimeMs = getTimeForPbTimestampProtoEs(page.plan.createTime);
const allowChangeLabels = useMemo(() => {
if (!project || !page.issue || page.issue.status !== IssueStatus.OPEN) {
return false;
@@ -84,10 +84,10 @@ export function PlanDetailMeta() {
return (
<div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-control-placeholder">
<span>{t("plan.meta.created-by", { user: creatorEmail })}</span>
- {createdTimeTs > 0 && (
+ {createdTimeMs !== undefined && (
<>
<span aria-hidden="true">·</span>
- <HumanizeTs ts={createdTimeTs / 1000} />
+ <HumanizeTs ts={createdTimeMs / 1000} />
</>
)}
diff --git a/frontend/src/utils/accessGrant.ts b/frontend/src/utils/accessGrant.ts
index bb2b009a2e..65a9a7b4ed 100644
--- a/frontend/src/utils/accessGrant.ts
+++ b/frontend/src/utils/accessGrant.ts
@@ -38,7 +38,8 @@ export const getAccessGrantExpirationText = (
| { type: "datetime"; expireTimeMs: number }
| { type: "duration"; value: string }
| { type: "never" } => {
- if (grant.expiration.case === "expireTime") {
+ const expireTimeMs = getAccessGrantExpireTimeMs(grant);
+ if (expireTimeMs !== undefined) {
// Active grants only carry `expireTime` — the originally-requested
// TTL is `Input only` on the proto and is gone after activation.
// We deliberately do NOT derive a "duration" from
@@ -48,10 +49,7 @@ export const getAccessGrantExpirationText = (
// later would render as "1d4h", which misleads reviewers about
// the actual granted window. Show the absolute expire datetime
// alone instead. Bot review #3370767734.
- return {
- type: "datetime",
- expireTimeMs: getTimeForPbTimestampProtoEs(grant.expiration.value),
- };
+ return { type: "datetime", expireTimeMs };
}
if (grant.expiration.case === "ttl") {
// Pending grants still carry the requested TTL — safe to format.
diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts
index f7b4850401..c373ef0c3b 100644
--- a/frontend/src/utils/datetime.ts
+++ b/frontend/src/utils/datetime.ts
@@ -168,14 +168,10 @@ function absoluteDateChangeAt(timestampMs: number, nowMs: number): number {
);
}
-function nextRelativeTimeChangeAt(timestampMs: number): number {
- return relativeTimeChangeAt(timestampMs, Date.now());
-}
-
/** A timestamp's age, as "5 minutes ago" or "in 2 days". */
export const relativeTimeReading: TimeReading<number, string> = {
read: formatRelativeTime,
- nextChangeAt: nextRelativeTimeChangeAt,
+ nextChangeAt: (timestampMs) => relativeTimeChangeAt(timestampMs, Date.now()),
};
function nextQueueTimeChangeAt(timestampMs: number): number {
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index 918f4ae292..492790c2dc 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -2,7 +2,6 @@ import type { Duration } from "@bufbuild/protobuf/wkt";
import dayjs from "dayjs";
import dayOfYear from "dayjs/plugin/dayOfYear";
import duration from "dayjs/plugin/duration";
-import relativeTime from "dayjs/plugin/relativeTime";
import utc from "dayjs/plugin/utc";
import DOMPurify from "dompurify";
import { escape as escapeHtml, escapeRegExp, round } from "lodash-es";
@@ -10,7 +9,6 @@ import semver from "semver";
dayjs.extend(dayOfYear);
dayjs.extend(duration);
-dayjs.extend(relativeTime);
dayjs.extend(utc);
export function isDev(): boolean {