Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: move the shell's route layout predicates out and test them

isFullBleedRoute and isWideBodyRoute are plain functions of a path, so
they move from Shell.tsx to shell/routes.ts, where the new tests cover
the start page, the hive directory's move to /hives, the terminal
paths and the wide-body routes.
This commit is contained in:
iris 2026-10-14 16:22:08 +02:00 • committed by mara
commit 01e58219cf
3 changed files with 78 additions and 32 deletions

View file

@ -0,0 +1,35 @@
// Which layout a route gets inside the shell: the readable-width cap, the
// wide body, or full-bleed. Kept apart from `Shell.tsx` so it is plain
// functions of a path, with no DOM or CSS behind it, and can be tested.
// Routes that opt out of `.shell-body`'s 60em readable-line-length cap
// — mara screenshotted the issue report's 8-column table getting
// clipped; that width is deliberate for the rest of the UI's cards/
// forms, but too narrow for a wide table. `.shell-body-wide` (Shell.css) is a
// modifier alongside the base class, not a replacement, so every other
// route's layout is untouched. `/agents` joined for the same reason —
// its own table view (plus the list+detail split) hits the same cap.
const WIDE_BODY_ROUTES = new Set([
"/issues",
"/agents",
"/review-runs",
"/review-tryout",
]);
// `/agents/:name/terminal` (and a subagent's, under
// `/agents/:name/subagents/:subagent/`) is full-bleed: the terminal fills
// the whole viewport below the header bar, edge to edge (`shell-full` /
// `shell-body-full` in Shell.css). It can't join the `Set` above — it's a
// parameterized path, one literal string can't match every agent name.
const FULL_BLEED_ROUTE_PATTERN =
/^\/agents\/[^/]+(\/subagents\/[^/]+)?\/terminal$/;
// The start page (`/`) is full-bleed too: its rain backdrop fills the whole
// body below the header.
export function isFullBleedRoute(location: string): boolean {
return location === "/" || FULL_BLEED_ROUTE_PATTERN.test(location);
}
export function isWideBodyRoute(location: string): boolean {
return WIDE_BODY_ROUTES.has(location);
}