Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(frontend): size every timestamp column to its form
zchpeter2b6e3758d5fa
diff --git a/docs/design/timestamp-display.md b/docs/design/timestamp-display.mdindex dbc14f11ad..85d2950f69 100644--- a/docs/design/timestamp-display.md+++ b/docs/design/timestamp-display.md@@ -134,6 +134,17 @@ history: the embedded lists, where width is contended and D6 keeps full precisioObjective divider: **exportable-as-evidence or a detail view → full; scannable embedded list →compact.**+**Column width follows the form.** Moving a surface off relative wording lengthens its value — "3+months ago" is about 125px in a table cell, the compact form 190, the operational 260, the full+date-time 280 — so a column sized for the old wording breaks the new one across two lines or+truncates it. Each form has a measured width (`TIMESTAMP_COLUMN`, the widest rendering across+every shipped locale), and a column holding it gets that width. In a fixed-layout table the+open-ended column — a title, a statement — is the one left unsized: the browser spreads spare+width across every sized column, so sizing them all lets the timestamp swell on a wide screen. A+column narrows below its form only where the tooltip restores what truncation hides: compact may,+operational may not, since its zone has to stay visible, and the full date-time may not, since its+tooltip is the age.+## Surface classificationEvery current `HumanizeTs` call site, classified under the principle:diff --git a/frontend/src/components/AuditLogTable.test.tsx b/frontend/src/components/AuditLogTable.test.tsxindex b9049b46ee..aa80668ef2 100644--- a/frontend/src/components/AuditLogTable.test.tsx+++ b/frontend/src/components/AuditLogTable.test.tsx@@ -4,6 +4,7 @@ import type { ReactElement } from "react";import { act } from "react";import { createRoot } from "react-dom/client";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import { StatusSchema } from "@/types/proto-es/google/rpc/status_pb";import {AuditLog_Severity,@@ -172,6 +173,26 @@ afterEach(() => {});describe("AuditLogTable", () => {+ test("keeps the full date-time on one line at any width", async () => {+ // The evidence tier's tooltip is the age, which cannot give the value+ // back, so its column never narrows past the form: sized to it, and the+ // floor a drag stops at.+ mocks.searchAuditLogs.mockResolvedValue({+ auditLogs: [create(AuditLogSchema, { name: "auditLogs/1" })],+ nextPageToken: "",+ });+ const { container, render, unmount } = renderIntoContainer(+ <AuditLogTable parent="projects/-" canExport={false} />+ );+ await render();++ const [created] = Array.from(container.querySelectorAll("col"));+ expect(created.style.width).toBe(`${TIMESTAMP_COLUMN.datetime.width}px`);++ unmount();+ });++test("searches only the matching special-account kind for a prefixed actor", async () => {mocks.searchAuditLogs.mockResolvedValue({ auditLogs: [], nextPageToken: "" });mocks.listServiceAccounts.mockResolvedValue({diff --git a/frontend/src/components/AuditLogTable.tsx b/frontend/src/components/AuditLogTable.tsxindex 0cd713d4ca..38ff2dbc01 100644--- a/frontend/src/components/AuditLogTable.tsx+++ b/frontend/src/components/AuditLogTable.tsx@@ -16,6 +16,7 @@ import {import { HumanizeTs } from "@/components/HumanizeTs";import { RouterLink } from "@/components/RouterLink";import { TimeRangePicker } from "@/components/TimeRangePicker";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";@@ -437,8 +438,8 @@ function useColumnDefs(): ColumnDef[] {{key: "create_time",title: t("audit-log.table.created-ts"),- defaultWidth: 220,- minWidth: 160,+ defaultWidth: TIMESTAMP_COLUMN.datetime.width,+ minWidth: TIMESTAMP_COLUMN.datetime.minWidth,resizable: true,sortable: true,render: (log: AuditLog) =>diff --git a/frontend/src/components/timestampColumn.ts b/frontend/src/components/timestampColumn.tsnew file mode 100644index 0000000000..8649bd5d4a--- /dev/null+++ b/frontend/src/components/timestampColumn.ts@@ -0,0 +1,19 @@+// Layout for the forms HumanizeTs renders, kept out of the component so a+// test that stubs the component still has the real widths to lay out with.++/**+ * The width of a table column that holds a form on one line: the widest+ * rendering (a two-digit hour, a zone as long as GMT-3:30) at a table's 14px,+ * plus a cell's 32px of padding. Measured in every locale the app ships;+ * en-US is the widest in all three forms.+ *+ * A column may be dragged below its form only where the tooltip restores what+ * the truncation hides. Compact's tooltip is the full date-time, so it may.+ * Operational may not, because its zone has to stay visible; nor may the full+ * date-time, whose tooltip is the age and cannot give the value back.+ */+export const TIMESTAMP_COLUMN = {+ compact: { width: 190, minWidth: 120 },+ operational: { width: 260, minWidth: 260 },+ datetime: { width: 280, minWidth: 280 },+} as const;diff --git a/frontend/src/routes/project/ProjectAccessGrantsPage.test.tsx b/frontend/src/routes/project/ProjectAccessGrantsPage.test.tsxnew file mode 100644index 0000000000..9a615ada99--- /dev/null+++ b/frontend/src/routes/project/ProjectAccessGrantsPage.test.tsx@@ -0,0 +1,23 @@+import { describe, expect, test, vi } from "vitest";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+ initReactI18next: { type: "3rdParty", init: () => {} },+}));++import { grantColumns } from "./ProjectAccessGrantsPage";++describe("grantColumns", () => {+ test("keeps the expiry's zone in view at any width", () => {+ // An operational time carries its zone so a reader elsewhere knows when+ // access really ends, and the zone is the end of the string -- the first+ // thing a narrow column cuts. So the column is sized to the whole form,+ // and a drag stops there.+ const expiration = grantColumns((key) => key).find(+ (column) => column.key === "expiration"+ );+ expect(expiration?.defaultWidth).toBe(TIMESTAMP_COLUMN.operational.width);+ expect(expiration?.minWidth).toBe(TIMESTAMP_COLUMN.operational.width);+ });+});diff --git a/frontend/src/routes/project/ProjectAccessGrantsPage.tsx b/frontend/src/routes/project/ProjectAccessGrantsPage.tsxindex 779dd5cf36..a4240d221b 100644--- a/frontend/src/routes/project/ProjectAccessGrantsPage.tsx+++ b/frontend/src/routes/project/ProjectAccessGrantsPage.tsx@@ -19,6 +19,7 @@ import {} from "@/components/ProjectPageLayout";import { RouterLink } from "@/components/RouterLink";import { TimeRangePicker } from "@/components/TimeRangePicker";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";@@ -90,6 +91,52 @@ type GrantColumn = {resizable?: boolean;};+/** The table's columns, in `<colgroup>` order; titles follow the language. */+export const grantColumns = (t: (key: string) => string): GrantColumn[] => [+ {+ key: "status",+ title: t("common.status"),+ defaultWidth: 160,+ minWidth: 128,+ },+ {+ key: "creator",+ title: t("common.creator"),+ defaultWidth: 200,+ minWidth: 128,+ sortKey: "creator",+ },+ {+ key: "created",+ title: t("common.created-at"),+ defaultWidth: 200,+ minWidth: 132,+ sortKey: "create_time",+ },+ {+ key: "expiration",+ title: t("common.expiration"),+ defaultWidth: TIMESTAMP_COLUMN.operational.width,+ minWidth: TIMESTAMP_COLUMN.operational.minWidth,+ sortKey: "expire_time",+ },+ {+ key: "statement",+ title: t("common.statement"),+ defaultWidth: 400,+ minWidth: 180,+ },+ {+ key: "databases",+ title: t("common.databases"),+ defaultWidth: 240,+ minWidth: 128,+ },+ // Trailing actions column — no title (blank header), fixed+ // width sized for two ghost buttons + "View issue".+ { key: "actions", defaultWidth: 140, minWidth: 96, resizable: false },+];+function hashCode(str: string): number {let hash = 0;for (let i = 0; i < str.length; i++) {@@ -477,59 +524,9 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {})();}, [fetchIssueByName, issueByGrantName, paged.dataList]);- // Translated column descriptors. Built inside the component (not at- // module scope) so `title` strings resolve via `t()` and update- // automatically on language switches. Memoized on `t` so the- // descriptor array identity is stable between renders within the- // same language — which matters because `useColumnWidths` reads the- // initial widths from this array on first render.- const columns = useMemo<GrantColumn[]>(- () => [- {- key: "status",- title: t("common.status"),- defaultWidth: 160,- minWidth: 128,- },- {- key: "creator",- title: t("common.creator"),- defaultWidth: 200,- minWidth: 128,- sortKey: "creator",- },- {- key: "created",- title: t("common.created-at"),- defaultWidth: 200,- minWidth: 132,- sortKey: "create_time",- },- {- key: "expiration",- title: t("common.expiration"),- defaultWidth: 200,- minWidth: 132,- sortKey: "expire_time",- },- {- key: "statement",- title: t("common.statement"),- defaultWidth: 400,- minWidth: 180,- },- {- key: "databases",- title: t("common.databases"),- defaultWidth: 240,- minWidth: 128,- },- // Trailing actions column — no title (blank header), fixed- // width sized for two ghost buttons + "View issue".- { key: "actions", defaultWidth: 140, minWidth: 96, resizable: false },- ],- [t]- );+ // Memoized on `t` so the array identity is stable within a language:+ // `useColumnWidths` reads the initial widths from it on first render.+ const columns = useMemo(() => grantColumns(t), [t]);// User-controlled column widths so long statements / databases /// expiration values aren't permanently truncated by the table'sdiff --git a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.test.tsx b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.test.tsxindex 9e0d43c6ea..4443c1c1ee 100644--- a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.test.tsx+++ b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.test.tsx@@ -36,6 +36,7 @@ vi.mock("@/components/HumanizeTs", async () => ({...(await import("@/test-utils/humanizeTs")).humanizeTsStub(),}));+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import { DatabaseChangelogTable } from "./DatabaseChangelogTable";const renderIntoContainer = (element: ReactElement) => {@@ -67,7 +68,7 @@ beforeEach(() => {});describe("DatabaseChangelogTable", () => {- test("gives the timestamp a fixed share and the title the rest, adjustably", () => {+ test("sizes the date to its form and lets the title fill", () => {const { container, render, unmount } = renderIntoContainer(<DatabaseChangelogTableloading={false}@@ -77,18 +78,17 @@ describe("DatabaseChangelogTable", () => {render();- // The timestamp column is sized for its own value and the title column- // takes what is left, so a date never wraps and a long title still has- // room. Both are draggable, since which one matters is the reader's call.- const widths = Array.from(container.querySelectorAll("col")).map((col) =>- Number.parseInt(col.style.width, 10)- );- const [, created, rollout] = widths;- expect(created).toBeGreaterThanOrEqual(190);- expect(rollout).toBeGreaterThan(created);+ // A fixed-layout table spreads spare width across every sized column, so+ // the title is left unsized to take it: the date keeps exactly its form's+ // width at any viewport, which is what keeps it on one line without+ // letting it grow. Only the date is draggable -- widening it is how the+ // reader trades room with the title.+ const [, created, rollout] = Array.from(container.querySelectorAll("col"));+ expect(created.style.width).toBe(`${TIMESTAMP_COLUMN.compact.width}px`);+ expect(rollout.style.width).toBe("");expect(container.querySelectorAll("[class*=cursor-col-resize]")- ).toHaveLength(2);+ ).toHaveLength(1);unmount();});diff --git a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsxindex aff432e9a1..3a377f0c80 100644--- a/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx+++ b/frontend/src/routes/project/database-detail/changelog/DatabaseChangelogTable.tsx@@ -3,6 +3,7 @@ import { useCallback, useMemo } from "react";import { useTranslation } from "react-i18next";import { router } from "@/app/router";import { HumanizeTs } from "@/components/HumanizeTs";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import {Table,TableBody,@@ -57,28 +58,27 @@ export function DatabaseChangelogTable({loading: boolean;}) {const { t } = useTranslation();- // Default widths are ratios once the table fills its container, so the- // rollout title -- the only column with an open-ended value -- carries a- // large one and absorbs the width the timestamp does not need. The created- // column's default fits the compact form on one line; dragged below that it- // ellipsizes, and the reading it hides is still on the hover, which is the- // one thing a timestamp must never lose.+ // A fixed-layout table spreads any spare width across every column that+ // has one, so the rollout title alone is left unsized: it takes what the+ // others leave, and the timestamp keeps exactly the width its form needs+ // at any viewport. Its default is only the floor the table keeps before it+ // scrolls.const columns = useMemo(() => [{ key: "status", title: "", defaultWidth: 48, resizable: false },{key: "created",title: t("common.created-at"),- defaultWidth: 200,- minWidth: 168,+ defaultWidth: TIMESTAMP_COLUMN.compact.width,+ minWidth: TIMESTAMP_COLUMN.compact.minWidth,resizable: true,},{key: "rollout",title: t("common.rollout"),- defaultWidth: 700,- minWidth: 200,- resizable: true,+ defaultWidth: 200,+ resizable: false,+ fills: true,},],[t]@@ -108,7 +108,12 @@ export function DatabaseChangelogTable({<Table className="table-fixed" style={{ minWidth: `${totalWidth}px` }}><colgroup>{widths.map((w, index) => (- <col key={columns[index].key} style={{ width: `${w}px` }} />+ <col+ key={columns[index].key}+ style={{+ width: "fills" in columns[index] ? undefined : `${w}px`,+ }}+ />))}</colgroup><TableHeader className="bg-control-bg">diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.test.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.test.tsxnew file mode 100644index 0000000000..99deae62ac--- /dev/null+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.test.tsx@@ -0,0 +1,88 @@+import { create } from "@bufbuild/protobuf";+import { timestampFromMs } from "@bufbuild/protobuf/wkt";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { afterEach, describe, expect, test, vi } from "vitest";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";+import { shownTimestampModes } from "@/test-utils/humanizeTs";+import {+ TaskRun_Status,+ TaskRunSchema,+} from "@/types/proto-es/v1/rollout_service_pb";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+ // @/lib/i18n initializes with this, and the table's helpers reach it.+ initReactI18next: { type: "3rdParty", init: () => {} },+}));++vi.mock("@/components/HumanizeTs", async () => ({+ ...(await import("@/test-utils/humanizeTs")).humanizeTsStub(),+}));++vi.mock("@/components/DatabaseTargetDisplay", () => ({+ DatabaseTargetDisplay: () => null,+}));++vi.mock("@/components/TaskRunStatusIcon", () => ({+ TaskRunStatusIcon: () => null,+}));++vi.mock("@/hooks/useProjectByName", () => ({+ useProjectByName: () => undefined,+}));++vi.mock("@/stores/app", () => ({+ useAppStore: (select: (state: { projectsByName: object }) => unknown) =>+ select({ projectsByName: {} }),+}));++vi.mock("../context/IssueDetailContext", () => ({+ useIssueDetailContext: () => ({ projectId: "p1", rollout: undefined }),+}));++import { IssueDetailTaskRunTable } from "./IssueDetailTaskRunTable";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++const roots: ReturnType<typeof createRoot>[] = [];++afterEach(() => {+ for (const root of roots.splice(0)) {+ act(() => root.unmount());+ }+});++describe("IssueDetailTaskRunTable", () => {+ test("gives each date column the width of the form it holds", () => {+ const container = document.createElement("div");+ const root = createRoot(container);+ roots.push(root);+ const createdMs = Date.UTC(2026, 2, 2, 12);+ act(() =>+ root.render(+ <IssueDetailTaskRunTable+ taskRuns={[+ create(TaskRunSchema, {+ name: "projects/p1/rollouts/1/stages/s1/tasks/1/taskRuns/1",+ status: TaskRun_Status.DONE,+ createTime: timestampFromMs(createdMs),+ startTime: timestampFromMs(createdMs + 60_000),+ }),+ ]}+ />+ )+ );++ // The detail column is the one left unsized, so it takes the spare width+ // and the dates keep theirs: narrower, a compact date breaks in two.+ const headers = Array.from(container.querySelectorAll("th"));+ const widthOf = (label: string) =>+ headers.find((th) => th.textContent === label)?.style.width;+ expect(widthOf("task.created")).toBe(`${TIMESTAMP_COLUMN.compact.width}px`);+ expect(widthOf("task.started")).toBe(`${TIMESTAMP_COLUMN.compact.width}px`);+ expect(shownTimestampModes(container)).toEqual(["compact", "compact"]);+ });+});diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsxindex 8cb01f4208..94ae412b0d 100644--- a/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailTaskRunTable.tsx@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";import { DatabaseTargetDisplay } from "@/components/DatabaseTargetDisplay";import { HumanizeTs } from "@/components/HumanizeTs";import { TaskRunStatusIcon } from "@/components/TaskRunStatusIcon";+import { TIMESTAMP_COLUMN } from "@/components/timestampColumn";import { EllipsisText } from "@/components/ui/ellipsis-text";import {Table,@@ -107,10 +108,18 @@ export function IssueDetailTaskRunTable({<TableHead className="sticky top-0 z-10 bg-control-bg/50">{t("common.detail")}</TableHead>- <TableHead className="sticky top-0 z-10 w-36 bg-control-bg/50">+ {/* Sized to the form, since the detail column is the one+ that fills; a narrower column breaks a date in two. */}+ <TableHead+ className="sticky top-0 z-10 bg-control-bg/50"+ style={{ width: TIMESTAMP_COLUMN.compact.width }}+ >{t("task.created")}</TableHead>- <TableHead className="sticky top-0 z-10 w-36 bg-control-bg/50">+ <TableHead+ className="sticky top-0 z-10 bg-control-bg/50"+ style={{ width: TIMESTAMP_COLUMN.compact.width }}+ >{t("task.started")}</TableHead><TableHead className="sticky top-0 z-10 w-28 bg-control-bg/50 pr-6 whitespace-nowrap text-sm">@@ -184,7 +193,7 @@ function IssueDetailTaskRunDateCell({ date }: { date?: Timestamp }) {<HumanizeTsmode="compact"tsMs={getTimeForPbTimestampProtoEs(date)}- className="text-sm text-control"+ className="block truncate text-sm text-control"/>);}