Skip to content

Commit 4bf1166

Browse files
fix: localize catalog dates after hydration
1 parent 1002da8 commit 4bf1166

6 files changed

Lines changed: 88 additions & 58 deletions

File tree

‎e2e/local-auth/skill-hero-metadata.pw.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,40 @@ function seedMetadataSkill() {
4141
}
4242
}
4343

44+
test.describe("skill date hydration", () => {
45+
test.use({ locale: "en-GB", timezoneId: "America/Los_Angeles" });
46+
47+
test("hydrates the UTC skill date before showing the visitor's local date", async ({ page }) => {
48+
seedMetadataSkill();
49+
const errors = trackRuntimeErrors(page);
50+
const response = await page.goto(buildSkillDetailHref("local", "local-agentic-risk-demo"));
51+
expect(response?.status()).toBe(200);
52+
const selector = '[aria-label="Skill metadata"] time[datetime]';
53+
const server = await page.evaluate(
54+
({ html, selector }) => {
55+
const time = new DOMParser().parseFromString(html, "text/html").querySelector(selector);
56+
return { iso: time?.getAttribute("datetime"), label: time?.textContent };
57+
},
58+
{ html: await response!.text(), selector },
59+
);
60+
expect(server.iso).toBeTruthy();
61+
const date = new Date(server.iso!);
62+
expect(server.label).toBe(
63+
new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeZone: "UTC" }).format(date),
64+
);
65+
await waitForHydration(page);
66+
const time = page.locator(selector);
67+
await expect(time).toHaveAttribute("datetime", server.iso!);
68+
await expect(time).toHaveText(
69+
new Intl.DateTimeFormat("en-GB", {
70+
dateStyle: "medium",
71+
timeZone: "America/Los_Angeles",
72+
}).format(date),
73+
);
74+
await expectHealthyPage(page, errors);
75+
});
76+
});
77+
4478
test("owner metadata save persists categories and topics after reload", async ({ page }) => {
4579
seedMetadataSkill();
4680
const errors = trackRuntimeErrors(page);

‎specs/plugin-skill-detail-polish-iteration.md‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,19 @@ This note preserves the complete UI direction established during the June 2026 d
191191

192192
## Identity-only native Install handoff
193193

194-
The install card lives in the desktop right rail, not the hero. The existing
195-
flat terminal toggle becomes **CLI | Desktop**, with the same vertical divider,
196-
type and active text treatment. Eligible hosted skills, plugins and Templates
197-
open on CLI, with the existing command shell, `$` marker, syntax treatment and
198-
inline copy icon and no separate Copy bar; the Desktop tab holds the red,
199-
text-only **Install in OpenClaw** CTA. CLI comes first for now because the page
200-
cannot tell whether the installed desktop app handles the link, and released
201-
builds do not all handle it yet. Make Desktop the default again once they do. There is no
202-
platform label, icon, helper copy or secondary download CTA. The card appears
203-
once before content on mobile (900px and below). The Install heading has no
204-
horizontal divider; its content-height row has no leftover divider padding or
205-
fixed metadata-row height, with a compact 12px gap to either panel. A matching
206-
1px metadata divider sits below the complete install section, above Downloads
207-
(or the next metadata row), centered in the existing 24px right-rail gap. It
208-
does not add spacing or appear on the standalone mobile install card.
194+
The public catalog detail header owns the install action at every viewport.
195+
Plugins use **Install**, Templates use **Add**, and hosted skills use **Add**
196+
when eligible or **Install options** when only fallback instructions are available.
197+
Opening the action shows one install dialog; it neither launches OpenClaw nor
198+
installs anything. The desktop rail contains metadata and listing utilities,
199+
not a second install card. Mobile uses the same action, not a duplicate card
200+
before the content. Blocked Templates keep their repair guidance on the page.
201+
202+
For eligible hosted listings, the dialog opens on **CLI** and the **Desktop**
203+
tab holds the text-only **Install in OpenClaw** link. CLI comes first because
204+
the website cannot detect whether the installed app supports the handoff. Keep
205+
the flat CLI | Desktop toggle and the command shell with its `$` marker and
206+
inline copy icon; do not add a separate Copy bar or secondary download CTA.
209207
CLI commands stay on one line and truncate with an ellipsis;
210208
hover or keyboard focus shows the full command in a viewport-bounded tooltip.
211209
Copy always uses the complete command. Switching tabs does not launch the app

‎src/__tests__/package-detail-route.test.tsx‎

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -287,37 +287,33 @@ describe("plugin detail route", () => {
287287
expect(screen.queryByRole("dialog")).toBeNull();
288288
});
289289

290-
it.each([390, 768, 900, 901, 1366, 1440])(
291-
"keeps the same header, inline README and metadata rail at %ipx",
292-
async (width) => {
293-
setViewportWidth(width);
294-
loaderDataMock.detail.package!.latestVersion = "1.0.0";
295-
loaderDataMock.readme = "Getting started with Demo";
296-
const route = await loadRoute();
297-
const Component = route.__config.component as ComponentType;
298-
render(<Component />);
290+
it("renders one install action, inline README and package details in the metadata rail", async () => {
291+
loaderDataMock.detail.package!.latestVersion = "1.0.0";
292+
loaderDataMock.readme = "Getting started with Demo";
293+
const route = await loadRoute();
294+
const Component = route.__config.component as ComponentType;
295+
render(<Component />);
299296

300-
const heading = screen.getByRole("heading", { level: 1, name: "Demo Plugin" });
301-
const hero = heading.closest<HTMLElement>(".catalog-detail__hero");
302-
expect(hero?.closest(".catalog-detail")).toBeTruthy();
303-
expect(within(hero!).getAllByRole("button")).toEqual([
304-
within(hero!).getByRole("button", { name: "Install" }),
305-
]);
306-
expect(within(hero!).queryByRole("link", { name: "Download" })).toBeNull();
307-
const detailsTrigger = within(screen.getByRole("complementary")).getByRole("button", {
308-
name: "Package details",
309-
});
310-
expect(detailsTrigger.textContent).toBe("Package details");
311-
expect(screen.queryByRole("tablist")).toBeNull();
312-
expect(screen.getByText("Getting started with Demo")).toBeTruthy();
313-
expect(
314-
within(screen.getByRole("complementary")).getByRole("group", { name: "Plugin metadata" }),
315-
).toBeTruthy();
316-
expect(
317-
within(openPackageDetails()).getByRole("link", { name: "Download" }).getAttribute("href"),
318-
).toBe("/api/v1/packages/demo-plugin/download?version=1.0.0");
319-
},
320-
);
297+
const heading = screen.getByRole("heading", { level: 1, name: "Demo Plugin" });
298+
const hero = heading.closest<HTMLElement>(".catalog-detail__hero");
299+
expect(hero?.closest(".catalog-detail")).toBeTruthy();
300+
expect(within(hero!).getAllByRole("button")).toEqual([
301+
within(hero!).getByRole("button", { name: "Install" }),
302+
]);
303+
expect(within(hero!).queryByRole("link", { name: "Download" })).toBeNull();
304+
const detailsTrigger = within(screen.getByRole("complementary")).getByRole("button", {
305+
name: "Package details",
306+
});
307+
expect(detailsTrigger.textContent).toBe("Package details");
308+
expect(screen.queryByRole("tablist")).toBeNull();
309+
expect(screen.getByText("Getting started with Demo")).toBeTruthy();
310+
expect(
311+
within(screen.getByRole("complementary")).getByRole("group", { name: "Plugin metadata" }),
312+
).toBeTruthy();
313+
expect(
314+
within(openPackageDetails()).getByRole("link", { name: "Download" }).getAttribute("href"),
315+
).toBe("/api/v1/packages/demo-plugin/download?version=1.0.0");
316+
});
321317

322318
it.each([
323319
{ family: "bundle-plugin", name: "discord", href: "openclaw://plugins/install?name=discord" },

‎src/components/CatalogDetailLayout.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import { ChevronRight } from "lucide-react";
2-
import { type ReactNode, useId } from "react";
2+
import { type ReactNode, useEffect, useId, useState } from "react";
33
import { cn } from "../lib/utils";
44
import "./catalog-detail-layout.css";
55

6+
const serverDate = new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeZone: "UTC" });
7+
8+
export function useCatalogDateFormatter() {
9+
// The first client render must match the server, even across a calendar-day boundary.
10+
const [formatter, setFormatter] = useState(serverDate);
11+
useEffect(() => setFormatter(new Intl.DateTimeFormat(undefined, { dateStyle: "medium" })), []);
12+
return formatter;
13+
}
14+
615
// Keep the public detail views on one rail, like Control UI's PluginDetailShell.
716
export function CatalogDetailLayout(props: {
817
breadcrumb: ReactNode;

‎src/components/PluginCatalogRail.tsx‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ArrowUpRight, Pencil, Plus } from "lucide-react";
2-
import { useEffect, useState } from "react";
32
import {
43
buildPluginCategoryBrowseHref,
54
buildPluginTopicBrowseHref,
@@ -9,7 +8,7 @@ import {
98
import type { PackageDetailResponse, PackageVersionDetail } from "../lib/packageApi";
109
import { buildPluginSecurityAuditHref } from "../lib/pluginRoutes";
1110
import { GitHubIcon } from "./BrandIcons";
12-
import { CatalogDetailFact } from "./CatalogDetailLayout";
11+
import { CatalogDetailFact, useCatalogDateFormatter } from "./CatalogDetailLayout";
1312
import { DetailSecuritySummary, DetailSecuritySummaryLabel } from "./DetailSecuritySummary";
1413

1514
function repositoryLink(raw: string | undefined) {
@@ -60,7 +59,6 @@ function compactCount(value: number) {
6059
(scale === 1_000 ? "k" : scale === 1_000_000 ? "m" : "b")
6160
);
6261
}
63-
const serverDate = new Intl.DateTimeFormat("en-US", { dateStyle: "medium", timeZone: "UTC" });
6462

6563
export function PluginCatalogRail({
6664
pkg,
@@ -73,12 +71,7 @@ export function PluginCatalogRail({
7371
ownerHandle?: string | null;
7472
onEditTopics?: () => void;
7573
}) {
76-
// Hydrate the server's UTC text before switching to the same local calendar as Control UI.
77-
const [publishedDate, setPublishedDate] = useState(serverDate);
78-
useEffect(
79-
() => setPublishedDate(new Intl.DateTimeFormat(undefined, { dateStyle: "medium" })),
80-
[],
81-
);
74+
const publishedDate = useCatalogDateFormatter();
8275
const categories = (pkg.categories ?? []).flatMap(
8376
(value) => getPluginCategoryBySlug(value) ?? [],
8477
);

‎src/components/SkillDetailPageView.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
CatalogDetailLayout,
2525
CatalogDetailFact,
2626
CatalogDetailBreadcrumb,
27+
useCatalogDateFormatter,
2728
} from "./CatalogDetailLayout";
2829
import { DETAIL_HERO_TOPIC_LIMIT } from "./DetailPageShell";
2930
import { DetailSecuritySummary, DetailSecuritySummaryLabel } from "./DetailSecuritySummary";
@@ -387,6 +388,7 @@ export function SkillDetailPageView({
387388
const repository = getGitHubRepositoryLink(skill);
388389
const linkedIdentity = ownerHandle || owner?.displayName;
389390
const platforms = (latestVersion?.parsed?.clawdis as ClawdisSkillMetadata | undefined)?.os;
391+
const dateFormatter = useCatalogDateFormatter();
390392
const updatedAt = new Date(skill.updatedAt);
391393
const fullDescription = getLatestVersionDescription(latestVersion);
392394
const identity = (
@@ -644,9 +646,7 @@ export function SkillDetailPageView({
644646
{Number.isFinite(updatedAt.valueOf()) && (
645647
<CatalogDetailFact label="Updated">
646648
<time dateTime={updatedAt.toISOString()}>
647-
{updatedAt.toLocaleDateString(undefined, {
648-
dateStyle: "medium",
649-
})}
649+
{dateFormatter.format(updatedAt)}
650650
</time>
651651
</CatalogDetailFact>
652652
)}

0 commit comments

Comments
 (0)