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.
This commit is contained in:
sam committed 2026-11-27 19:13:33 +11:00
1 parent 5cc59c31c6
commit f1c595d39b
3 files changed
+106 -97

No files matched your search

+83
View File
@@ -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;
}
+1 -97
View File
@@ -5,109 +5,13 @@ import {
flattenRoutes, flattenRoutes,
type NavNode, type NavNode,
type NavRouteNode, type NavRouteNode,
type NavSpec,
} from "./nav-tree"; } from "./nav-tree";
import { orgSpecs, settings, specs, unlisted } from "./nav-specs";
export type { NavEntry, NavNode } from "./nav-tree"; export type { NavEntry, NavNode } from "./nav-tree";
const table = flattenRoutes(routes as NavRouteNode[]); 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. */ /** hiddenPaths lists the routes this composition cannot back. */
export function hiddenPaths(sections: CapabilitySections | null): string[] { export function hiddenPaths(sections: CapabilitySections | null): string[] {
return hiddenRoutes(sections, table); return hiddenRoutes(sections, table);
+22
View File
@@ -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",
);
});