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
2 changed files with 295 additions and 200 deletions

View file

@ -0,0 +1,8 @@
/* A finished run's table, the overall verdict under it and the head commit. */
.ui-tryout-overall,
.ui-tryout-sha {
margin: 0.75em 0 0;
}
.ui-tryout-sha {
color: var(--muted);
}

View file

@ -0,0 +1,102 @@
// <TryOutResult> — a finished try-out: one row per classification, the
// overall verdict under them, and the head commit the run read. One column per
// field of a row, where the posted review folds them into four
// (`docs/4-implementation/swarm/review-classifier.md`); no token
// counts, cache counts or cost, here or anywhere in the UI.
import { Badge } from "@hive/shared/badge.js";
import { Hint } from "../../ui/hint/Hint.js";
import { Table, type TableColumn } from "../../ui/table/Table.js";
import type {
TryOutResult as Result,
TryOutRow,
} from "../review-tryout/TryOutTypes.js";
import "./TryOutResult.css";
const VERDICT_LABEL: Record<TryOutRow["verdict"], string> = {
match: "match",
"no-match": "no match",
"not-applicable": "not applicable",
};
const COLUMNS: TableColumn<TryOutRow>[] = [
{ key: "name", header: "classification", render: (r) => r.name },
{ key: "polarity", header: "polarity", render: (r) => r.polarity },
{
key: "verdict",
header: "verdict",
render: (r) => (r.error ? "—" : VERDICT_LABEL[r.verdict]),
},
{
key: "certainty",
header: "certainty",
render: (r) => (r.error ? "—" : r.certainty),
},
{ key: "threshold", header: "threshold", render: (r) => r.threshold },
{
key: "counted",
header: "counted",
// A counted row shows whether it passed its polarity; one below its
// threshold does not count and has no pass or fail.
render: (r) =>
r.error ? "—" : r.counted ? (r.passed ? "yes ✅" : "yes ❌") : "no",
},
{
key: "reason",
header: "reason",
cellClass: "ui-table-prose",
// A row that could not run says why where the reason would be.
render: (r) =>
r.error ? (
<Hint tone="error" as="span" class="ui-tryout-row-error">
{r.error}
</Hint>
) : (
r.reason
),
},
];
/** What the table needs of a run: the try-out's answer, or a listed run's. The
* head commit is absent for a run that never read one. */
export type TryOutAnswer = Pick<Result, "rows" | "overall"> & {
head_sha?: string;
};
export function TryOutResult({
result,
filterKey = "swarm-ui:review-tryout:table-filters",
}: {
result: TryOutAnswer;
/** Where the column filters are remembered; a page showing several tables
* keeps them apart from the try-out's. */
filterKey?: string;
}) {
const rows = result.rows ?? [];
return (
<div class="ui-tryout-result">
<Table
columns={COLUMNS}
rows={rows}
// By position: two classifications may share a name, and a shared key
// would let one result render over the other.
rowKey={(r) => String(rows.indexOf(r))}
storageKey={filterKey}
emptyMessage="the run returned no classifications"
/>
{result.overall ? (
<p class="ui-tryout-overall">
<strong>Overall: </strong>
<Badge
tone={result.overall === "approve" ? "positive" : "negative"}
value={result.overall === "approve" ? "approve" : "request changes"}
/>
</p>
) : null}
{result.head_sha ? (
<p class="ui-tryout-sha">
Ran on head <code>{result.head_sha.slice(0, 12)}</code>
</p>
) : null}
</div>
);
}