Compare commits

..
2 changed files with 46 additions and 42 deletions

View file

@ -504,15 +504,6 @@ stops at the row's icon midline).
### Selection bar ### Selection bar
Per-card action buttons (`R3ST4RT` / `ST0P` / `ST4RT` / `R3BU1LD` /
`DESTR0Y` / `PURG3`) used to live on each container row; the
operator picked the bulk-bar model instead. Clicking an agent's
icon toggles its selection (an in-memory `Set<name>`); `Esc` or
the bar's `✕ clear` button drops everything. The selection
persists across tab switches in-memory — the bar just hides on
non-SW4RM tabs since other tabs don't show the agent cards needed
to cross-reference.
When one or more agents are selected (via icon click), a sticky When one or more agents are selected (via icon click), a sticky
frosted-mauve bar slides up from the bottom of the viewport frosted-mauve bar slides up from the bottom of the viewport
(`#selection-bar`, `position: fixed; bottom: 0`). It shows: (`#selection-bar`, `position: fixed; bottom: 0`). It shows:
@ -522,15 +513,15 @@ frosted-mauve bar slides up from the bottom of the viewport
support the action; disabled with a tooltip naming the blockers support the action; disabled with a tooltip naming the blockers
when the selection is mixed: when the selection is mixed:
- `↺ R3ST4RT` — running agents only - `↺ R3ST4RT` — running agents only
- `■ ST0P` — running agents only - `■ ST0P` — running agents only (manager included; no special-case)
- `▶ ST4RT` — stopped agents only - `▶ ST4RT` — stopped agents only
- `↻ R3BU1LD` — always available - `↻ R3BU1LD` — always available
- `DESTR0Y` / `PURG3` — sub-agents only (disabled if manager selected) - `DESTR0Y` / `PURG3` — sub-agents only (disabled if manager selected)
- `⇡ M0V3 → ROOT` (#486) — promote selected agents to top-level - `⇡ M0V3 → ROOT` (#486) — promote selected agents to top-level
(parent = null); disabled when all selected are already at root. (parent = null); disabled when all selected are already at root.
Backend `topology::set_parent` refuses moves it can't satisfy Manager included with no special-case (matches the `ST0P` policy);
(e.g. moving the manager) and the refusal surfaces in the the backend's `topology::set_parent` refuses to move the manager
failure roll-up. and the refusal surfaces in the failure roll-up.
- `⇢ M0V3 → [select]` (#486) — inline picker available for any - `⇢ M0V3 → [select]` (#486) — inline picker available for any
selection size. The dropdown lists every container that isn't IN selection size. The dropdown lists every container that isn't IN
the selection itself nor a descendant of any selected agent the selection itself nor a descendant of any selected agent

View file

@ -287,11 +287,11 @@ window.marked = marked;
if (s) renderContainers(s); if (s) renderContainers(s);
} }
// ─── selection ────────────────────────────────────────────────────── // ─── selection (#443) ───────────────────────────────────────────────
// In-memory set of selected agent logical names backing the sticky // Set of selected agent logical names. Toggled by clicking the
// #selection-bar. See docs/web-ui.md::Selection bar for the // container-row icon. When non-empty, the sticky #selection-bar
// interaction model (icon-click toggle, Esc/clear button drop, // becomes visible with the bulk actions. Per-card action buttons
// tab-gated visibility). // are gone — actions live in the bar.
const selectionState = new Set(); const selectionState = new Set();
function toggleSelection(name) { function toggleSelection(name) {
if (selectionState.has(name)) selectionState.delete(name); if (selectionState.has(name)) selectionState.delete(name);
@ -534,7 +534,7 @@ window.marked = marked;
// hyperhive mark (`/favicon.svg`, served by the dashboard // hyperhive mark (`/favicon.svg`, served by the dashboard
// itself, always reachable). (issues #195, #202) // itself, always reachable). (issues #195, #202)
const iconImg = el('img', { class: 'container-icon-img', alt: '' }); const iconImg = el('img', { class: 'container-icon-img', alt: '' });
// Icon is the selection toggle. Click → add/remove from // #443: icon is the selection toggle. Click → add/remove from
// `selectionState` → re-render. role=button + tabindex makes it // `selectionState` → re-render. role=button + tabindex makes it
// keyboard-accessible; aria-pressed reflects the toggle state. // keyboard-accessible; aria-pressed reflects the toggle state.
const icon = el('div', { const icon = el('div', {
@ -698,11 +698,15 @@ window.marked = marked;
)); ));
} }
// Per-card action buttons (R3ST4RT / ST0P / ST4RT / R3BU1LD / // Per-card action buttons used to live here (R3ST4RT / ST0P /
// DESTR0Y / PURG3) moved to the selection bar — see // ST4RT / R3BU1LD / DESTR0Y / PURG3). Per mara on #443: "dont
// docs/web-ui.md::Selection bar. The contextual `needs update ↻` // show all the restart buttons etc., just show state and links.
// instead, clicking an agent icon selects that agent." Actions
// moved into the sticky #selection-bar (see renderSelectionBar)
// which appears when the operator has at least one agent
// selected via the icon click. The contextual `needs update ↻`
// chip in the head row stays — it's a state-hint, not an // chip in the head row stays — it's a state-hint, not an
// action button. // action button per se.
// ── drill-ins ──────────────────────────────────────────────── // ── drill-ins ────────────────────────────────────────────────
const drill = el('div', { class: 'drill-ins' }); const drill = el('div', { class: 'drill-ins' });
@ -726,13 +730,12 @@ window.marked = marked;
renderSelectionBar(containers); renderSelectionBar(containers);
} }
// ─── selection bar ────────────────────────────────────────────────── // ─── selection bar (#443) ───────────────────────────────────────────
// Sticky-bottom strip; visible when ≥1 agent selected on the SW4RM // Sticky-bottom strip; visible when ≥1 agent selected. mara picked
// tab. See docs/web-ui.md::Selection bar for the interaction model // option B: show every action button, disable the ones that don't
// and the per-action availability rules (disabled-with-tooltip for // apply to the full selection, hover tooltip explains why. Actions
// actions that don't apply to the full selection). Actions POST per // POST per agent in a loop (no new backend wire — endpoints already
// agent in a loop (endpoints are individually idempotent / // exist and are individually idempotent / event-covered).
// event-covered, so no new bulk backend wire is needed).
function renderSelectionBar(containers) { function renderSelectionBar(containers) {
const bar = $('selection-bar'); const bar = $('selection-bar');
if (!bar) return; if (!bar) return;
@ -742,9 +745,11 @@ window.marked = marked;
if (!countSpan || !namesSpan || !actions) return; if (!countSpan || !namesSpan || !actions) return;
const selected = containers.filter((c) => selectionState.has(c.name)); const selected = containers.filter((c) => selectionState.has(c.name));
// Tab-gate: bar only renders on SW4RM (the only tab with agent // #596: the bar's actions only make sense on the SW4RM tab — that's
// cards to cross-reference). Selection state lives in-memory and // where the agent cards are visible to cross-reference against the
// the bar reappears on return to SW4RM if still non-empty. // selection. On other tabs the operator just sees a floating bar
// with no context, so hide it. Selection state persists in-memory
// and the bar reappears on return to SW4RM if still non-empty.
const onSwarmTab = (document.body.dataset.activeTab || 'swarm') === 'swarm'; const onSwarmTab = (document.body.dataset.activeTab || 'swarm') === 'swarm';
if (!selected.length || !onSwarmTab) { if (!selected.length || !onSwarmTab) {
bar.hidden = true; bar.hidden = true;
@ -780,6 +785,12 @@ window.marked = marked;
confirm: (names) => `restart ${names.length} agent${names.length === 1 ? '' : 's'} (${names.join(', ')})?`, confirm: (names) => `restart ${names.length} agent${names.length === 1 ? '' : 's'} (${names.join(', ')})?`,
disabledTitle: why('↺ R3ST4RT', stoppedNames.map((n) => `\`${n}\` is stopped`)), disabledTitle: why('↺ R3ST4RT', stoppedNames.map((n) => `\`${n}\` is stopped`)),
}); });
// #443 also lifts the manager-stop guard: when the whole selection
// is running, ST0P applies — manager included. host-side hive-c0re
// keeps serving the dashboard either way + per-agent approvals +
// meta-input updates still work without the manager up, so we
// don't special-case the confirm prompt when the manager is in
// the selection (mara: "dont special case manager for stopping").
addBulkButton(actions, 'btn-stop', '■ ST0P', allRunning, selected, { addBulkButton(actions, 'btn-stop', '■ ST0P', allRunning, selected, {
action: '/kill/', action: '/kill/',
confirm: (names) => `stop ${names.length} agent${names.length === 1 ? '' : 's'} (${names.join(', ')})?`, confirm: (names) => `stop ${names.length} agent${names.length === 1 ? '' : 's'} (${names.join(', ')})?`,
@ -826,12 +837,14 @@ window.marked = marked;
addMoveActions(actions, selected, containers); addMoveActions(actions, selected, containers);
} }
// Render the M0V3 affordances inside the selection bar — separate // #486 — render the M0V3 affordances inside the selection bar. Split
// helper because the picker variant needs a select + button pair, // into its own helper because the picker variant needs a select + button
// not the single-button shape addBulkButton ships. Backend // pair, not the single-button shape addBulkButton ships.
// `topology::set_parent` refuses moves it can't satisfy (manager //
// included) and the refusal surfaces in the bulk-action error // No client-side manager special-case (mara on #695): backend
// roll-up. // `topology::set_parent` refuses to move the manager and surfaces the
// refusal as a per-agent failure in the bulk-action error roll-up. Same
// pattern as #443 ST0P (which also doesn't special-case manager).
function addMoveActions(parent, selected, containers) { function addMoveActions(parent, selected, containers) {
// M0V3 → ROOT: parent=null for every selected agent. Only meaningful // M0V3 → ROOT: parent=null for every selected agent. Only meaningful
// when at least one selected agent currently has a non-null parent; // when at least one selected agent currently has a non-null parent;
@ -3253,9 +3266,9 @@ window.marked = marked;
if (tab) tab.classList.toggle('active', t === target); if (tab) tab.classList.toggle('active', t === target);
if (pane) pane.classList.toggle('tab-pane-active', t === target); if (pane) pane.classList.toggle('tab-pane-active', t === target);
} }
// Track active tab on the body so renderSelectionBar can gate // #596: track active tab on the body so renderSelectionBar can
// visibility (bar only belongs on SW4RM where agent cards live). // gate visibility (bar only belongs on SW4RM where agent cards
// Re-render the bar so the toggle takes effect immediately // live). Re-render the bar so the toggle takes effect immediately
// on hashchange without waiting for the next SSE update. // on hashchange without waiting for the next SSE update.
document.body.dataset.activeTab = target; document.body.dataset.activeTab = target;
renderSelectionBar(Array.from(containersState.values())); renderSelectionBar(Array.from(containersState.values()));