From f1c595d39bfbcd20ce2577ddbff53fb7530abc74 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 27 Nov 2026 19:13:33 +1100 Subject: [PATCH] fix(ui): name only the pages the sidebars can open (#2148) Removing the old services' pages left their entries in the sidebar specs, and a nav entry with no route threw during the first render, so the shell drew nothing and every page was blank. The chat browser test caught it, which is the failure #2148 recorded; it passes again. The spec list moves to ui/src/lib/nav-specs.ts, which imports nothing, so a test can check every address it names against the generated page catalogue. That is the guard: deleting a page without updating the sidebars now fails the gate instead of the browser. --- ui/src/lib/nav-specs.ts | 83 +++++++++++++++++++++++++++++++++ ui/src/lib/nav.ts | 98 +-------------------------------------- ui/test/nav-specs.test.ts | 22 +++++++++ 3 files changed, 106 insertions(+), 97 deletions(-) create mode 100644 ui/src/lib/nav-specs.ts create mode 100644 ui/test/nav-specs.test.ts diff --git a/ui/src/lib/nav-specs.ts b/ui/src/lib/nav-specs.ts new file mode 100644 index 000000000..7e9ff78d2 --- /dev/null +++ b/ui/src/lib/nav-specs.ts @@ -0,0 +1,83 @@ +/** + * What the sidebars list, in reading order. + * + * The paths are hand-picked but the pages they name are not: a page that is + * removed leaves its entry here pointing at nothing, so a test checks every + * path against the page catalogue the router generates. + */ +import type { NavSpec } from "./nav-tree"; + +/** The main sidebar: operations, automation, governance and administration. */ +export const specs: NavSpec[] = [ + { + kind: "group", + label: "Operations", + sections: [{ paths: ["/", "/runs", "/proposals"] }], + }, + { + kind: "group", + label: "Automation", + sections: [{ paths: ["/workflows", "/events"] }], + }, + { + kind: "group", + label: "Governance", + sections: [{ paths: ["/controls", "/controls/guards", "/controls/action-types"] }], + }, + { + kind: "group", + label: "Administration", + sections: [{ paths: ["/org", "/settings"] }], + }, +]; + +/** The Organisation sidebar, grouped by what is being configured. */ +export const orgSpecs: NavSpec[] = [ + { kind: "link", path: "/org", label: "Overview" }, + { + kind: "group", + label: "Organisation", + sections: [ + { + label: "People & access", + paths: ["/org/members", "/org/approvals", "/org/workspaces", "/org/policies", "/org/decisions"], + }, + { + label: "Agents", + paths: ["/org/instructions"], + }, + ], + }, +]; + +/** The Instance sidebar: infrastructure and instance limits an administrator + * controls. Organisation resources are not listed here. */ +export const settings: NavSpec = { + kind: "group", + label: "Instance", + sections: [ + { + label: "Models & prompts", + paths: ["/settings/models", "/settings/memory"], + }, + { + label: "Connections & channels", + paths: ["/settings/extensions", "/settings/secret-engines", "/settings/credentials"], + }, + { paths: ["/settings/status", "/settings/organisations", "/settings/authentication"] }, + ], +}; + +/** Reached from elsewhere, and by Jump to, but not from a sidebar. */ +export const unlisted = ["/account", "/account/appearance", "/memory"]; + +/** navPaths lists every address the sidebars and Jump to can name. */ +export function navPaths(): string[] { + const out: string[] = []; + for (const spec of [...specs, ...orgSpecs, settings]) { + if (spec.kind === "link") out.push(spec.path); + else for (const section of spec.sections) out.push(...section.paths); + } + out.push(...unlisted); + return out; +} diff --git a/ui/src/lib/nav.ts b/ui/src/lib/nav.ts index cd09984af..71b2372d6 100644 --- a/ui/src/lib/nav.ts +++ b/ui/src/lib/nav.ts @@ -5,109 +5,13 @@ import { flattenRoutes, type NavNode, type NavRouteNode, - type NavSpec, } from "./nav-tree"; +import { orgSpecs, settings, specs, unlisted } from "./nav-specs"; export type { NavEntry, NavNode } from "./nav-tree"; const table = flattenRoutes(routes as NavRouteNode[]); -// Primary destinations grouped by operational role. Personal security and -// preferences live in the account menu. -const specs: NavSpec[] = [ - { - kind: "group", - label: "Operations", - sections: [{ paths: ["/", "/tasks", "/runs", "/proposals"] }], - }, - { - kind: "group", - label: "Automation", - sections: [{ paths: ["/workflows", "/events"] }], - }, - { - kind: "group", - label: "Governance", - sections: [{ paths: ["/controls", "/controls/guards", "/controls/action-types"] }], - }, - { - kind: "group", - label: "Administration", - sections: [{ paths: ["/org", "/settings"] }], - }, -]; - -// The Organisation sidebar, grouped by what is being configured. Every page -// here is an organisation-owned resource. -const orgSpecs: NavSpec[] = [ - { kind: "link", path: "/org", label: "Overview" }, - { - kind: "group", - label: "Organisation", - sections: [ - { - label: "People & access", - paths: ["/org/members", "/org/approvals", "/org/agents", "/org/workspaces", "/org/policies", "/org/decisions", "/org/audit"], - }, - { - label: "Agents", - paths: ["/org/instructions", "/org/repositories"], - }, - { - label: "Automation", - paths: ["/org/scheduling-policy", "/org/issue-routing", "/org/channels"], - }, - { - label: "Usage", - paths: ["/org/usage"], - }, - ], - }, -]; - -// The Instance sidebar: infrastructure and instance limits an administrator -// controls. Organisation resources are not listed here. -const settings: NavSpec = { - kind: "group", - label: "Instance", - sections: [ - { - label: "Models & prompts", - paths: [ - "/settings/models", - "/settings/skills", - "/settings/curators", - "/settings/memory", - ], - }, - { - label: "Connections & channels", - paths: [ - "/settings/channels", - "/settings/tools", - "/settings/extensions", - "/settings/plugins", - "/settings/secret-engines", - "/settings/credentials", - ], - }, - { - label: "Runtime", - paths: [ - "/settings/task-execution", - "/settings/container-runtime", - "/settings/agent-profiles", - "/settings/status", - ], - }, - { paths: ["/settings/organisations", "/settings/authentication"] }, - ], -}; - -// Reached from the Dashboard's Logs button and the account menu, and by -// Jump to, but not from the bar. -const unlisted = ["/logs", "/account", "/account/appearance", "/memory"]; - /** hiddenPaths lists the routes this composition cannot back. */ export function hiddenPaths(sections: CapabilitySections | null): string[] { return hiddenRoutes(sections, table); diff --git a/ui/test/nav-specs.test.ts b/ui/test/nav-specs.test.ts new file mode 100644 index 000000000..8e7488964 --- /dev/null +++ b/ui/test/nav-specs.test.ts @@ -0,0 +1,22 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +import { navPaths } from "../src/lib/nav-specs.ts"; + +const pages: { path: string }[] = JSON.parse( + readFileSync(new URL("../pages/pages.json", import.meta.url), "utf8"), +); + +// Guards the regression #2121 shipped: the sidebars kept naming pages that were +// removed, and the first render of a nav entry with no route threw, leaving the +// dashboard blank. A page the catalogue does not list is one the router cannot +// open. +test("every destination the sidebars name is a page the dashboard serves", () => { + const known = new Set(pages.map((page) => page.path)); + assert.deepEqual( + navPaths().filter((path) => !known.has(path)), + [], + "the sidebars name addresses no page answers", + ); +});