From a8628de625b129a14e95521a2a8068748dd4e8b8 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 27 Nov 2026 16:38:02 +1100 Subject: [PATCH] fix(ui): merge folder parent routes so nav shows labels; drop dead legacy redirects --- internal/app/archied/alerts.go | 6 ++-- ui/src/lib/nav-tree.ts | 25 +++++++++++--- ui/src/router/redirects.ts | 59 +--------------------------------- ui/test/nav-tree.test.ts | 19 ++++++++++- 4 files changed, 43 insertions(+), 66 deletions(-) diff --git a/internal/app/archied/alerts.go b/internal/app/archied/alerts.go index 3b7978ab7..e3b203808 100644 --- a/internal/app/archied/alerts.go +++ b/internal/app/archied/alerts.go @@ -164,7 +164,7 @@ func providerAlerts(providers map[string]config.Provider) []alert.Input { Severity: alert.SeverityAction, Condition: true, Title: fmt.Sprintf("Provider %q has no usable credential", name), Body: "Key unresolved; its models cannot run. Check the binding.", - Link: "/settings/credential-bindings", + Link: "/settings/credentials", }) } return out @@ -218,7 +218,7 @@ func unboundAlerts(cfg config.Config) map[org.OrgID][]alert.Input { Key: key, Severity: alert.SeverityAction, Condition: true, Title: fmt.Sprintf("%q is granted but has no credential binding", service), Body: "Runs cannot authenticate. Bind a credential.", - Link: "/settings/credential-bindings", + Link: "/settings/credentials", }) } } @@ -445,7 +445,7 @@ func (w *credentialWatch) observe(ctx context.Context, orgName, service string, Key: key, Severity: alert.SeverityAction, Condition: true, Title: fmt.Sprintf("The credential bound to %q is not working", service), Body: "Secret unresolved; runs cannot authenticate. Check the binding.", - Link: "/settings/credential-bindings", + Link: "/settings/credentials", }) }() } diff --git a/ui/src/lib/nav-tree.ts b/ui/src/lib/nav-tree.ts index 4eda1ebd7..2998abf26 100644 --- a/ui/src/lib/nav-tree.ts +++ b/ui/src/lib/nav-tree.ts @@ -49,18 +49,35 @@ export function flattenRoutes( list: NavRouteNode[], parent = "", ): NavRouteNode[] { + return mergeSamePath(flatten(list, parent)); +} + +function flatten(list: NavRouteNode[], parent: string): NavRouteNode[] { return list.flatMap((route) => { const joined = route.path.startsWith("/") ? route.path : `${parent}/${route.path}`.replace(/\/+/g, "/"); const path = joined.length > 1 ? joined.replace(/\/$/, "") : joined; - return [ - { ...route, path }, - ...flattenRoutes(route.children ?? [], path), - ]; + return [{ ...route, path }, ...flatten(route.children ?? [], path)]; }); } +// File-based routing wraps a folder's index page in a parent route with no +// meta of its own (runs/ holds index.vue and [id].vue), and a layout route +// shares its address with its index child. Both answer at one address, so +// they merge into one entry; the earlier route's fields win. +function mergeSamePath(routes: NavRouteNode[]): NavRouteNode[] { + const byPath = new Map(); + for (const route of routes) { + const seen = byPath.get(route.path); + byPath.set( + route.path, + seen ? { ...route, ...seen, meta: { ...route.meta, ...seen.meta } } : route, + ); + } + return [...byPath.values()]; +} + export type NavSpec = | { kind: "link"; path: string; label?: string } | { diff --git a/ui/src/router/redirects.ts b/ui/src/router/redirects.ts index ef2f3827f..f9218fad1 100644 --- a/ui/src/router/redirects.ts +++ b/ui/src/router/redirects.ts @@ -1,38 +1,4 @@ -import type { RouteLocationGeneric, RouteRecordRaw } from "vue-router"; - -const legacyRedirects: Record = { - // The old unified Access area and the org-owned settings that used to sit - // under Settings resolve to the Organisation destination (or Account for - // personal tokens, which were never the org's). - "/access": "/org", - "/access/authentication": "/settings/authentication", - "/access/agents": "/org/agents", - "/access/workspaces": "/org/workspaces", - "/access/policies": "/org/policies", - "/access/models": "/org/models", - "/access/tokens": "/account", - "/settings/identities": "/org/agents", - "/settings/access-policies": "/org/policies", - "/settings/connections": "/org/connections", - "/settings/repositories": "/org/repositories", - "/settings/credential-bindings": "/org/credential-bindings", - "/settings/soul": "/org/instructions", - "/org/soul": "/org/instructions", - "/settings/schedules": "/org/schedules", - "/settings/playbooks": "/org/playbooks", - "/settings/scheduling-policy": "/org/scheduling-policy", - "/settings/appearance": "/account/appearance", - // Paths from before Settings existed, kept for bookmarks and chat history. - "/system/status": "/settings/status", - "/system/appearance": "/account/appearance", - "/system/tasks": "/settings/task-execution", - "/system/models": "/settings/models", - "/system/repos": "/settings/repositories", - "/system/identities": "/org/agents", - "/channels": "/org/channels", - "/skills": "/settings/skills", - "/curators": "/settings/curators", -}; +import type { RouteRecordRaw } from "vue-router"; /** * Redirect-only routes that do not correspond to a page component under @@ -115,27 +81,4 @@ export const redirects: RouteRecordRaw[] = [ description: "Workflows and the events that start them.", }, }, - { - path: "/settings/history", - redirect: (to: RouteLocationGeneric) => ({ - path: "/org/audit", - query: to.query, - hash: to.hash, - }), - meta: { nav: false }, - }, - { - path: "/settings/audit", - redirect: (to: RouteLocationGeneric) => ({ - path: "/org/audit", - query: to.query, - hash: to.hash, - }), - meta: { nav: false }, - }, - ...Object.entries(legacyRedirects).map(([path, redirect]) => ({ - path, - redirect, - meta: { nav: false }, - })), ]; diff --git a/ui/test/nav-tree.test.ts b/ui/test/nav-tree.test.ts index 85ed63e28..90ec245db 100644 --- a/ui/test/nav-tree.test.ts +++ b/ui/test/nav-tree.test.ts @@ -90,7 +90,7 @@ test("a nav spec names the address the browser visits, not the child's own path" ]); assert.deepEqual( flat.map((r) => r.path), - ["/org", "/org", "/org/agents", "/org/settings/keys", "/org/settings/keys/new", "/absolute", "/absolute/child"], + ["/org", "/org/agents", "/org/settings/keys", "/org/settings/keys/new", "/absolute", "/absolute/child"], ); }); @@ -123,3 +123,20 @@ test("an unlabelled section marks its first item with an empty divider", () => { ], ); }); + +// Guards the sidebar showing "/runs" instead of "Runs": file-based routing +// wraps a folder's index page in a parent route that carries no meta. +test("a metaless folder route merges with its index page", () => { + const flat = flattenRoutes([ + { + path: "/runs", + children: [ + { path: "", meta: { label: "Runs", description: "All runs" } }, + { path: ":id", meta: { label: "Run" } }, + ], + }, + ]); + const runs = flat.filter((r) => r.path === "/runs"); + assert.equal(runs.length, 1); + assert.equal(runs[0].meta?.label, "Runs"); +});