Skip to content

Commit 895727f

Browse files
fix(web): pull request comment tooltips keep their date layout and seconds
Only the hour cycle follows Time format; System default renders exactly as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 671473a commit 895727f

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.browser.test.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,8 @@ it("shows a comment's exact time in the chosen 24-hour clock", async () => {
265265
await using screen = await render({ ...detail, comments: [comment], commentCount: 1 });
266266

267267
await userEvent.hover(screen.container.querySelector(`time[datetime="${createdAt}"]`)!);
268-
const date = new Date(createdAt);
269-
const clock = `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
268+
const expected = new Date(createdAt).toLocaleString(undefined, { hour12: false });
270269
await vi.waitFor(() =>
271-
expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toContain(clock),
270+
expect(document.querySelector('[data-slot="tooltip-popup"]')?.textContent).toBe(expected),
272271
);
273-
expect(document.querySelector('[data-slot="tooltip-popup"]')!.textContent).not.toMatch(/AM|PM/i);
274272
});

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { cn } from "~/lib/utils";
3535
import { useOpenLink } from "~/browser/useOpenLink";
3636
import { RelativeTime } from "~/components/RelativeTime";
3737
import { useClientSettings } from "~/hooks/useSettings";
38-
import { formatChatTimestampTooltip } from "~/timestampFormat";
38+
import { formatFullTimestamp } from "~/timestampFormat";
3939

4040
import { Button } from "../ui/button";
4141
import { PullRequestEditButton } from "./PullRequestEditButton";
@@ -140,7 +140,7 @@ function CommentIdentity({
140140
</time>
141141
</TooltipTrigger>
142142
<TooltipPopup>
143-
{formatChatTimestampTooltip(comment.createdAt, timestampFormat)}
143+
{formatFullTimestamp(comment.createdAt, timestampFormat)}
144144
{comment.url ? " · Open comment on host" : ""}
145145
</TooltipPopup>
146146
</Tooltip>

‎apps/web/src/timestampFormat.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ export function formatChatTimestampTooltip(
131131
return `${time}, ${day}${ordinalSuffix(day)} ${month} ${year}`;
132132
}
133133

134+
export function formatFullTimestamp(isoDate: string, timestampFormat: TimestampFormat): string {
135+
return new Date(isoDate).toLocaleString(
136+
undefined,
137+
timestampFormat === "locale" ? undefined : { hour12: timestampFormat === "12-hour" },
138+
);
139+
}
140+
134141
export function formatShortTimestamp(isoDate: string, timestampFormat: TimestampFormat): string {
135142
const date = parseTimestampDate(isoDate);
136143
if (!date) return "";

0 commit comments

Comments
 (0)