Watch
0
0
Fork
You've already forked hyperhive
0

dashboard: action buttons use the swarm UI's button, with its danger tone and touch height

Button.css moves to @hive/shared, a rename from swarm-ui/src/ui/button/Button.css to shared/src/button/Button.css; the swarm UI's Button imports it from there and the dashboard imports it too. The dashboard's own .btn rules and its eleven per-action colour modifiers are gone: the bulk action buttons, the per-row purge and the selection bar's clear are ui-button, destroy and purge are ui-button-danger, and all of them have the 2.75em height the dashboard buttons were under. The form() and addBulkButton helpers take a tone (danger or default) in place of a btn-* class. The danger variant is the one the confirmations PR adds, identical, so the two merge in either order.
This commit is contained in:
iris 2026-11-19 19:24:59 +01:00 • committed by mara
commit 16a5bff2b1
9 changed files with 26 additions and 140 deletions

View file

@ -4,7 +4,7 @@
// job-queue-rollup ops. See docs/4-implementation/web-ui/dashboard.md::Container row for the // job-queue-rollup ops. See docs/4-implementation/web-ui/dashboard.md::Container row for the
// rendering contract. // rendering contract.
import { $, form, fmtAgeSecs } from "./common.js"; import { $, buttonClass, form, fmtAgeSecs } from "./common.js";
import { el } from "@hive/shared/dom.js"; import { el } from "@hive/shared/dom.js";
import { themedConfirm, themedToast } from "@hive/shared/modal.js"; import { themedConfirm, themedToast } from "@hive/shared/modal.js";
import { h, render } from "preact"; import { h, render } from "preact";
@ -731,7 +731,7 @@ export function renderSelectionBar(containers) {
return `${label} not available — ${blockers.join(", ")} ${blockers.length === 1 ? "is" : "are"} blocking it`; return `${label} not available — ${blockers.join(", ")} ${blockers.length === 1 ? "is" : "are"} blocking it`;
} }
addBulkButton(actions, "btn-restart", "↺ R3ST4RT", allRunning, selected, { addBulkButton(actions, "default", "↺ R3ST4RT", allRunning, selected, {
action: "/api/restart/", action: "/api/restart/",
confirm: (names) => confirm: (names) =>
`restart ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`, `restart ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -743,7 +743,7 @@ export function renderSelectionBar(containers) {
stoppedNames.map((n) => `\`${n}\` is stopped`), stoppedNames.map((n) => `\`${n}\` is stopped`),
), ),
}); });
addBulkButton(actions, "btn-stop", "■ ST0P", allRunning, selected, { addBulkButton(actions, "default", "■ ST0P", allRunning, selected, {
action: "/api/kill/", action: "/api/kill/",
confirm: (names) => confirm: (names) =>
`stop ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`, `stop ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -754,7 +754,7 @@ export function renderSelectionBar(containers) {
stoppedNames.map((n) => `\`${n}\` is already stopped`), stoppedNames.map((n) => `\`${n}\` is already stopped`),
), ),
}); });
addBulkButton(actions, "btn-start", "▶ ST4RT", allStopped, selected, { addBulkButton(actions, "default", "▶ ST4RT", allStopped, selected, {
action: "/api/start/", action: "/api/start/",
confirm: (names) => confirm: (names) =>
`start ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`, `start ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
@ -763,7 +763,7 @@ export function renderSelectionBar(containers) {
runningNames.map((n) => `\`${n}\` is already running`), runningNames.map((n) => `\`${n}\` is already running`),
), ),
}); });
addBulkButton(actions, "btn-pause", "⏸ P4US3", allUnpaused, selected, { addBulkButton(actions, "default", "⏸ P4US3", allUnpaused, selected, {
action: "/api/pause/", action: "/api/pause/",
confirm: (names) => confirm: (names) =>
`pause ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? parks the turn loop — inbox messages queue unacked.`, `pause ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? parks the turn loop — inbox messages queue unacked.`,
@ -772,7 +772,7 @@ export function renderSelectionBar(containers) {
pausedNames.map((n) => `\`${n}\` is already paused`), pausedNames.map((n) => `\`${n}\` is already paused`),
), ),
}); });
addBulkButton(actions, "btn-resume", "▶ R3SUM3", allPaused, selected, { addBulkButton(actions, "default", "▶ R3SUM3", allPaused, selected, {
action: "/api/resume/", action: "/api/resume/",
confirm: (names) => confirm: (names) =>
`resume ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? the turn loop restarts and drains queued messages.`, `resume ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? the turn loop restarts and drains queued messages.`,
@ -781,17 +781,17 @@ export function renderSelectionBar(containers) {
unpausedNames.map((n) => `\`${n}\` is not paused`), unpausedNames.map((n) => `\`${n}\` is not paused`),
), ),
}); });
addBulkButton(actions, "btn-rebuild", "↻ R3BU1LD", true, selected, { addBulkButton(actions, "default", "↻ R3BU1LD", true, selected, {
action: "/api/rebuild/", action: "/api/rebuild/",
confirm: (names) => confirm: (names) =>
`rebuild ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? hot-reloads each container.`, `rebuild ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? hot-reloads each container.`,
}); });
addBulkButton(actions, "btn-destroy", "DESTR0Y", true, selected, { addBulkButton(actions, "danger", "DESTR0Y", true, selected, {
action: "/api/destroy/", action: "/api/destroy/",
confirm: (names) => confirm: (names) =>
`destroy ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? containers are removed; state + creds kept.`, `destroy ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? containers are removed; state + creds kept.`,
}); });
addBulkButton(actions, "btn-destroy", "PURG3", true, selected, { addBulkButton(actions, "danger", "PURG3", true, selected, {
action: "/api/destroy/", action: "/api/destroy/",
body: { purge: "on" }, body: { purge: "on" },
confirm: (names) => confirm: (names) =>
@ -799,13 +799,13 @@ export function renderSelectionBar(containers) {
}); });
} }
function addBulkButton(parent, btnClass, label, enabled, selected, opts) { function addBulkButton(parent, tone, label, enabled, selected, opts) {
const names = selected.map((c) => c.name); const names = selected.map((c) => c.name);
const btn = el( const btn = el(
"button", "button",
{ {
type: "button", type: "button",
class: "btn " + btnClass, class: buttonClass(tone),
}, },
label, label,
); );

View file

@ -1,6 +1,7 @@
/* Shared Catppuccin palette + body typography + terminal pane styles. /* Shared Catppuccin palette + body typography + terminal pane styles.
Bundled in front of the page-specific rules via esbuild. */ Bundled in front of the page-specific rules via esbuild. */
@import "@hive/shared/base.css"; @import "@hive/shared/base.css";
@import "@hive/shared/button.css";
@import "@hive/shared/terminal.css"; @import "@hive/shared/terminal.css";
@import "@hive/shared/tabs.css"; @import "@hive/shared/tabs.css";
/* Shared pill/chip/badge shape (the "extract pill component" issue, /* Shared pill/chip/badge shape (the "extract pill component" issue,
@ -128,120 +129,6 @@ code {
border-color: var(--amber); border-color: var(--amber);
} }
/* ─── buttons ───────────────────────────────────────────────────────
.btn base + semantic colour/size modifiers. */
.btn {
font-family: inherit;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 0.1em;
background: transparent;
/* Strip browser UA button chrome (solid fill, system text colour).
Without this, native <button> + <input type="submit"> elements
ignore our background:transparent and colour in some browsers. */
-webkit-appearance: none;
appearance: none;
border: 1px solid;
padding: 0.25em 0.8em;
cursor: pointer;
text-shadow: 0 0 4px currentColor;
box-shadow: 0 0 0 0 currentColor;
transition: box-shadow 0.15s ease;
}
.btn:hover {
background: color-mix(in srgb, var(--fg) 6%, transparent);
text-shadow: 0 0 10px currentColor;
box-shadow: 0 0 10px -2px currentColor;
}
.btn:disabled,
.btn[disabled] {
opacity: 0.32;
cursor: not-allowed;
text-shadow: none;
box-shadow: none;
}
.btn:disabled:hover,
.btn[disabled]:hover {
background: transparent;
text-shadow: none;
box-shadow: none;
}
.btn-approve {
color: var(--green);
border-color: var(--green);
}
.btn-destroy {
color: var(--red);
border-color: var(--red);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-rebuild {
color: var(--amber);
border-color: var(--amber);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-restart {
color: var(--cyan);
border-color: var(--cyan);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-stop {
color: var(--pink);
border-color: var(--pink);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-start {
color: var(--green);
border-color: var(--green);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
/* Same yellow as .badge-paused (the paused-state pill) — pause enters
that state, so the trigger and the resulting badge read as one
colour, not two unrelated ones. Resume reads as green like
.btn-start: both are "go" actions, back to the turn loop running. */
.btn-pause {
color: var(--yellow);
border-color: var(--yellow);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-resume {
color: var(--green);
border-color: var(--green);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
/* M0V3 affordance (selection bar) — mauve reads as "structural
change" rather than the destructive red / amber chrome of
destroy / rebuild. See docs/4-implementation/web-ui/dashboard.md::Selection bar. */
.btn-move {
color: var(--purple);
border-color: var(--purple);
font-size: 0.75em;
padding: 0.15em 0.5em;
margin-left: 0.6em;
}
.btn-talk {
color: var(--cyan);
border-color: var(--cyan);
}
.btn-spawn {
color: var(--amber);
border-color: var(--amber);
}
/* ─── page-content gutter ───────────────────────────────────────────── /* ─── page-content gutter ─────────────────────────────────────────────
Inverted-gutter layout: the dashboard keeps `<body>` full-bleed Inverted-gutter layout: the dashboard keeps `<body>` full-bleed
and wraps their padded content in a single `.page-content` div that and wraps their padded content in a single `.page-content` div that

View file

@ -22,9 +22,17 @@ export const esc = (s) =>
(c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c], (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c],
); );
// An action button in the swarm UI's look (`@hive/shared/button.css`): the tone
// is `"danger"` for an action that destroys, `"default"` for the rest. Any other
// string is taken as the button's own classes, for the one pill-shaped control.
export const buttonClass = (tone) =>
tone === "danger" || tone === "default"
? "ui-button ui-button-" + tone
: tone;
export const form = ( export const form = (
action, action,
btnClass, tone,
btnLabel, btnLabel,
confirmMsg, confirmMsg,
extra = {}, extra = {},
@ -45,7 +53,7 @@ export const form = (
f.append(el("input", { type: "hidden", name, value })); f.append(el("input", { type: "hidden", name, value }));
} }
f.append( f.append(
el("button", { type: "submit", class: "btn " + btnClass }, btnLabel), el("button", { type: "submit", class: buttonClass(tone) }, btnLabel),
); );
return f; return f;
}; };

View file

@ -630,16 +630,6 @@ footer .banner-thin {
gap: 0.4em; gap: 0.4em;
align-items: center; align-items: center;
} }
.selection-actions .btn {
font-size: 0.75em;
padding: 0.2em 0.7em;
}
.selection-clear {
color: var(--muted);
border-color: var(--purple-dim);
font-size: 0.75em;
padding: 0.2em 0.7em;
}
/* Pad the dashboard body so the sticky bar doesn't cover the /* Pad the dashboard body so the sticky bar doesn't cover the
bottom of the agent list. Only applies when bar is visible. */ bottom of the agent list. Only applies when bar is visible. */
body.dashboard-shell.has-selection { body.dashboard-shell.has-selection {

View file

@ -179,7 +179,7 @@
<span class="selection-actions" id="selection-actions"></span> <span class="selection-actions" id="selection-actions"></span>
<button <button
type="button" type="button"
class="btn selection-clear" class="ui-button ui-button-default selection-clear"
id="selection-clear" id="selection-clear"
title="clear selection (esc)" title="clear selection (esc)"
> >

View file

@ -74,7 +74,7 @@ export function renderKept() {
actions.append( actions.append(
form( form(
"/api/purge-tombstone/" + t.name, "/api/purge-tombstone/" + t.name,
"btn-destroy", "danger",
"PURG3", "PURG3",
"PURGE " + "PURGE " +
t.name + t.name +

View file

@ -44,6 +44,7 @@
"./icon-button.css": "./src/icon-button/IconButton.css", "./icon-button.css": "./src/icon-button/IconButton.css",
"./badge.js": "./src/badge/Badge.tsx", "./badge.js": "./src/badge/Badge.tsx",
"./badge.css": "./src/badge/Badge.css", "./badge.css": "./src/badge/Badge.css",
"./button.css": "./src/button/Button.css",
"./dropdown.js": "./src/dropdown/Dropdown.tsx", "./dropdown.js": "./src/dropdown/Dropdown.tsx",
"./dropdown.css": "./src/dropdown/Dropdown.css", "./dropdown.css": "./src/dropdown/Dropdown.css",
"./icons.js": "./src/icons.tsx", "./icons.js": "./src/icons.tsx",

View file

@ -5,7 +5,7 @@
// taken back: destroy, delete, a removal that cuts access). // taken back: destroy, delete, a removal that cuts access).
import type { ComponentChildren } from "preact"; import type { ComponentChildren } from "preact";
import { Spinner } from "../spinner/Spinner.js"; import { Spinner } from "../spinner/Spinner.js";
import "./Button.css"; import "@hive/shared/button.css";
export type ButtonVariant = "primary" | "default" | "danger"; export type ButtonVariant = "primary" | "default" | "danger";