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
36 changed files with 164 additions and 86 deletions

View file

@ -117,6 +117,15 @@ stylesheet names a role and never a number:
Stacking inside one component (1 or 2) stays a plain number. A new floating box
uses `--z-popover` and `--shadow-pop`.
## Status tones
A badge, a hint, a banner and a toast all take one of five tones, defined in
`shared/src/tone.ts`: `neutral` (no signal), `info` (cyan), `ok` (green), `warn`
(amber) and `error` (red). A badge adds `accent` for a selected or active choice.
A banner takes `info`, `warn` or `error`, and a toast takes the four that carry a
signal. A component that shows a status takes a `Tone` and doesn't invent a
fifth spelling.
## Common mistakes
The Catppuccin colour names **don't** map 1:1 to the variable names.

View file

@ -999,7 +999,7 @@ restricted, log or unrestricted. Selecting it lists the three modes; picking one
`PUT` of the mode with the stored permissions beside it.
The **repositories** row is how many repositories the agent's forge account may
create: a badge reading none or `up to N`, in the warning tone above 0. Selecting
create: a badge reading none or `up to N`, in the `warn` tone above 0. Selecting
it opens a number box, 0 to 100, and **save** does a `PUT` of `max_repos` with the
stored permissions beside it. A `PUT` that leaves `max_repos` out, and the `DELETE`
of **use the default**, keep it. Nothing stored means 0, and the box warns that an

View file

@ -42,6 +42,7 @@
"./warn-banner.css": "./src/warn-banner/WarnBanner.css",
"./icon-button.js": "./src/icon-button/IconButton.tsx",
"./icon-button.css": "./src/icon-button/IconButton.css",
"./tone.js": "./src/tone.ts",
"./badge.js": "./src/badge/Badge.tsx",
"./badge.css": "./src/badge/Badge.css",
"./button.css": "./src/button/Button.css",

View file

@ -89,15 +89,18 @@
conventions or css mix new colors" — this is that; stock mocha/latte
keep their existing look, since both accents already sit close to
`--fg` in contrast terms). */
.ui-badge-positive .ui-badge-value {
.ui-badge-ok .ui-badge-value {
color: color-mix(in srgb, var(--green) 60%, var(--fg));
}
.ui-badge-warning .ui-badge-value {
.ui-badge-warn .ui-badge-value {
color: color-mix(in srgb, var(--amber) 60%, var(--fg));
}
.ui-badge-negative .ui-badge-value {
.ui-badge-error .ui-badge-value {
color: color-mix(in srgb, var(--red) 60%, var(--fg));
}
.ui-badge-info .ui-badge-value {
color: color-mix(in srgb, var(--cyan) 60%, var(--fg));
}
.ui-badge-accent .ui-badge-value {
color: color-mix(in srgb, var(--purple) 60%, var(--fg));
}

View file

@ -19,14 +19,14 @@
// `shared` is the one package both already depend on (see
// `docs/5-project/web-ui/design-guide.md`'s component-first + junk-drawer rules).
import type { ComponentChildren } from "preact";
import type { Tone } from "../tone.js";
import "./Badge.css";
export type BadgeTone =
| "neutral"
| "positive"
| "warning"
| "negative"
| "accent";
/**
* The shared `Tone`, plus `accent` for "selected" or "active", which marks a
* choice rather than a status.
*/
export type BadgeTone = Tone | "accent";
/**
* `'default'` — the filled pill every status/picker badge has always
* been. `'quiet'` — no permanent fill, only a background on hover/

View file

@ -0,0 +1,10 @@
// The one set of status tones: a badge, a hint, a banner and a toast all
// take a `Tone`, so "ok" or "warn" is spelled and coloured the same way
// everywhere. `neutral` is "no signal" (plain text, no colour); the other four
// map to the theme's green, amber, red and cyan (`--green`, `--amber`,
// `--red`, `--cyan`). A new component that shows a status takes a `Tone` and
// does not add a fifth spelling.
export const TONES = ["neutral", "info", "ok", "warn", "error"] as const;
export type Tone = (typeof TONES)[number];

View file

@ -10,13 +10,15 @@
// is the first consumer — compose from this instead of duplicating the
// banner's own border/colour/pulse rules locally.
//
// `level` defaults to 'warning', matching `hive-warn.js`'s own default.
// `level` defaults to 'warn', matching `hive-warn.js`'s own default.
// Only `error` pulses — an active incident, not a standing caveat, same
// rule `hive-warn.css`'s own comment states.
import type { ComponentChildren } from "preact";
import type { Tone } from "../tone.js";
import "./WarnBanner.css";
export type WarnLevel = "info" | "warning" | "error";
/** A banner is never `neutral` or `ok`: it exists to flag something. */
export type WarnLevel = Exclude<Tone, "neutral" | "ok">;
export interface WarnBannerProps {
level?: WarnLevel;
@ -29,7 +31,7 @@ export interface WarnBannerProps {
}
export function WarnBanner({
level = "warning",
level = "warn",
class: extraClass,
children,
}: WarnBannerProps) {

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)}
/>
);

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