Watch
0
0
Fork
You've already forked hyperhive
0

frontend: one tone vocabulary for badges, hints, banners and toasts

Part of the unification order in the UI sweep issue (step b).

A badge named its tones positive/warning/negative, a hint muted/warn/error/ok,
a banner info/warning/error and a toast info/ok/error. They now all take the
shared Tone: neutral, info, ok, warn, error (a badge adds accent for a selected
choice). Warn is amber everywhere (a hint used yellow), info is cyan everywhere
(a toast used purple). A test pins the list against each component's CSS.
This commit is contained in:
iris 2026-11-25 21:43:23 +01:00
commit 25965341e0
27 changed files with 164 additions and 86 deletions

View file

@ -89,13 +89,13 @@ export function isUpdating(row: Pick<AgentRow, "snapshot">): boolean {
// actionable meaning.
export const FRESHNESS: Record<Freshness, { tone: BadgeTone; label: string }> =
{
fresh: { tone: "positive", label: "fresh" },
stale: { tone: "warning", label: "stale" },
fresh: { tone: "ok", label: "fresh" },
stale: { tone: "warn", label: "stale" },
never_reported: { tone: "neutral", label: "never reported" },
// `unknown` means the agent reported into the KV bucket but isn't in
// the swarm-identity roster — a real, distinct case ("hive-reported,
// not yet in swarm level"), not just a fallback default, so it gets a
// label that says what to do about it rather than reusing the enum
// name as the label.
unknown: { tone: "negative", label: "not in swarm identity" },
unknown: { tone: "error", label: "not in swarm identity" },
};

View file

@ -75,7 +75,7 @@ export function AgentApiKey({ hive, agent }: { hive: string; agent: string }) {
<Badge
label="API key"
value={stored ? "stored" : "none"}
tone={stored ? "positive" : "neutral"}
tone={stored ? "ok" : "neutral"}
/>{" "}
</>
)}

View file

@ -94,7 +94,7 @@ export function AgentIdentity({
<AgentStateRow key={row.name} agent={row.name} />
{showsLoginNeeded(row) ? (
<Badge
tone="warning"
tone="warn"
value="login needed"
title="the agent's claude has no session; its turns wait until it is logged in (log in under inference)"
/>
@ -117,7 +117,7 @@ export function AgentIdentity({
) : null}
{row.config_pr ? (
<Badge
tone="warning"
tone="warn"
value={
<>
config PR{" "}

View file

@ -295,7 +295,7 @@ export function AgentInternet({ agent, g }: { agent: string; g: GrantState }) {
<BadgePopover
label="internet"
value={internetSummary(grant.unrestricted_internet, grant.internet_log)}
tone={mode === "restricted" ? "neutral" : "warning"}
tone={mode === "restricted" ? "neutral" : "warn"}
title={`how far ${agent}'s traffic may leave the host`}
popoverLabel={`${agent} internet access`}
>
@ -359,7 +359,7 @@ export function AgentRepos({ agent, g }: { agent: string; g: GrantState }) {
<BadgePopover
label="repositories"
value={reposSummary(grant.max_repos)}
tone={stored === 0 ? "neutral" : "warning"}
tone={stored === 0 ? "neutral" : "warn"}
title={`how many repositories ${agent}'s forge account may create`}
popoverLabel={`${agent} repository limit`}
>

View file

@ -77,7 +77,7 @@ export function AgentSsh({ agent, g }: { agent: string; g: GrantState }) {
<BadgePopover
label="ssh"
value={sshSummary(grant.ssh)}
tone={on ? "warning" : "neutral"}
tone={on ? "warn" : "neutral"}
title={`whether ${agent} may get SSH certificates from the swarm`}
popoverLabel={`${agent} SSH access`}
>

View file

@ -150,7 +150,7 @@ export function AgentCard({
) : null}
{hivePauseReason(row) !== null ? (
<Badge
tone="warning"
tone="warn"
value="paused by hive"
title={`the hive paused this agent: ${hivePauseReason(row)}. Set it up again to resume it.`}
/>
@ -162,7 +162,7 @@ export function AgentCard({
{...inert}
>
<Badge
tone="warning"
tone="warn"
value="login needed"
title="the agent's claude has no session; its turns wait until it is logged in"
/>

View file

@ -38,11 +38,11 @@ export function WantedMenu({
const canDeclare = !!row.hive && !destroyed && !undeclared;
const tone: BadgeTone =
row.wanted === "up"
? "positive"
? "ok"
: row.wanted === "paused"
? "warning"
? "warn"
: destroyed
? "negative"
? "error"
: "neutral";
const options: DropdownOption[] = [
{ value: "up", label: "up" },

View file

@ -14,7 +14,7 @@ import {
const TURN_STATE_TONE: Record<string, BadgeTone> = {
idle: "neutral",
thinking: "accent",
compacting: "warning",
compacting: "warn",
};
export function tokenTotal(u: TokenUsage | null): number | null {
@ -73,7 +73,7 @@ export function StateBadges({
own doc), never "offline"/"destroyed" — a stopped or
destroyed agent publishes nothing at all. */}
{header.agent_state !== "up" && (
<Badge tone="warning" value={header.agent_state} />
<Badge tone="warn" value={header.agent_state} />
)}
{withModel &&
(agent === undefined ? (

View file

@ -27,7 +27,7 @@ export function BashTasksMenu({ agentName }: { agentName: string }) {
<Badge
icon={<TerminalIcon />}
value={running}
tone={running > 0 ? "positive" : "neutral"}
tone={running > 0 ? "ok" : "neutral"}
ariaLabel={label}
title={`${label}: ${open ? "close" : "open"} ${agentName}'s bash tasks`}
expanded={open}

View file

@ -62,7 +62,7 @@ export function CancelTurnBadge({
if (state.status === "error") {
return (
<Badge
tone="negative"
tone="error"
value={`cancel failed: ${state.detail}`}
title="try cancelling again"
onClick={cancel}
@ -72,7 +72,7 @@ export function CancelTurnBadge({
if (!canCancel(turnState)) return null;
return (
<Badge
tone="warning"
tone="warn"
value={state.status === "cancelling" ? "cancelling…" : "cancel turn"}
title="stop the agent's current turn"
onClick={state.status === "cancelling" ? undefined : cancel}

View file

@ -124,7 +124,7 @@ export function SubagentsMenu({
<Badge
icon={<SubagentsIcon />}
value={running.length}
tone={running.length > 0 ? "positive" : "neutral"}
tone={running.length > 0 ? "ok" : "neutral"}
ariaLabel={runningLabel(running.length)}
title={`${runningLabel(running.length)}: ${open ? "close" : "open"} ${agentName}'s subagents`}
expanded={open}

View file

@ -28,10 +28,10 @@ import {
} from "./alerts.js";
const STATE_TONE: Record<string, BadgeTone> = {
Alerting: "negative",
Error: "negative",
NoData: "warning",
Pending: "warning",
Alerting: "error",
Error: "error",
NoData: "warn",
Pending: "warn",
};
const COLUMNS: TableColumn<Alert>[] = [

View file

@ -55,9 +55,10 @@ import { Popover } from "../ui/popover/Popover.js";
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
import { GearIcon } from "@hive/shared/icons.js";
import { Dropdown, type DropdownOption } from "@hive/shared/dropdown.js";
import { TONES } from "@hive/shared/tone.js";
import "./ComponentsPage.css";
const HINT_TONES: HintTone[] = ["muted", "warn", "error", "ok"];
const HINT_TONES: HintTone[] = [...TONES];
const SUBMIT_SAMPLES: [string, SubmitState][] = [
["done", { status: "done", value: undefined }],
@ -118,7 +119,7 @@ const TABLE_COLUMNS: TableColumn<Row>[] = [
{
key: "status",
header: "status",
render: () => <Badge tone="positive" value="ok" />,
render: () => <Badge tone="ok" value="ok" />,
},
];
@ -133,13 +134,7 @@ const SELECT_OPTIONS: SelectOption[] = [
];
const BUTTON_VARIANTS: ButtonVariant[] = ["primary", "default", "danger"];
const BADGE_TONES: BadgeTone[] = [
"neutral",
"positive",
"warning",
"negative",
"accent",
];
const BADGE_TONES: BadgeTone[] = [...TONES, "accent"];
const MODEL_OPTIONS: DropdownOption[] = [
{ value: "haiku", label: "haiku", description: "fast" },
@ -250,7 +245,7 @@ function BadgeToggleSample() {
return (
<Badge
value={paused ? "▶ resume" : "⏸ pause"}
tone={paused ? "warning" : "neutral"}
tone={paused ? "warn" : "neutral"}
onClick={() => setPaused((p) => !p)}
/>
);

View file

@ -329,8 +329,7 @@ function IssueReportBody() {
/>
),
ariaSort: ariaSortFor("blocked"),
render: (r) =>
r.blocked ? <Badge tone="warning" value="blocked" /> : "—",
render: (r) => (r.blocked ? <Badge tone="warn" value="blocked" /> : "—"),
// A distinct gap from the existing "hide blocked" toggle above:
// that one only *hides* blocked issues, there was no way to see
// *only* the blocked ones. Synthesized two-value set (not the raw

View file

@ -181,7 +181,7 @@ export function LinkMatrixAccountForm({
setMode(v as Mode);
}}
/>
<Hint tone={mode === "token" ? "warn" : "muted"}>
<Hint tone={mode === "token" ? "warn" : "neutral"}>
{mode === "token" ? TOKEN_WARNING : PASSWORD_NOTE}
</Hint>
{mode === "token" ? (

View file

@ -36,9 +36,9 @@ const REPO_FILTER_KEY = "swarm-ui:pr-report:repo-filter";
const TABLE_FILTERS_KEY = "swarm-ui:pr-report:table-filters";
const CI_TONE: Record<NonNullable<PrReportRow["ci"]>, BadgeTone> = {
success: "positive",
pending: "warning",
failure: "negative",
success: "ok",
pending: "warn",
failure: "error",
};
const COLUMNS: TableColumn<PrReportRow>[] = [
@ -119,7 +119,7 @@ const COLUMNS: TableColumn<PrReportRow>[] = [
{r.changes_requested > 0 ? (
<>
{" "}
<Badge tone="negative" value="changes requested" />
<Badge tone="error" value="changes requested" />
</>
) : null}
</>
@ -132,7 +132,7 @@ const COLUMNS: TableColumn<PrReportRow>[] = [
key: "conflicts",
header: "conflicts",
render: (r) =>
r.has_conflicts ? <Badge tone="negative" value="conflicts" /> : "—",
r.has_conflicts ? <Badge tone="error" value="conflicts" /> : "—",
sortBy: (r) => Number(r.has_conflicts),
filterValues: (r) => [yesNo(r.has_conflicts)],
filterMode: "multiselect",

View file

@ -35,9 +35,9 @@ export const OUTCOME_LABEL: Record<BuildOutcome, string> = {
};
export const OUTCOME_TONE: Record<BuildOutcome, BadgeTone> = {
built: "positive",
failed: "negative",
error: "warning",
built: "ok",
failed: "error",
error: "warn",
};
/**

View file

@ -43,9 +43,9 @@ const CONNECTION_LABEL: Record<ConnectionState, string> = {
const CONNECTION_TONE: Record<ConnectionState, BadgeTone> = {
connecting: "neutral",
open: "positive",
reconnecting: "warning",
closed: "negative",
open: "ok",
reconnecting: "warn",
closed: "error",
};
// One message's row. Memoised on the message, which keeps its identity while it

View file

@ -87,7 +87,7 @@ export function TryOutResult({
<p class="ui-tryout-overall">
<strong>Overall: </strong>
<Badge
tone={result.overall === "approve" ? "positive" : "negative"}
tone={result.overall === "approve" ? "ok" : "error"}
value={result.overall === "approve" ? "approve" : "request changes"}
/>
</p>

View file

@ -46,13 +46,13 @@ export const OUTCOME_LABEL: Record<RunOutcome, string> = {
};
export const OUTCOME_TONE: Record<RunOutcome, BadgeTone> = {
approved: "positive",
approved: "ok",
"changes-requested": "accent",
"no-verdict": "neutral",
"queue-full": "warning",
"post-failed": "negative",
done: "positive",
failed: "negative",
"queue-full": "warn",
"post-failed": "error",
done: "ok",
failed: "error",
};
export const TRIGGER_LABEL: Record<RunTrigger, string> = {

Some files were not shown because too many files have changed in this diff Show more