Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: shared code leaves page folders; SectionHeading and Preformatted replace per-page copies

durationLabel moves to util.ts, termPaths to agent/terminal/term-paths.ts,
StateBadges and tokenTotal to agent/state, and TryOutResult to
pages/review-common, so the builds, runs and agent pages no longer import
across page folders. SectionHeading is the body-size section heading the
create form and the egress card each styled; Preformatted is the scrolling
text block of the builds tail and the AGENTS.md view, which now share one
chrome and are both keyboard-scrollable. The components page shows both.
This commit is contained in:
iris 2026-11-06 19:09:18 +01:00
commit 5d5df29687

View file

@ -31,3 +31,13 @@ export function fmtAgo(ageSeconds: number): string {
if (age < 86400) return RTF.format(-Math.floor(age / 3600), "hour");
return RTF.format(-Math.floor(age / 86400), "day");
}
/** How long a run took, as `45s`, `3m 12s` or `1h 4m`. A clock that ran
* backwards reads as `0s`. */
export function durationLabel(startedUnix: number, finishedUnix: number) {
const total = Math.max(0, Math.round(finishedUnix - startedUnix));
if (total < 60) return `${total}s`;
const minutes = Math.floor(total / 60);
if (minutes < 60) return `${minutes}m ${total % 60}s`;
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
}