Watch
0
0
Fork
You've already forked hyperhive
0

frontend: remove the stylix overlay and add hyperhive and Catppuccin light and dark themes

This commit is contained in:
iris 2026-11-22 16:43:49 +01:00 • committed by mara
commit 91e2d26133
4 changed files with 486 additions and 413 deletions

View file

@ -28,7 +28,7 @@ A service module declares its vhost as `services.hyperhive.gateway.vhosts.<name>
| URL | upstream | when |
| --- | --- | --- |
| `<name>.hives.<swarm>/` | dashboard dist (static, from `servedFrontend`), behind authelia | always |
| `<name>.hives.<swarm>/` | dashboard dist (static, from `frontend`), behind authelia | always |
| `<name>.hives.<swarm>/api/` | hive-c0re (`7000`), behind authelia | always |
| `<name>.hives.<swarm>/health/` | hive-c0re (`7000`) | always |
| `<name>.hives.<swarm>/api/docs/` | themed Swagger UI dist (static), behind authelia | always |
@ -278,7 +278,7 @@ hive-c0re serves exactly two prefixes, so the dashboard routes by **path** — d
- `location /api/` → hive-c0re (`7000`): all dashboard data, actions, and the SSE stream (`/api/dashboard/stream`). `proxy_buffering off` and a 1d read timeout keep the stream live.
- `location /health/` → hive-c0re: liveness and readiness.
- `location /` → the dashboard dist (from the `servedFrontend` nix-store path) with `try_files $uri /index.html`.
- `location /` → the dashboard dist (from the `frontend` nix-store path) with `try_files $uri /index.html`.
The gateway static-serves the dist while hive-c0re stays API-only, so a frontend-only change doesn't restart the core daemon. A new top-level c0re route prefix needs a matching `location` on the dashboard vhost (`hive-c0re/vhosts.nix`).
@ -343,7 +343,7 @@ c0re process never leaves a partial or unparseable file behind.
### Per-agent static frontend split
hive-c0re's environment sets `HIVE_AGENT_FRONTEND_DIR` to the `agent/`
subdirectory of `services.hyperhive.deploy.hive-controller.servedFrontend`.
subdirectory of `services.hyperhive.deploy.hive-controller.frontend`.
The nginx include generator (`gateway_nginx::write`) reads
this variable and, when set, emits split location blocks per agent
instead of a single proxy block.

View file

@ -1,15 +1,13 @@
# CSS custom properties (theme variables)
Colour variables live in **two standalone stylesheets**, split so a theme
swap touches only the first:
Colour variables live in **two standalone stylesheets**, split so a new theme
touches only the first:
1. **`colors.css`** — the 16 `--base00`…`--base0F` base16 slots. **This is
the entire theme swap contract.** A generator (for example one fed a stylix
base16 scheme, which is natively base00–base0F) replaces _only this
file_.
the whole theme contract.** A theme is 16 colours here and nothing else.
2. **`theme.css`** — the semantic layer: `--bg`, `--fg`, `--purple`, …
_derived_ from the base16 slots (`--bg: var(--base00)` etc.). This is
what the app references and it **never changes on a swap**.
what the app references and it **doesn't change per theme**.
Both files live in `frontend/packages/shared/src/`. Per-page stylesheets
(`common.css`, `dashboard.css`, `agent.css`)
@ -17,23 +15,35 @@ reference the **semantic** names and must **not** redeclare them or reach
for the raw `--baseNN` slots directly. (`base.css` holds only the shared
`body` typography — it references the palette but no longer defines it.)
`colors.css` declares each palette's 16 hex values exactly once —
`--mocha-baseNN` (dark, Catppuccin Mocha) and `--latte-baseNN` (light,
Catppuccin-Latte-derived; `base08`-`base0F` run darker than stock
Latte to actually clear WCAG AA against how this app uses them — real
contrast failures found in review, see the comment above those
declarations in `colors.css` for the numbers and why). Everything else
in the file just points the active `--baseNN` slot at one of those two
raw palettes via `var()`, never a second copy of a hex value: an
unconditional default (Mocha), a row gated behind `@media
(prefers-color-scheme: light)` (Latte, the OS/browser-level default),
and two `:root[data-theme='light'|'dark']` blocks a per-user override
sets (swarm-ui's `SettingsMenu`) — an attribute selector always
outranks the plain `:root` inside the media query, so the override wins
regardless of the actual OS preference. Absent an override, the media
query decides; that's what a client with no more specific theme
decision gets (see "Theme swapping" below for how a stylix deployment
supersedes all of this at once).
`colors.css` declares each theme's 16 hex values exactly once, as
`--<theme>-baseNN`, for five themes that are each light or dark:
| Theme | Id | Scheme | Palette |
| ---------------------- | ------------------------ | ------ | ------------------------------------------------------------------ |
| hyperhive light | `hyperhive-light` | light | Latte's neutrals, accents darker than stock to clear WCAG AA |
| hyperhive dark | `hyperhive-dark` | dark | Mocha's neutrals, the light accents' hues lifted to suit a dark bg |
| catppuccin latte mauve | `catppuccin-latte-mauve` | light | Catppuccin Latte as published |
| catppuccin mocha mauve | `catppuccin-mocha-mauve` | dark | Catppuccin Mocha as published |
| catppuccin mocha mara | `catppuccin-mocha-mara` | dark | Mocha with the accents mara picked |
The hyperhive light accents (`base08`-`base0F`) run darker than stock Latte
because the stock ones fail contrast as badge text and as plain text; the
comment above them in `colors.css` has the numbers. The hyperhive dark
accents keep those hues and saturations and raise the lightness until each
clears 6:1 against `base02`.
Everything else in the file points the active `--baseNN` slots at one of
those raw palettes via `var()`, never a second copy of a hex value: an
unconditional default (hyperhive dark), a block gated behind
`@media (prefers-color-scheme: light)` (hyperhive light, the OS-level
default), and one `:root[data-theme='<id>']` block per theme, which the
settings menu's theme select sets. An attribute selector always outranks
the plain `:root` inside the media query, so a picked theme wins whatever
the OS prefers. The select's **auto** choice sets no `data-theme`, so the
media query decides.
`frontend/packages/shared/src/settings/themes.ts` lists the ids, labels and
schemes; adding a theme is one entry there and one palette plus one block in
`colors.css`.
Both are deliberately standalone, not `@import`ed into the page bundles:
each package re-exports them (`src/{colors,theme}.css` →
@ -139,26 +149,22 @@ color: var(--amber); /* warning / running */
color: var(--green); /* ok */
```
## Theme swapping — the base16 contract
## Themes — the base16 contract
**The swap interface is `colors.css` — the 16 base16 slots, not the
semantic names.** A theme generator (for example one reading a stylix base16
scheme) overrides only `colors.css`; the semantic layer in `theme.css`
derives everything else, so the whole UI re-themes with nothing else to
template or regenerate. The base16 slot → semantic mapping is _internal_
to `theme.css` (the "Derives from" column above) — a generator never
needs to know the semantic var names, and `theme.css` + the page bundles stay
untouched.
**The theme interface is `colors.css` — the 16 base16 slots, not the
semantic names.** The semantic layer in `theme.css` derives everything
else, so a new theme needs nothing else to template or regenerate. The
base16 slot → semantic mapping is _internal_ to `theme.css` (the "Derives
from" column above): a theme never needs the semantic var names, and
`theme.css` and the page bundles stay untouched.
**Two palettes, one contract.** `colors.css` ships both a dark default
(Catppuccin Mocha, unconditional) and a light default (Catppuccin Latte,
behind `@media (prefers-color-scheme: light)`), plus a per-user override
path (`:root[data-theme]`) — a theme generator that overrides the file
wholesale (for example the stylix path, which writes a single unconditional
`:root` block with no media query, no `--mocha-*`/`--latte-*` vars, no
`[data-theme]` blocks) supersedes all of it at once, same as today.
**Five palettes, one contract.** `colors.css` ships the five themes in the
table above, each light or dark, with hyperhive dark as the unconditional
default and hyperhive light behind `@media (prefers-color-scheme: light)`.
Each theme's block also sets `color-scheme` and the contrast shares of
`theme.css` (`--muted-share` and friends) for its scheme.
`colors.css` base16 slot defaults (Catppuccin Mocha, dark default):
`colors.css` base16 slots in the dark palettes (the values are Catppuccin Mocha's; hyperhive dark differs in `base08`-`base0F`):
| Slot | Default | Standard base16 role | Mapped to |
| -------- | --------- | -------------------- | ---------------------------------------------------------- |
@ -187,10 +193,8 @@ Notes for theme authors:
`--muted`/`--subtext0` = `base05`↔`base00` blends). They still track a
swap automatically; no generator action needed.
- A standard Catppuccin base16 scheme uses **teal** for `base0C`;
`colors.css` defaults it to **sky** (`#89dceb`) to preserve the historical
accent. A
stylix Catppuccin scheme will shift `--cyan` to teal — that's the
operator's chosen scheme, working as intended.
`colors.css` uses **sky** (`#89dceb` in Mocha) to keep the historical
accent.
- `base04`/`base06`/`base07` aren't consumed by a semantic var today;
they're kept at their standard values so the 16-slot contract is
complete (a partial scheme override still works).

View file

@ -240,6 +240,13 @@ stream with an error status, the browser gives up and the badge reads
**disconnected**. The **reconnect** button beside it opens the stream again, and
the stream replays the rows. The message log card works the same way.
The settings menu in the header has a **theme** select: **auto**, which follows
the OS and picks hyperhive light or hyperhive dark, then hyperhive light,
hyperhive dark, catppuccin latte mauve, catppuccin mocha mauve and catppuccin
mocha mara. Each theme is light or
dark, and a pick beats the OS preference. The browser remembers the choice, and
hyperhive dark applies until a user picks one. The hive dashboard's menu has the same select.
The settings menu in the header has a **hide developer details** toggle. It drops
the muted debug rows (coalesced ticks, harness chatter) from every
terminal, the preview and the tabs, and rows already on screen hide or show as

View file

@ -39,7 +39,7 @@ repeated here.
generation, mainly for shape/elevation ideas. Colour is dynamic too —
autoderived shades (mixing, lighter/darker) are fair game, same as
Material's own approach — but every derived colour still traces back
to the base16/stylix contract below, never an independent source.
to the base16 contract below, never an independent source.
## Motion
@ -64,17 +64,16 @@ The mechanical contract (base16 slots, semantic vars, what a page's CSS
is and isn't allowed to reference) lives in `docs/4-implementation/web-ui/css-vars.md` —
read that for the how. This section is the _policy_ layered on top:
- **User-theming compatible by construction.** The whole point of the
base16/`colors.css` swap contract is that a user's own theme (stylix
today) takes over with zero swarm-ui code changes. Don't build
- **Theme-agnostic by construction.** The whole point of the
base16/`colors.css` contract is that a new theme is 16 colours with zero
swarm-ui code changes. Don't build
anything that assumes a specific palette's exact colours (contrast
ratios, "this accent is always purple") beyond what the semantic var
names promise.
- **stylix wins outright when it's active, no in-between state.** When
an operator has stylix supplying swarm-ui's palette, that palette is
authoritative — swarm-ui's own light/dark preference (below) doesn't
override it. This is a deliberate simplification, not a limitation to
fix: a stylix-using operator has already made their choice.
- **Every theme is light or dark.** A theme declares its scheme, so the
browser's own controls, scrollbars and dialog backdrops follow it. The
user's pick wins over the OS preference; **auto** follows the OS and
chooses hyperhive light or hyperhive dark.
- **Light theme is accessibility, not a cosmetic extra.** Some people
need light for contrast/low-vision reasons, others need dark for
photosensitivity — there's no universally correct default. The OS