From c6f8f26b16aae91b455c4ec116c888477dfdd3d0 Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 21 Nov 2026 10:16:45 +0100 Subject: [PATCH] frontend: the swarm UI's page chrome moves to @hive/shared as AppShell The header bar, the nav row with its sliding underline, the settings menu slot, the skip link and the content column move out of the swarm UI's Shell into a router-free AppShell in @hive/shared, with their CSS. It takes the brand, the nav items, the current location and the link component, plus slots for extra tabs, settings entries and menus. The swarm UI's Shell keeps what is its own on top of it: the open agent-terminal tabs (their CSS moves to DynamicTabs.css), the swarm's settings, links and user menus, the swarm name and the full-bleed routes. No visible change; this is the base for the hive UI to reuse the same chrome. --- frontend/README.md | 3 +- frontend/packages/shared/package.json | 2 + .../src/app-shell/AppShell.css} | 120 +---- .../shared/src/app-shell/AppShell.tsx | 410 +++++++++++++++ .../src/pages/agents/AgentTerminalPage.css | 2 +- .../swarm-ui/src/shell/DynamicTabs.css | 97 ++++ .../packages/swarm-ui/src/shell/Shell.tsx | 490 +++--------------- .../packages/swarm-ui/src/shell/routes.ts | 2 +- frontend/packages/swarm-ui/src/swarm-ui.css | 2 +- .../swarm-ui/src/ui/skeleton/Skeleton.css | 2 +- .../packages/swarm-ui/src/ui/slug/Slug.css | 2 +- .../swarm-ui/src/ui/split-view/SplitView.tsx | 2 +- 12 files changed, 604 insertions(+), 530 deletions(-) rename frontend/packages/{swarm-ui/src/shell/Shell.css => shared/src/app-shell/AppShell.css} (68%) create mode 100644 frontend/packages/shared/src/app-shell/AppShell.tsx create mode 100644 frontend/packages/swarm-ui/src/shell/DynamicTabs.css diff --git a/frontend/README.md b/frontend/README.md index 8c89112b9..4066374dd 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -3,7 +3,8 @@ npm workspaces project for the hyperhive browser-facing assets: - `packages/shared/` — shared modules used by every surface (terminal - pane, Catppuccin palette + body typography). + pane, Catppuccin palette + body typography, the `AppShell` page chrome the + swarm UI mounts). - `packages/dashboard/` — the hive-c0re dashboard SPA. - `packages/agent/` — the per-container web pages (stats, screen). - `packages/swarm-ui/` — the swarm-level operator UI shell (hives, diff --git a/frontend/packages/shared/package.json b/frontend/packages/shared/package.json index fd8221796..791a5cfdb 100644 --- a/frontend/packages/shared/package.json +++ b/frontend/packages/shared/package.json @@ -10,6 +10,8 @@ "preact": "11.2.0" }, "exports": { + "./app-shell.js": "./src/app-shell/AppShell.tsx", + "./app-shell.css": "./src/app-shell/AppShell.css", "./term-msg.js": "./src/terminal/termMsg.ts", "./term-row.js": "./src/terminal/Row.tsx", "./term-linkify.js": "./src/terminal/linkify.tsx", diff --git a/frontend/packages/swarm-ui/src/shell/Shell.css b/frontend/packages/shared/src/app-shell/AppShell.css similarity index 68% rename from frontend/packages/swarm-ui/src/shell/Shell.css rename to frontend/packages/shared/src/app-shell/AppShell.css index 5c6e06e28..406b3f980 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.css +++ b/frontend/packages/shared/src/app-shell/AppShell.css @@ -1,8 +1,6 @@ -/* — header bar + nav row + the content column every route - renders into. Colour vars come from ../theme.css (same base16 slots - the per-hive dashboard uses, so this reads as recognizably - hyperhive) — the layout itself is this package's own, not - @hive/shared's chrome.css. +/* — header bar + nav row + the content column every route + renders into. Colour vars come from @hive/shared's theme.css, the base16 + slots every hyperhive UI uses. `flex-wrap` on the header and nav rather than a hamburger/collapse menu: a narrow viewport (phone or a tiled desktop window) wraps onto @@ -10,7 +8,7 @@ over-invest" is the explicit scope here, not full mobile navigation redesign. - Page-switch animation (see Shell.tsx's file-top comment for the JS + Page-switch animation (see AppShell.tsx's file-top comment for the JS half): both the nav indicator's slide and the page-body pop follow the same three-rule motion-guard shape `@hive/shared/motion-apply.js`'s own doc comment specifies — a base rule, @@ -50,7 +48,7 @@ } .shell-brand { font-weight: 600; - /* Base colour only — Shell.tsx overrides it inline to the same + /* Base colour only — AppShell.tsx overrides it inline to the same currently-active-tab accent `.shell-nav-indicator` uses (falling back to this `--purple` before the first measurement lands, which is also the "hives" default route's own accent, so there's no @@ -108,7 +106,7 @@ } } /* Holds `SettingsMenu` + `LinksMenu` — one `margin-left: auto` on the - wrapper, not one on each child (see Shell.tsx's comment for why two + wrapper, not one on each child (see AppShell.tsx's comment for why two adjacent auto margins don't sit flush together). */ .shell-header-actions { display: flex; @@ -145,9 +143,9 @@ color: var(--fg); } /* Shared underline, one element instead of one border-bottom per link - — see Shell.tsx's file-top comment. `left`/`top`/`width` are set + — see AppShell.tsx's file-top comment. `left`/`top`/`width` are set inline per-render from a real measurement; only the *transition* - between those values lives here. 140ms matches Shell.tsx's `HOP_MS` + between those values lives here. 140ms matches AppShell.tsx's `HOP_MS` exactly, so one hop's CSS transition finishes right as the next hop's JS-driven style update lands, instead of the two blending into an averaged easing curve. */ @@ -179,104 +177,13 @@ /* Suppresses the transition for exactly one render — the indicator's very first real position, so it snaps into place instead of visibly growing from the unmounted `left:0/width:0/transparent` fallback (see - Shell.tsx's `indicatorSettledOnce`). Two-class selector so it wins + AppShell.tsx's `indicatorSettledOnce`). Two-class selector so it wins over the plain `.shell-nav-indicator` rule above without `!important`, same reasoning `:root[data-motion='reduce']`'s extra attribute selector already relies on. */ .shell-nav-indicator.shell-nav-indicator-instant { transition: none; } -/* Dynamic tabs group — inline in `.shell-nav` itself, next to the - static route links (mara, PR review: "the dynamic tab should be in - the top bar, not a new one below" — an earlier cut had this as its - own sticky row under the header; that version and the reasoning for - it are still in this file's git history if the split ever needs to - come back). `margin-left: 0.5em` + `border-left` reads as "a group - attached to the nav, not another nav item" without a second landmark - or a fixed pixel gap that'd fight `.shell-nav`'s own `gap`. */ -.shell-tabs { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 0.5em; - margin-left: 0.5em; - padding-left: 0.75em; - border-left: 1px solid var(--border); -} -.shell-tab { - display: flex; - align-items: center; - gap: 0.25em; - padding: 0.2em 0.4em 0.2em 0.7em; - border-radius: 0.3em; - background: var(--bg); - border: 1px solid var(--border); -} -.shell-tab-active { - border-color: var(--pink); -} -/* A tab that can be dragged onto a terminal to split it shows a grip in a gutter - of its own on hover, so the drag is discoverable. The gutter is part of the - padding, so the tab does not change size when the grip appears. */ -.shell-tab-draggable { - position: relative; - padding-left: 1.3em; - cursor: grab; -} -/* The tab a dragged tab would take the place of. */ -.shell-tab-drop { - box-shadow: inset 2px 0 0 var(--purple); -} -.shell-tab-grip { - position: absolute; - left: 0.35em; - top: 50%; - display: inline-flex; - color: var(--muted); - opacity: 0; - transform: translateY(-50%); - transition: opacity 0.15s ease; - pointer-events: none; -} -.shell-tab-draggable:hover .shell-tab-grip { - opacity: 0.9; -} -@media (prefers-reduced-motion: reduce) { - .shell-tab-grip { - transition: none; - } -} -.shell-tab-link { - color: var(--muted); - text-decoration: none; - font-size: 0.9em; -} -.shell-tab-active .shell-tab-link { - color: var(--fg); -} -.shell-tab-link:hover { - color: var(--fg); -} -/* Same reset every icon-only chrome button in this codebase uses - (`Badge`'s own `