Skip to content

Commit ed6dff0

Browse files
committed
feat(control-ui): show relative commit age and hover-only copy button on About
The About page commit row now embeds the commit's committer timestamp (commitAt, advisory like branch/dirty) and renders it as an always-relative age with the exact localized date-time on hover. The copy button becomes a compact borderless icon revealed on hover/focus only where hover exists; touch keeps it visible.
1 parent d4c7549 commit ed6dff0

12 files changed

Lines changed: 142 additions & 1 deletion

‎scripts/control-ui-mock-dev.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,7 @@ const server = await createServer({
16281628
"globalThis.OPENCLAW_CONTROL_UI_BUILD_INFO": JSON.stringify({
16291629
version: "2026.7.10",
16301630
commit: "0123456789abcdef0123456789abcdef01234567",
1631+
commitAt: "2026-07-10T11:22:33.000Z",
16311632
builtAt: "2026-07-10T12:34:56.000Z",
16321633
buildId: "mock",
16331634
}),

‎ui/src/app/vite-config.node.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,30 @@ describe("Control UI Vite config", () => {
4242

4343
it("embeds one canonical artifact identity from explicit build inputs", () => {
4444
const readGitCommit = vi.fn(() => "f".repeat(40));
45+
const readGitCommitTimestamp = vi.fn(() => "2026-07-10T10:11:12.000Z");
4546
expect(
4647
resolveControlUiBuildInfo({
4748
env: {
4849
GIT_COMMIT: "0123456789abcdef0123456789abcdef01234567",
4950
OPENCLAW_BUILD_TIMESTAMP: "2026-07-10T12:34:56Z",
5051
},
5152
readGitCommit,
53+
readGitCommitTimestamp,
5254
readGitBranch: () => null,
5355
readGitDirty: () => null,
5456
readPackageVersion: () => "2026.7.10",
5557
}),
5658
).toEqual({
5759
version: "2026.7.10",
5860
commit: "0123456789abcdef0123456789abcdef01234567",
61+
commitAt: "2026-07-10T10:11:12.000Z",
5962
builtAt: "2026-07-10T12:34:56.000Z",
6063
branch: null,
6164
dirty: null,
6265
buildId: "2026.7.10-0123456789ab-2026-07-10T12-34-56.000Z",
6366
});
6467
expect(readGitCommit).not.toHaveBeenCalled();
68+
expect(readGitCommitTimestamp).toHaveBeenCalledWith("0123456789abcdef0123456789abcdef01234567");
6569
});
6670

6771
it("falls back to Git and the current UTC time only when inputs are absent", () => {
@@ -70,13 +74,15 @@ describe("Control UI Vite config", () => {
7074
env: {},
7175
now: () => new Date("2026-07-10T13:14:15.000Z"),
7276
readGitCommit: () => "a".repeat(40),
77+
readGitCommitTimestamp: () => null,
7378
readGitBranch: () => null,
7479
readGitDirty: () => null,
7580
readPackageVersion: () => null,
7681
}),
7782
).toEqual({
7883
version: null,
7984
commit: "a".repeat(40),
85+
commitAt: null,
8086
builtAt: "2026-07-10T13:14:15.000Z",
8187
branch: null,
8288
dirty: null,

‎ui/src/build-info-normalizers.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function normalizeControlUiBuildInfo(value: unknown): ControlUiBuildInfo
6060
const metadata = { version, commit, builtAt };
6161
return {
6262
...metadata,
63+
commitAt: normalizeControlUiBuildTimestamp(record.commitAt),
6364
branch: normalizeControlUiBranch(record.branch),
6465
dirty: typeof record.dirty === "boolean" ? record.dirty : null,
6566
buildId: normalizeControlUiBuildId(record.buildId ?? deriveControlUiBuildId(metadata)),

‎ui/src/build-info-types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type ControlUiBuildInfo = Readonly<{
22
version: string | null;
33
commit: string | null;
4+
commitAt: string | null;
45
builtAt: string | null;
56
branch: string | null;
67
dirty: boolean | null;

‎ui/src/build-info.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ describe("Control UI build info", () => {
4242
expect(
4343
normalizeControlUiBuildInfo({ builtAt: "2026-07-10T12:34:56+00:00" }).builtAt,
4444
).toBeNull();
45+
expect(normalizeControlUiBuildInfo({ commitAt: "2026-07-10T11:22:33Z" }).commitAt).toBe(
46+
"2026-07-10T11:22:33.000Z",
47+
);
48+
expect(
49+
normalizeControlUiBuildInfo({ commitAt: "2026-07-10T11:22:33+02:00" }).commitAt,
50+
).toBeNull();
4551
});
4652

4753
it("renders invalid injected metadata as unavailable instead of inventing identity", () => {
4854
expect(
4955
normalizeControlUiBuildInfo({
5056
version: " ",
5157
commit: "deadbeef",
58+
commitAt: "later",
5259
builtAt: "later",
5360
branch: "HEAD",
5461
dirty: "yes",
@@ -57,6 +64,7 @@ describe("Control UI build info", () => {
5764
).toEqual({
5865
version: null,
5966
commit: null,
67+
commitAt: null,
6068
builtAt: null,
6169
branch: null,
6270
dirty: null,

‎ui/src/components/sidebar-build-chip.node.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function buildInfo(overrides: Partial<ControlUiBuildInfo> = {}): ControlUiBuildI
99
return {
1010
version: "2026.7.10",
1111
commit: COMMIT,
12+
commitAt: null,
1213
builtAt: BUILT_AT,
1314
branch: "main",
1415
dirty: false,

‎ui/src/e2e/build-info-unicode.e2e.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describeControlUiE2e("Control UI Unicode build identity mocked Gateway E2E", ()
8181
server = await startControlUiE2eServer({
8282
version: "2026.7.10",
8383
commit: "0123456789abcdef0123456789abcdef01234567",
84+
commitAt: "2026-07-10T11:22:33.000Z",
8485
builtAt: "2026-07-10T12:34:56.000Z",
8586
branch: RAW_BRANCH,
8687
dirty: true,

‎ui/src/pages/about/view.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { renderAbout } from "./view.ts";
88
type AboutProps = Parameters<typeof renderAbout>[0];
99

1010
const COMMIT = "0123456789abcdef0123456789abcdef01234567";
11+
const COMMIT_AT = "2026-07-10T11:22:33.000Z";
1112
const BUILT_AT = "2026-07-10T12:34:56.000Z";
1213

1314
function createProps(overrides: Partial<AboutProps> = {}): AboutProps {
1415
return {
1516
buildInfo: {
1617
version: "2026.7.10",
1718
commit: COMMIT,
19+
commitAt: COMMIT_AT,
1820
builtAt: BUILT_AT,
1921
branch: "feature/build-chip",
2022
dirty: true,
@@ -91,6 +93,15 @@ describe("renderAbout", () => {
9193
expect(values?.[1]?.querySelector("code")?.getAttribute("title")).toBe(COMMIT);
9294
expect(values?.[1]?.querySelector("code")?.getAttribute("dir")).toBe("ltr");
9395

96+
const commitAge = values?.[1]?.querySelector("time.about-commit__age");
97+
expect(commitAge?.getAttribute("datetime")).toBe(COMMIT_AT);
98+
expect(commitAge?.textContent?.trim()).not.toBe("");
99+
expect(commitAge?.getAttribute("title")).toBe(
100+
new Intl.DateTimeFormat("en", { dateStyle: "medium", timeStyle: "short" }).format(
101+
new Date(COMMIT_AT),
102+
),
103+
);
104+
94105
expect(values?.[2]?.textContent).toContain("feature/build-chip*");
95106

96107
const time = values?.[3]?.querySelector("time");
@@ -104,6 +115,15 @@ describe("renderAbout", () => {
104115
);
105116
});
106117

118+
it("keeps the commit hash without an age when no commit timestamp is embedded", () => {
119+
const container = document.createElement("div");
120+
const props = createProps();
121+
render(renderAbout({ ...props, buildInfo: { ...props.buildInfo, commitAt: null } }), container);
122+
123+
expect(container.querySelector(".about-commit code")?.textContent).toBe(COMMIT.slice(0, 12));
124+
expect(container.querySelector(".about-commit__age")).toBeNull();
125+
});
126+
107127
it("keeps the connected Gateway version separate from the browser artifact", () => {
108128
const container = document.createElement("div");
109129
render(renderAbout(createProps()), container);
@@ -136,6 +156,7 @@ describe("renderAbout", () => {
136156
buildInfo: {
137157
version: null,
138158
commit: null,
159+
commitAt: null,
139160
builtAt: null,
140161
branch: null,
141162
dirty: null,

‎ui/src/pages/about/view.ts‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import "../../components/tooltip.ts";
1818
import { i18n, t } from "../../i18n/index.ts";
1919
import { buildExternalLinkRel, EXTERNAL_LINK_TARGET } from "../../lib/external-link.ts";
20+
import { formatRelativeTimestamp } from "../../lib/format.ts";
2021
import "../../styles/about.css";
2122
import { brandIcons } from "./brand-icons.ts";
2223

@@ -102,6 +103,27 @@ function renderUnavailable() {
102103
return html`<span class="muted">${t("aboutPage.unavailable")}</span>`;
103104
}
104105

106+
// Always-relative commit age; the exact localized timestamp lives on hover
107+
// (title) so the row stays compact for any artifact age.
108+
function renderCommitAge(commitAt: string | null) {
109+
if (!commitAt) {
110+
return nothing;
111+
}
112+
const timestamp = Date.parse(commitAt);
113+
if (!Number.isFinite(timestamp)) {
114+
return nothing;
115+
}
116+
const exact = new Intl.DateTimeFormat(i18n.getLocale(), {
117+
dateStyle: "medium",
118+
timeStyle: "short",
119+
}).format(new Date(timestamp));
120+
return html`
121+
<time class="about-commit__age" dir="auto" datetime=${commitAt} title=${exact}
122+
>${formatRelativeTimestamp(timestamp, { fallback: "" })}</time
123+
>
124+
`;
125+
}
126+
105127
function renderCommit(props: AboutProps) {
106128
const commit = props.buildInfo.commit;
107129
if (!commit) {
@@ -114,7 +136,7 @@ function renderCommit(props: AboutProps) {
114136
<openclaw-tooltip .content=${label}>
115137
<button
116138
type="button"
117-
class="btn btn--icon"
139+
class="about-commit__copy"
118140
aria-label=${label}
119141
aria-busy=${props.copyState === "copying" ? "true" : nothing}
120142
?disabled=${props.copyState === "copying"}
@@ -123,6 +145,7 @@ function renderCommit(props: AboutProps) {
123145
<span aria-hidden="true">${props.copyState === "copied" ? icons.check : icons.copy}</span>
124146
</button>
125147
</openclaw-tooltip>
148+
${renderCommitAge(props.buildInfo.commitAt)}
126149
<span class="about-sr-only" role="status" aria-live="polite"
127150
>${copyStatus(props.copyState)}</span
128151
>

‎ui/src/styles/about.css‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,59 @@
233233
user-select: all;
234234
}
235235

236+
/* Borderless inline copy affordance; kept tiny so the hash stays the focus. */
237+
.about-commit__copy {
238+
display: inline-flex;
239+
align-items: center;
240+
justify-content: center;
241+
padding: 3px;
242+
border: 0;
243+
border-radius: 6px;
244+
background: transparent;
245+
color: var(--muted);
246+
cursor: pointer;
247+
transition:
248+
opacity var(--duration-fast, 120ms) ease,
249+
color var(--duration-fast, 120ms) ease,
250+
background var(--duration-fast, 120ms) ease;
251+
}
252+
253+
.about-commit__copy:hover,
254+
.about-commit__copy:focus-visible {
255+
color: var(--text-strong);
256+
background: var(--bg-hover);
257+
}
258+
259+
.about-commit__copy svg {
260+
display: block;
261+
width: 14px;
262+
height: 14px;
263+
stroke: currentColor;
264+
fill: none;
265+
stroke-width: 1.5px;
266+
stroke-linecap: round;
267+
stroke-linejoin: round;
268+
}
269+
270+
/* Hover-revealed only where hover exists; touch/keyboard keep it visible
271+
(focus-within covers tabbing, coarse pointers never match the media query). */
272+
@media (hover: hover) and (pointer: fine) {
273+
.about-commit .about-commit__copy {
274+
opacity: 0;
275+
}
276+
277+
.about-commit:hover .about-commit__copy,
278+
.about-commit:focus-within .about-commit__copy {
279+
opacity: 1;
280+
}
281+
}
282+
283+
.about-commit__age {
284+
color: var(--muted);
285+
font-size: var(--control-ui-text-xs, 12px);
286+
white-space: nowrap;
287+
}
288+
236289
/* Screen-reader-only live region for copy feedback (no shared utility yet). */
237290
.about-sr-only {
238291
position: absolute;

0 commit comments

Comments
 (0)