Skip to content

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

chore: optimize jit (#20536)

ecmadao2a25642d4b44
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f38116d3b8..a2459e2177 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1185,6 +1185,7 @@
}
},
"details": "Access Grant Details",
+ "duration-after-approval": "{{duration}} after issue approved",
"expired-at": "Expired at",
"export-results-to-file": "Export results to a file",
"this-grant-allows": "This grant allows",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index b0f56ee738..3c9b41015a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1185,6 +1185,7 @@
}
},
"details": "Detalles de la concesión de acceso",
+ "duration-after-approval": "{{duration}} después de aprobar la solicitud",
"expired-at": "Expiró el",
"export-results-to-file": "Exportar resultados a un archivo",
"this-grant-allows": "Esta concesión permite",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 5158d98523..345d82bead 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1185,6 +1185,7 @@
}
},
"details": "アクセス付与の詳細",
+ "duration-after-approval": "Issue 承認後 {{duration}}",
"expired-at": "有効期限",
"export-results-to-file": "結果をファイルにエクスポート",
"this-grant-allows": "このアクセス権限で許可される操作",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 53f09a39d6..6f0f168f50 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1185,6 +1185,7 @@
}
},
"details": "Chi tiết cấp quyền truy cập",
+ "duration-after-approval": "{{duration}} sau khi yêu cầu được duyệt",
"expired-at": "Hết hạn lúc",
"export-results-to-file": "Xuất kết quả ra tệp",
"this-grant-allows": "Cấp quyền này cho phép",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 23a5bc3aaa..f34d2ddf93 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1185,6 +1185,7 @@
}
},
"details": "访问授权详情",
+ "duration-after-approval": "工单批准后 {{duration}}",
"expired-at": "过期时间",
"export-results-to-file": "将结果导出为文件",
"this-grant-allows": "此授权允许",
diff --git a/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx b/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx
index 61e29fd481..922948d527 100644
--- a/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx
+++ b/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx
@@ -32,6 +32,7 @@ import {
} from "@/react/components/ui/table";
import { Tooltip } from "@/react/components/ui/tooltip";
import { useCurrentUser } from "@/react/hooks/useAppState";
+import { useColumnWidths } from "@/react/hooks/useColumnWidths";
import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";
import { useProjectByName } from "@/react/hooks/useProjectByName";
import { useAppStore } from "@/react/stores/app";
@@ -59,6 +60,29 @@ import { extractDatabaseResourceName } from "@/utils/v1/database";
type SortKey = "creator" | "create_time" | "expire_time";
type SortDir = "asc" | "desc";
+// Column descriptor for the access-grants table. The column array is
+// built inside the component (so titles resolve via `t()` and react
+// to language switches); only the shape lives at module scope.
+//
+// Position in the array is the `<colgroup>` order — keep this in sync
+// with the cell order inside `<AccessGrantRow>` (`useColumnWidths`
+// indexes positionally).
+//
+// - `title` — header label; omit for a blank header (actions col).
+// - `defaultWidth` — initial render width; user-resizable from there.
+// - `minWidth` — drag floor so a column can't collapse to a sliver.
+// - `sortKey` — present iff the column participates in server sort.
+// - `resizable` — defaults true; set false for purely action columns
+// where a too-narrow width clips the button row.
+type GrantColumn = {
+ key: string;
+ title?: string;
+ defaultWidth: number;
+ minWidth: number;
+ sortKey?: SortKey;
+ resizable?: boolean;
+};
+
function hashCode(str: string): number {
let hash = 0;
for (let i = 0; i < str.length; i++) {
@@ -396,6 +420,66 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {
enabled: canList,
});
+ // 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: 112,
+ minWidth: 80,
+ },
+ {
+ key: "creator",
+ title: t("common.creator"),
+ defaultWidth: 200,
+ minWidth: 140,
+ sortKey: "creator",
+ },
+ {
+ key: "created",
+ title: t("common.created-at"),
+ defaultWidth: 200,
+ minWidth: 160,
+ sortKey: "create_time",
+ },
+ {
+ key: "expiration",
+ title: t("common.expiration"),
+ defaultWidth: 200,
+ minWidth: 160,
+ sortKey: "expire_time",
+ },
+ {
+ key: "statement",
+ title: t("common.statement"),
+ defaultWidth: 400,
+ minWidth: 200,
+ },
+ {
+ key: "databases",
+ title: t("common.databases"),
+ defaultWidth: 240,
+ minWidth: 160,
+ },
+ // Trailing actions column — no title (blank header), fixed
+ // width sized for two ghost buttons + "View issue".
+ { key: "actions", defaultWidth: 180, minWidth: 120, resizable: false },
+ ],
+ [t]
+ );
+
+ // User-controlled column widths so long statements / databases /
+ // expiration values aren't permanently truncated by the table's
+ // fixed-width layout. The hook owns the per-column width state and
+ // the mousedown→mousemove→mouseup drag pipeline.
+ const { widths, totalWidth, onResizeStart } = useColumnWidths(columns);
+
const handleConfirm = useCallback(async () => {
if (!confirmAction) return;
const { type, grant } = confirmAction;
@@ -457,45 +541,54 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {
</div>
) : (
<div className="px-4">
- <div className="border rounded-sm overflow-hidden">
- <Table className="table-fixed">
+ {/*
+ `overflow-x-auto` lets users drag a column past the
+ container width without clipping the trailing columns.
+ The previous `overflow-hidden` would have swallowed
+ the resized overflow.
+ */}
+ <div className="border rounded-sm overflow-x-auto">
+ <Table
+ className="table-fixed"
+ style={{ minWidth: `${totalWidth}px` }}
+ >
+ {/*
+ `<colgroup>` order mirrors `columns`, which in turn
+ mirrors the cell order inside `<AccessGrantRow>` —
+ `useColumnWidths` indexes positionally, not by key.
+ */}
+ <colgroup>
+ {widths.map((w, i) => (
+ <col key={columns[i].key} style={{ width: `${w}px` }} />
+ ))}
+ </colgroup>
<TableHeader>
<TableRow className="bg-control-bg">
- <TableHead className="w-28">
- {t("common.status")}
- </TableHead>
- <TableHead
- sortable
- sortActive={sortKey === "creator"}
- sortDir={sortDir}
- onSort={() => handleSort("creator")}
- className="w-44"
- >
- {t("common.creator")}
- </TableHead>
- <TableHead
- sortable
- sortActive={sortKey === "create_time"}
- sortDir={sortDir}
- onSort={() => handleSort("create_time")}
- className="w-44 hidden xl:table-cell"
- >
- {t("common.created-at")}
- </TableHead>
- <TableHead
- sortable
- sortActive={sortKey === "expire_time"}
- sortDir={sortDir}
- onSort={() => handleSort("expire_time")}
- className="w-44 hidden xl:table-cell"
- >
- {t("common.expiration")}
- </TableHead>
- <TableHead>{t("common.statement")}</TableHead>
- <TableHead className="w-48">
- {t("common.databases")}
- </TableHead>
- <TableHead className="w-40" />
+ {columns.map((col, colIdx) => {
+ const isSortable = col.sortKey !== undefined;
+ const isResizable = col.resizable !== false;
+ return (
+ <TableHead
+ key={col.key}
+ sortable={isSortable}
+ sortActive={isSortable && sortKey === col.sortKey}
+ sortDir={sortDir}
+ onSort={
+ isSortable
+ ? () => handleSort(col.sortKey!)
+ : undefined
+ }
+ resizable={isResizable}
+ onResizeStart={
+ isResizable
+ ? (e) => onResizeStart(colIdx, e)
+ : undefined
+ }
+ >
+ {col.title ?? null}
+ </TableHead>
+ );
+ })}
</TableRow>
</TableHeader>
<TableBody>
@@ -609,10 +702,10 @@ function AccessGrantRow({
<TableCell>
<EllipsisText text={extractUserEmail(grant.creator)} />
</TableCell>
- <TableCell className="hidden xl:table-cell">
+ <TableCell>
<EllipsisText text={createdAt} />
</TableCell>
- <TableCell className="hidden xl:table-cell">
+ <TableCell>
<EllipsisText text={expiration} />
</TableCell>
<TableCell>
diff --git a/frontend/src/react/pages/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx b/frontend/src/react/pages/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
index 5687195cb4..98ad7fc227 100644
--- a/frontend/src/react/pages/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
+++ b/frontend/src/react/pages/project/issue-detail/components/IssueDetailAccessGrantDetails.tsx
@@ -134,14 +134,23 @@ export function IssueDetailAccessGrantDetails() {
<div className="flex flex-col gap-y-1">
<span className="text-sm text-control-light">
- {expirationInfo.type === "duration"
- ? t("common.duration")
- : t("issue.access-grant.expired-at")}
+ {t("common.expiration")}
</span>
<div className="text-base">
{expirationInfo.type === "never"
? t("project.members.never-expires")
- : expirationInfo.value}
+ : expirationInfo.type === "duration"
+ ? // Pending grant — TTL is still on the proto, safe
+ // to surface as "{{duration}} after issue approved".
+ t("issue.access-grant.duration-after-approval", {
+ duration: expirationInfo.value,
+ })
+ : // Active grant — show the absolute expire datetime
+ // only. The original requested duration is gone
+ // post-activation (input-only proto field); we
+ // can't recover it without double-counting the
+ // approval wait. Bot review #3370767734.
+ expirationInfo.value}
</div>
</div>
</div>
diff --git a/frontend/src/utils/accessGrant.ts b/frontend/src/utils/accessGrant.ts
index 087bd9a073..da99cecf3a 100644
--- a/frontend/src/utils/accessGrant.ts
+++ b/frontend/src/utils/accessGrant.ts
@@ -41,10 +41,20 @@ export const getAccessGrantExpirationText = (
| { type: "duration"; value: string }
| { type: "never" } => {
if (grant.expiration.case === "expireTime") {
+ // 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
+ // `expireTime - createTime`: `createTime` is when the request was
+ // opened, not when the grant was activated, so the subtraction
+ // double-counts the approval-wait time. A 4h grant approved a day
+ // later would render as "1d4h", which misleads reviewers about
+ // the actual granted window. Show the absolute expire datetime
+ // alone instead. Bot review #3370767734.
const ms = getTimeForPbTimestampProtoEs(grant.expiration.value);
return { type: "datetime", value: formatAbsoluteDateTime(ms) };
}
if (grant.expiration.case === "ttl") {
+ // Pending grants still carry the requested TTL — safe to format.
const totalSeconds = Number(grant.expiration.value.seconds);
const dur = dayjs.duration(totalSeconds, "seconds");
const days = Math.floor(dur.asDays());