Watch
0
0
Fork
You've already forked hyperhive
0

frontend: delete the tab strip, the side panel and the rebuild-queue stylesheet nothing uses

The shared tab-strip helper and its styles, the side-panel custom element, and the
dashboard's system-sections.css (rules for markup the job graph replaced) have no
importer or element left; AppShell took over the tab strip. Their package exports
and the two CSS imports go with them. The dashboard, agent and swarm-ui bundles
still build.
This commit is contained in:
iris 2026-11-25 19:26:58 +01:00
commit 975b43ce0e
4 changed files with 1 additions and 510 deletions

View file

@ -1,122 +0,0 @@
/* hive-side-panel.css — scoped stylesheet for the generic <hive-side-panel>
shadow-DOM custom element (hive-side-panel.js). Loaded as raw text at
build time (esbuild's `text` loader) and appended as a <style> element
inside the shadow root — see @hive/shared/shadow-css.js's header comment
for why a plain <style> tag and not adoptedStyleSheets.
Every rule here styles shadow-owned chrome this element builds itself
(backdrop, drawer, resize handle, header, title, close button) — none of
it is slotted, so this file needs zero `::slotted()`. The one slotted
node (the caller's opaque content, passed to open()/openNamed()/
refresh()) is intentionally un-styled from in here: each package's own
content-type-specific rules (`hive-side-panel .md` in the dashboard,
`hive-side-panel .agent-inbox` in the agent UI) live in that package's
own global stylesheet and reach the slotted content via the element's
own tag name as the selector root — no compatibility class needed,
same architecture floor as `<hive-menu>`'s item-row styling, not a
scope choice.
`:host(.open)`/`:host(.resizing)` respond to the two state classes the
JS toggles on the host itself (`open`, and `resizing` during a drag) —
the shadow-scoped counterparts of the page-global `body.side-panel-
resizing` cursor-override class, which stays in each package's own
stylesheet since it has to reach light-DOM elements outside this
element entirely (see hive-side-panel.js's module header). */
:host {
position: fixed;
inset: 0;
z-index: 200;
pointer-events: none;
}
.side-panel-backdrop {
position: absolute;
inset: 0;
background: color-mix(in srgb, var(--crust) 55%, transparent);
opacity: 0;
transition: opacity 200ms ease;
}
.side-panel-drawer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: var(--side-panel-w, min(42em, 95vw));
background: var(--bg-elev);
border-left: 1px solid var(--purple-dim);
display: flex;
flex-direction: column;
transform: translateX(100%);
transition: transform 220ms ease;
overflow: hidden;
}
:host(.open) {
pointer-events: auto;
}
:host(.open) .side-panel-backdrop {
opacity: 1;
}
:host(.open) .side-panel-drawer {
transform: translateX(0);
}
.side-panel-resize {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 6px;
cursor: ew-resize;
opacity: 0;
transition: opacity 120ms;
background: var(--purple-dim);
}
.side-panel-resize:hover,
:host(.resizing) .side-panel-resize {
opacity: 1;
}
:host(.resizing) .side-panel-resize {
background: var(--purple);
}
.side-panel-head {
display: flex;
align-items: center;
gap: 0.6em;
padding: 0.6em 1em;
border-bottom: 1px solid var(--border);
flex: none;
}
.side-panel-title {
flex: 1;
font-size: 0.88em;
color: var(--muted);
letter-spacing: 0.04em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.side-panel-close {
display: flex;
align-items: center;
justify-content: center;
background: none;
border: 1px solid var(--border);
border-radius: 3px;
color: var(--muted);
font-size: 1em;
line-height: 1;
padding: 0.15em 0.4em;
cursor: pointer;
transition:
border-color 0.15s ease,
color 0.15s ease;
}
.side-panel-close:hover {
border-color: var(--red);
color: var(--red);
}
.side-panel-body {
flex: 1;
overflow-y: auto;
padding: 0.8em 1em;
font-size: 0.88em;
}

View file

@ -1,237 +0,0 @@
// hive-side-panel.js — <hive-side-panel>, the generic slide-in drawer
// shadow-DOM custom element behind the dashboard's and the per-agent UI's
// side panel (file previews, diffs, logs, inbox/todo lists — anything too
// long to expand inline). One singleton instance per page, created once,
// eagerly, by each package's own module (dashboard/src/common.js's
// `sidePanel`, agent/src/app.js's `sidePanel`) and used directly — no
// wrapper object, no per-call lazy-init guard.
//
// Builds all structural chrome itself in `connectedCallback` (backdrop,
// drawer, resize handle, header, title, close button) — shadow-owned,
// zero `::slotted()` needed. Only the panel *content* is opaque
// caller-built DOM, appended as a light-DOM child and picked up by the
// shadow tree's single default `<slot>`, exactly like `<hive-menu>`'s
// `content` (see that file's header for why). Each package's own global
// stylesheet reaches that content via the element's own tag name as the
// selector root (`hive-side-panel .md`, `hive-side-panel .agent-inbox`)
// — no compatibility class needed.
//
// Public API is instance methods: `open(title, content)`,
// `openNamed(name, title, content)`, `refresh(name, title, content)`,
// `close()`, `currentOwner()`. `open` is exactly `openNamed(null, title,
// content)` — untyped opens clear the owner, matching the dashboard's
// original semantics.
//
// Drag-to-resize + localStorage width persistence is ported from the
// dashboard's original `Panel` (the only one of the two originals that
// had it) — making it available to every consumer (the agent UI didn't
// have it before) is a deliberate behavior widening, not incidental.
import { el } from "../dom.js";
import { attachShadowCss } from "../shadow-css.js";
import sidePanelCss from "./hive-side-panel.css";
// See docs/4-implementation/web-ui/agent-page.md::Side panel for the hit-strip + pointer-capture +
// localStorage persistence model; CSS clamps the stored value to min
// 320px / max 96vw and out-of-range stored values are dropped silently.
// Shared by both packages deliberately — see module header.
const WIDTH_KEY = "hyperhive:side-panel-width";
const WIDTH_MIN = 320;
class HiveSidePanel extends HTMLElement {
connectedCallback() {
const root = attachShadowCss(this, sidePanelCss);
this.setAttribute("aria-hidden", "true");
// Closed, the drawer is only slid off screen; `inert` keeps its controls out
// of the Tab order and away from assistive tech until it opens.
this.inert = true;
this._owner = null;
this._opener = null;
this._titleEl = el("span", {
class: "side-panel-title",
id: "side-panel-title",
});
this._closeBtn = el(
"button",
{
type: "button",
class: "side-panel-close",
title: "close (esc)",
},
"✕",
);
const head = el(
"header",
{ class: "side-panel-head" },
this._titleEl,
this._closeBtn,
);
this._resizeHandle = el("div", {
class: "side-panel-resize",
role: "separator",
"aria-orientation": "vertical",
"aria-label": "drag to resize side panel",
title: "drag to resize",
});
this._bodyEl = el("div", { class: "side-panel-body" }, el("slot"));
this._drawer = el(
"aside",
{
class: "side-panel-drawer",
role: "dialog",
"aria-labelledby": "side-panel-title",
},
this._resizeHandle,
head,
this._bodyEl,
);
this._backdrop = el("div", { class: "side-panel-backdrop" });
root.append(this._backdrop, this._drawer);
this._closeBtn.addEventListener("click", () => this.close());
this._backdrop.addEventListener("click", () => this.close());
document.addEventListener("keydown", (e) => {
if (
e.key === "Escape" &&
!e.defaultPrevented &&
this.classList.contains("open")
)
this.close();
});
this._applyStoredWidth();
this._bindResize();
}
open(title, content) {
this.openNamed(null, title, content);
}
openNamed(name, title, content) {
this._owner = name;
this._titleEl.textContent = title;
this.replaceChildren(...(content ? [content] : []));
// Remembered only on the first open: a replace while open keeps the
// original opener.
if (!this.classList.contains("open")) this._opener = document.activeElement;
this.classList.add("open");
this.setAttribute("aria-hidden", "false");
this.inert = false;
this._closeBtn.focus();
}
refresh(name, title, content) {
if (this._owner !== name) return;
this._titleEl.textContent = title;
this.replaceChildren(...(content ? [content] : []));
}
close() {
this._owner = null;
this.classList.remove("open");
this.setAttribute("aria-hidden", "true");
this.inert = true;
// Back to the control that opened it, if that is still on the page.
if (this._opener instanceof HTMLElement && this._opener.isConnected) {
this._opener.focus();
}
this._opener = null;
}
currentOwner() {
return this._owner;
}
_clampWidth(w) {
// Use document.documentElement.clientWidth rather than window.innerWidth:
// clientWidth gives the actual CSS layout viewport width and is not
// altered by Firefox's Fingerprinting Protection (which rounds
// window.innerWidth/outerWidth to the nearest 200px).
const max = Math.floor(document.documentElement.clientWidth * 0.96);
return Math.max(WIDTH_MIN, Math.min(max, w));
}
_applyStoredWidth() {
const raw = (() => {
try {
return localStorage.getItem(WIDTH_KEY);
} catch {
return null;
}
})();
if (!raw) return;
const parsed = parseInt(raw, 10);
if (!Number.isFinite(parsed) || parsed <= 0) return;
this._drawer.style.setProperty(
"--side-panel-w",
this._clampWidth(parsed) + "px",
);
}
_bindResize() {
const handle = this._resizeHandle;
const drawer = this._drawer;
let dragging = false;
handle.addEventListener("pointerdown", (e) => {
e.preventDefault();
dragging = true;
document.body.classList.add("side-panel-resizing");
// Shadow-scoped counterpart of the global `body.side-panel-resizing`
// class below — the resize handle's own hover/drag appearance lives
// inside this element's shadow tree, which the global class (a
// light-DOM-only escape hatch for the page-wide cursor override)
// can't reach.
this.classList.add("resizing");
// Capture so we keep getting pointermove even when the cursor
// outpaces the handle band (drag-fast-then-pause loses the
// handle's :hover state otherwise).
try {
handle.setPointerCapture(e.pointerId);
} catch {
/* legacy */
}
});
document.addEventListener("pointermove", (e) => {
if (!dragging) return;
// Drawer is anchored to the right edge — width = viewport - pointer X.
const w = this._clampWidth(
document.documentElement.clientWidth - e.clientX,
);
drawer.style.setProperty("--side-panel-w", w + "px");
});
const stopDrag = () => {
if (!dragging) return;
dragging = false;
document.body.classList.remove("side-panel-resizing");
this.classList.remove("resizing");
// Persist the final width. Read the actual rendered width
// rather than re-deriving so the stored value matches what
// the operator saw at mouseup.
const w = drawer.getBoundingClientRect().width;
try {
localStorage.setItem(WIDTH_KEY, String(Math.round(w)));
} catch {
/* localStorage unavailable — width is session-only */
}
};
document.addEventListener("pointerup", stopDrag);
document.addEventListener("pointercancel", stopDrag);
// Re-clamp on viewport resize so a persisted width that exceeds
// 96vw doesn't push the drawer off-screen after a window shrink.
window.addEventListener("resize", () => {
if (dragging) return;
const cur = drawer.getBoundingClientRect().width;
const clamped = this._clampWidth(cur);
if (clamped !== Math.round(cur)) {
drawer.style.setProperty("--side-panel-w", clamped + "px");
}
});
}
}
customElements.define("hive-side-panel", HiveSidePanel);

View file

@ -1,39 +0,0 @@
/* Shared tab-strip chrome — the generic tab/sub-tab styling used across
the dashboard tabbar, the logs sub-tabs, and the agent stat-window
selector. Behaviour lives in `@hive/shared/tabs.js` (createTabStrip).
Colours come from the semantic theme layer (theme.css → colors.css),
so this inherits theme-swap safety for free. Call sites keep a thin
variant class for size/spacing deltas; richer affordances (count
pills, the dashboard's responsive overflow ⋮ menu) layer on top in the
per-page CSS. See docs/4-implementation/web-ui/css-vars.md. */
.hive-tabbar {
display: flex;
gap: 0.2em;
}
.hive-tab {
display: inline-flex;
align-items: center;
padding: 0.35em 0.9em;
border-radius: 4px;
color: var(--subtext0);
text-decoration: none;
font-size: 0.85em;
letter-spacing: 0.05em;
cursor: pointer;
transition:
background 100ms,
color 100ms;
}
.hive-tab:hover {
background: var(--border);
color: var(--fg);
}
.hive-tab--active {
background: var(--border);
color: var(--purple);
}

View file

@ -1,71 +0,0 @@
// Shared hash-routed tab strip — the generic behaviour behind the
// dashboard tabbar, the logs sub-tabs, and the agent stat-window
// selector. Pairs with `@hive/shared/tabs.css` (the .hive-tab* styles).
//
// Convention over configuration (no element-resolver callbacks):
// - Tab controls are the `[data-tab="<id>"]` elements inside the
// `tabbar` you pass in (any element — `<a>` or `<button>`; give
// them class `hive-tab`).
// - Panels are matched by `[data-tab-pane="<id>"]` anywhere in the
// document.
//
// Routing is always via `location.hash` so tabs are deep-linkable and
// honour back/forward. A page may only host one strip (one hash); if a
// second independent strip is ever needed we add a key prefix then.
//
// On show: toggles `.hive-tab--active` + `aria-selected` on each control
// and `hidden` on each panel, then fires `onShow(id)` for per-tab
// side-effects (lazy loads, etc.). See docs/4-implementation/web-ui/css-vars.md.
/**
* @param {Element|null} tabbar container holding the `[data-tab]` controls
* @param {{ defaultId?: string, onShow?: (id: string) => void }} [opts]
* @returns {{ show: (id: string) => void, active: () => string|null }}
*/
export function createTabStrip(tabbar, opts = {}) {
const { defaultId, onShow } = opts;
if (!tabbar) {
return { show() {}, active: () => null };
}
const tabs = Array.from(tabbar.querySelectorAll("[data-tab]"));
const ids = tabs.map((t) => t.getAttribute("data-tab"));
const fallback = defaultId && ids.includes(defaultId) ? defaultId : ids[0];
const paneFor = (id) => document.querySelector(`[data-tab-pane="${id}"]`);
const active = () => {
const hash = location.hash.replace(/^#/, "");
return ids.includes(hash) ? hash : fallback;
};
const show = (id) => {
const target = ids.includes(id) ? id : fallback;
for (const tab of tabs) {
const tid = tab.getAttribute("data-tab");
const on = tid === target;
tab.classList.toggle("hive-tab--active", on);
tab.setAttribute("aria-selected", String(on));
const pane = paneFor(tid);
if (pane) pane.hidden = !on;
}
if (typeof onShow === "function") onShow(target);
};
// Drive every activation through the hash so deep-links + back/forward
// stay authoritative; the hashchange listener does the actual showing.
for (const tab of tabs) {
tab.addEventListener("click", (e) => {
e.preventDefault();
const id = tab.getAttribute("data-tab");
if (location.hash.replace(/^#/, "") === id) {
show(id); // same hash → no hashchange, re-show directly
} else {
location.hash = id;
}
});
}
window.addEventListener("hashchange", () => show(active()));
show(active()); // initial render from the current hash
return { show, active };
}