Skip to content

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

refactor(frontend): let absence flow through instead of restating it

zchpeter15c228911dad
diff --git a/frontend/src/components/HumanizeTs.tsx b/frontend/src/components/HumanizeTs.tsx
index 3a59942620..589900a6bc 100644
--- a/frontend/src/components/HumanizeTs.tsx
+++ b/frontend/src/components/HumanizeTs.tsx
@@ -27,8 +27,8 @@ import {
export type TimeDisplayMode = "queue" | "compact" | "operational" | "datetime";
interface HumanizeTsProps {
- /** The instant to show, in milliseconds. */
- tsMs: number;
+ /** The instant to show, in milliseconds; nothing renders without one. */
+ tsMs: number | undefined;
mode?: TimeDisplayMode;
className?: string;
/**
diff --git a/frontend/src/components/issue-activity/IssueCommentActivity.tsx b/frontend/src/components/issue-activity/IssueCommentActivity.tsx
index e44bc7ef87..1512d4a30d 100644
--- a/frontend/src/components/issue-activity/IssueCommentActivity.tsx
+++ b/frontend/src/components/issue-activity/IssueCommentActivity.tsx
@@ -218,8 +218,8 @@ function IssueCommentHeader({
const { t } = useTranslation();
const creator =
useUserByIdentifier(comment.creator) ?? unknownUser(comment.creator);
- const createdTs = getTimeForPbTimestampProtoEs(comment.createTime, 0);
- const updatedTs = getTimeForPbTimestampProtoEs(comment.updateTime, 0);
+ const createdTs = getTimeForPbTimestampProtoEs(comment.createTime);
+ const updatedTs = getTimeForPbTimestampProtoEs(comment.updateTime);
const isEdited =
createdTs !== updatedTs &&
getIssueCommentType(comment) === IssueCommentType.USER_COMMENT;
@@ -239,9 +239,7 @@ function IssueCommentHeader({
{t("activity.n-similar-activities", { count: similarCount })}
</Badge>
)}
- {comment.createTime && (
- <HumanizeTs className="text-xs text-control-light" tsMs={createdTs} />
- )}
+ <HumanizeTs className="text-xs text-control-light" tsMs={createdTs} />
{isEdited && (
<span className="text-control-light text-xs">
({t("common.edited")})
diff --git a/frontend/src/components/plan-check/PlanCheckSection.tsx b/frontend/src/components/plan-check/PlanCheckSection.tsx
index 4d30e79001..7adaeae575 100644
--- a/frontend/src/components/plan-check/PlanCheckSection.tsx
+++ b/frontend/src/components/plan-check/PlanCheckSection.tsx
@@ -359,14 +359,12 @@ export function PlanCheckResultsDrawer({
<CircleQuestionMark className="h-4 w-4 text-control-light" />
</Tooltip>
)}
- {group.createTime && (
- <HumanizeTs
- className="text-xs text-control-light"
- tsMs={getTimeForPbTimestampProtoEs(
- group.createTime
- )}
- />
- )}
+ <HumanizeTs
+ className="text-xs text-control-light"
+ tsMs={getTimeForPbTimestampProtoEs(
+ group.createTime
+ )}
+ />
</div>
</div>
{group.target && (
diff --git a/frontend/src/components/task-run-log/SectionContent.tsx b/frontend/src/components/task-run-log/SectionContent.tsx
index 8946c7ad79..b7060a5c32 100644
--- a/frontend/src/components/task-run-log/SectionContent.tsx
+++ b/frontend/src/components/task-run-log/SectionContent.tsx
@@ -9,8 +9,7 @@ import type { Section } from "./types";
// The full reading is offered only for an instant the formatters can render.
const fullTime = (timeMs: number | undefined) => {
- const instantMs =
- timeMs === undefined ? undefined : displayableInstantMs(timeMs);
+ const instantMs = displayableInstantMs(timeMs);
return instantMs === undefined ? undefined : (
<FullDateTime tsMs={instantMs} />
);
diff --git a/frontend/src/modules/sql-editor/components/HistoryPane.tsx b/frontend/src/modules/sql-editor/components/HistoryPane.tsx
index 206e9a7d96..59562933da 100644
--- a/frontend/src/modules/sql-editor/components/HistoryPane.tsx
+++ b/frontend/src/modules/sql-editor/components/HistoryPane.tsx
@@ -197,13 +197,11 @@ export function HistoryPane() {
>
<div className="w-full flex flex-row justify-between items-center">
<div className="flex items-start gap-x-1">
- {history.createTime && (
- <HumanizeTs
- className="text-xs text-control-placeholder"
- mode="compact"
- tsMs={getTimeForPbTimestampProtoEs(history.createTime)}
- />
- )}
+ <HumanizeTs
+ className="text-xs text-control-placeholder"
+ mode="compact"
+ tsMs={getTimeForPbTimestampProtoEs(history.createTime)}
+ />
</div>
<div className="flex items-center gap-x-1">
<Button
diff --git a/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx b/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
index e4d947a8bc..0c51a9ef0e 100644
--- a/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
+++ b/frontend/src/routes/project/ProjectMaskingExemptionPage.tsx
@@ -1108,7 +1108,8 @@ function ExemptionGrantSection({
)}
/>
<span className="font-medium text-sm">{title}</span>
- {!grant.expirationTimestamp || !daysLeft ? (
+ {/* No reading means no expiry: zero is this API's "never". */}
+ {!daysLeft ? (
<span className="text-xs font-medium text-amber-600">
{t("settings.sensitive-data.never-expires")}
</span>
diff --git a/frontend/src/routes/project/issue-detail/components/IssueDetailCommentList.tsx b/frontend/src/routes/project/issue-detail/components/IssueDetailCommentList.tsx
index 0ea7bffe0a..369cd77d9f 100644
--- a/frontend/src/routes/project/issue-detail/components/IssueDetailCommentList.tsx
+++ b/frontend/src/routes/project/issue-detail/components/IssueDetailCommentList.tsx
@@ -423,15 +423,12 @@ function IssueDescriptionCommentRow({
<span className="wrap-break-word min-w-0 text-control">
{t("activity.sentence.created-issue")}
</span>
- {page.issue?.createTime && (
- <HumanizeTs
- className="text-control-light"
- tsMs={getTimeForPbTimestampProtoEs(
- page.issue.createTime,
- 0
- )}
- />
- )}
+ <HumanizeTs
+ className="text-control-light"
+ tsMs={getTimeForPbTimestampProtoEs(
+ page.issue?.createTime
+ )}
+ />
</div>
{allowEdit && !isEditing && (
<Button
diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
index 4222d4cb59..f19a12c55d 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
@@ -418,12 +418,10 @@ function ThreadSummary({
{t("plan.review.thread.n-replies", { count: thread.replies.length })}
</span>
)}
- {thread.root.createTime && (
- <HumanizeTs
- className="hidden shrink-0 text-xs text-control-light sm:inline"
- tsMs={getTimeForPbTimestampProtoEs(thread.root.createTime)}
- />
- )}
+ <HumanizeTs
+ className="hidden shrink-0 text-xs text-control-light sm:inline"
+ tsMs={getTimeForPbTimestampProtoEs(thread.root.createTime)}
+ />
<Badge className="shrink-0 gap-x-1 px-2 text-xs" variant="success">
<CircleCheck className="size-3" />
{t("plan.review.thread.resolved")}
diff --git a/frontend/src/routes/project/plan-detail/components/threads/ThreadComment.tsx b/frontend/src/routes/project/plan-detail/components/threads/ThreadComment.tsx
index 948d560ba5..039cc50704 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/ThreadComment.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/ThreadComment.tsx
@@ -34,8 +34,8 @@ export function ThreadComment({
const { t } = useTranslation();
const creator =
useUserByIdentifier(comment.creator) ?? unknownUser(comment.creator);
- const createdTs = getTimeForPbTimestampProtoEs(comment.createTime, 0);
- const updatedTs = getTimeForPbTimestampProtoEs(comment.updateTime, 0);
+ const createdTs = getTimeForPbTimestampProtoEs(comment.createTime);
+ const updatedTs = getTimeForPbTimestampProtoEs(comment.updateTime);
const isEdited = createdTs !== updatedTs;
const [isEditing, setIsEditing] = useState(false);
const [draft, setDraft] = useState(comment.comment);
@@ -87,12 +87,10 @@ export function ThreadComment({
{creator.title || creator.email}
</span>
</div>
- {comment.createTime && (
- <HumanizeTs
- className="hidden shrink-0 whitespace-nowrap text-xs text-control-light @2xs/comment:inline"
- tsMs={createdTs}
- />
- )}
+ <HumanizeTs
+ className="hidden shrink-0 whitespace-nowrap text-xs text-control-light @2xs/comment:inline"
+ tsMs={createdTs}
+ />
{isEdited && (
<span className="hidden shrink-0 whitespace-nowrap text-xs text-control-light @2xs/comment:inline">
({t("common.edited")})
diff --git a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx
index e9239abe8e..7c45d43b13 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx
@@ -221,12 +221,10 @@ function CollapsedThreadRow({
</span>
</span>
)}
- {comment.createTime && (
- <HumanizeTs
- className="hidden shrink-0 text-xs text-control-light @xl:inline"
- tsMs={getTimeForPbTimestampProtoEs(comment.createTime)}
- />
- )}
+ <HumanizeTs
+ className="hidden shrink-0 text-xs text-control-light @xl:inline"
+ tsMs={getTimeForPbTimestampProtoEs(comment.createTime)}
+ />
{resolved && (
<Badge className="shrink-0 gap-x-1 px-2 text-xs" variant="success">
<CircleCheck className="size-3" />
diff --git a/frontend/src/utils/datetime.ts b/frontend/src/utils/datetime.ts
index 5037058556..e16812ee18 100644
--- a/frontend/src/utils/datetime.ts
+++ b/frontend/src/utils/datetime.ts
@@ -20,10 +20,12 @@ const MAX_TIME_VALUE_MS = 8.64e15;
* throws. A display asks here rather than testing a value itself, which is how
* a guard drifts from the domain it guards.
*/
-export function displayableInstantMs(ms: number): number | undefined {
- return Number.isFinite(ms) && Math.abs(ms) <= MAX_TIME_VALUE_MS
- ? ms
- : undefined;
+export function displayableInstantMs(
+ ms: number | undefined
+): number | undefined {
+ // NaN and the infinities all fail the range test, so this is the whole
+ // domain. Absence passes through it rather than being tested for twice.
+ return ms !== undefined && Math.abs(ms) <= MAX_TIME_VALUE_MS ? ms : undefined;
}
function getActiveLocale(): string {