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:
parent
4bd81d5b0f
commit
5d5df29687
2 changed files with 295 additions and 200 deletions
|
|
@ -21,13 +21,13 @@ import {
|
|||
} from "../../ui/refresh-interval/RefreshInterval.js";
|
||||
import { fetchJson, usePolled } from "../../ui/polled/usePolled.js";
|
||||
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
|
||||
import { TryOutResult } from "../review-tryout/TryOutResult.js";
|
||||
import { TryOutResult } from "../review-common/TryOutResult.js";
|
||||
import { durationLabel } from "../../util.js";
|
||||
import {
|
||||
OUTCOME_LABEL,
|
||||
OUTCOME_TONE,
|
||||
TRIGGER_LABEL,
|
||||
classificationCount,
|
||||
durationLabel,
|
||||
type ClassifierRun,
|
||||
} from "./RunsTypes.js";
|
||||
import "./ReviewRuns.css";
|
||||
|
|
|
|||
|
|
@ -60,16 +60,6 @@ export const TRIGGER_LABEL: Record<RunTrigger, string> = {
|
|||
review: "requested review",
|
||||
};
|
||||
|
||||
/** 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`;
|
||||
}
|
||||
|
||||
/** How many classifications ran, in words. A run that never got as far as
|
||||
* running any has no rows. */
|
||||
export function classificationCount(run: ClassifierRun): string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue