feat(webui): five-place top bar with Settings, New task and one connection pill
Dashboard, Tasks, Workflows, Events and Settings replace the Work, Agent and System menus. Configuration pages move under /settings/* with redirects from their old paths; Logs and Appearance leave the bar and stay reachable from Jump to, the Dashboard and the account menu. New task opens the Start work form in a dialog and lands on the new task. One pill reports the live stream's state. Drops docs/prds/dashboard-navigation-groups.md: web UI design is not tracked in PRDs.
This commit is contained in:
23 files changed
+453
-383
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import type { StreamState } from "./stream-state";
|
||||
|
||||
export type ConnectionState = StreamState | "connecting";
|
||||
|
||||
/** What the UI calls the live stream's state, and the tone it is shown in. */
|
||||
export function connectionStatus(state: ConnectionState): {
|
||||
label: string;
|
||||
tone: "ok" | "warn" | "danger";
|
||||
} {
|
||||
if (state === "live") return { label: "Connected", tone: "ok" };
|
||||
if (state === "unavailable") return { label: "Disconnected", tone: "danger" };
|
||||
return { label: "Connecting", tone: "warn" };
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
export interface NavEntry {
|
||||
path: string;
|
||||
label: string;
|
||||
description: string;
|
||||
section?: string;
|
||||
dividerBefore?: string;
|
||||
soon?: boolean;
|
||||
}
|
||||
|
||||
export interface NavLink {
|
||||
kind: "link";
|
||||
entry: NavEntry;
|
||||
}
|
||||
|
||||
export interface NavGroup {
|
||||
kind: "group";
|
||||
label: string;
|
||||
items: NavEntry[];
|
||||
}
|
||||
|
||||
export type NavNode = NavLink | NavGroup;
|
||||
|
||||
export interface NavRoute {
|
||||
path: string;
|
||||
meta?: {
|
||||
label?: string;
|
||||
description?: string;
|
||||
section?: string;
|
||||
soon?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type NavSpec =
|
||||
| { kind: "link"; path: string }
|
||||
| {
|
||||
kind: "group";
|
||||
label: string;
|
||||
sections: { label: string; paths: string[] }[];
|
||||
};
|
||||
|
||||
/**
|
||||
* buildNav turns the specs into the bar, with the routes the serving
|
||||
* composition cannot back removed. A group whose every child is hidden is
|
||||
* dropped; each section's label moves to its first visible item. jumpTargets
|
||||
* is everything the bar reaches plus the unlisted pages, for the Jump to box.
|
||||
*/
|
||||
export function buildNav(
|
||||
table: NavRoute[],
|
||||
specs: NavSpec[],
|
||||
hidden: string[] = [],
|
||||
unlisted: string[] = [],
|
||||
): { tree: NavNode[]; jumpTargets: NavEntry[] } {
|
||||
const entryFor = (path: string): NavEntry => {
|
||||
const route = table.find((r) => r.path === path);
|
||||
if (!route) throw new Error(`nav references ${path}, which is not a route`);
|
||||
return {
|
||||
path,
|
||||
label: route.meta?.label ?? path,
|
||||
description: route.meta?.description ?? "",
|
||||
section: route.meta?.section,
|
||||
soon: route.meta?.soon,
|
||||
};
|
||||
};
|
||||
const visible = (path: string) => !hidden.includes(path);
|
||||
|
||||
const tree: NavNode[] = [];
|
||||
for (const spec of specs) {
|
||||
if (spec.kind === "link") {
|
||||
if (visible(spec.path))
|
||||
tree.push({ kind: "link", entry: entryFor(spec.path) });
|
||||
continue;
|
||||
}
|
||||
const items = spec.sections.flatMap((section) =>
|
||||
section.paths
|
||||
.filter(visible)
|
||||
.map(entryFor)
|
||||
.map((entry, i) =>
|
||||
i === 0 ? { ...entry, dividerBefore: section.label } : entry,
|
||||
),
|
||||
);
|
||||
if (items.length > 0) tree.push({ kind: "group", label: spec.label, items });
|
||||
}
|
||||
|
||||
const reached = tree.flatMap((node) =>
|
||||
node.kind === "link" ? [node.entry] : node.items,
|
||||
);
|
||||
const extra = unlisted.filter(visible).map(entryFor);
|
||||
return { tree, jumpTargets: [...reached, ...extra] };
|
||||
}
|
||||
+42
-101
@@ -1,121 +1,62 @@
|
||||
import { routes } from "@/router";
|
||||
import {
|
||||
buildNav,
|
||||
type NavNode,
|
||||
type NavRoute,
|
||||
type NavSpec,
|
||||
} from "./nav-tree";
|
||||
|
||||
export interface NavEntry {
|
||||
path: string;
|
||||
label: string;
|
||||
description: string;
|
||||
section?: string;
|
||||
dividerBefore?: string;
|
||||
soon?: boolean;
|
||||
}
|
||||
export type { NavEntry, NavGroup, NavLink, NavNode } from "./nav-tree";
|
||||
|
||||
export interface NavLink {
|
||||
kind: "link";
|
||||
entry: NavEntry;
|
||||
}
|
||||
|
||||
export interface NavGroup {
|
||||
kind: "group";
|
||||
label: string;
|
||||
items: NavEntry[];
|
||||
}
|
||||
|
||||
export type NavNode = NavLink | NavGroup;
|
||||
|
||||
interface RouteMeta {
|
||||
label?: string;
|
||||
description?: string;
|
||||
section?: string;
|
||||
nav?: boolean;
|
||||
navPath?: string;
|
||||
soon?: boolean;
|
||||
}
|
||||
|
||||
const table = routes as Array<{ path: string; meta?: RouteMeta }>;
|
||||
|
||||
// The bar reads left to right. A destination that is its own top-level thing is
|
||||
// a link rather than a group of one: Events carries the three surfaces that used
|
||||
// to sit in a dropdown, and a group whose only child shares its name is a menu
|
||||
// that says nothing.
|
||||
type NavSpec =
|
||||
| { kind: "link"; path: string }
|
||||
| {
|
||||
kind: "group";
|
||||
label: string;
|
||||
paths: string[];
|
||||
dividerBefore?: { path: string; label: string };
|
||||
};
|
||||
const table = routes as Array<NavRoute & { meta?: { navPath?: string } }>;
|
||||
|
||||
// Five places. Configuration lives under Settings, grouped the way the
|
||||
// settings sidebar groups it (docs/design/ui-redesign/README.md, section 2).
|
||||
const specs: NavSpec[] = [
|
||||
{ kind: "link", path: "/" },
|
||||
{
|
||||
kind: "group",
|
||||
label: "Work",
|
||||
paths: ["/tasks", "/workflows", "/channels", "/logs"],
|
||||
},
|
||||
{ kind: "group", label: "Agent", paths: ["/skills", "/curators"] },
|
||||
{ kind: "link", path: "/tasks" },
|
||||
{ kind: "link", path: "/workflows" },
|
||||
{ kind: "link", path: "/events" },
|
||||
{
|
||||
kind: "group",
|
||||
label: "System",
|
||||
paths: [
|
||||
"/system/status",
|
||||
"/system/appearance",
|
||||
"/system/tasks",
|
||||
"/system/models",
|
||||
"/system/repos",
|
||||
"/system/identities",
|
||||
"/system/advanced",
|
||||
label: "Settings",
|
||||
sections: [
|
||||
{
|
||||
label: "Agents",
|
||||
paths: [
|
||||
"/settings/models",
|
||||
"/settings/skills",
|
||||
"/settings/curators",
|
||||
"/settings/advanced",
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Integrations",
|
||||
paths: [
|
||||
"/settings/channels",
|
||||
"/settings/repositories",
|
||||
"/settings/identities",
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Runtime",
|
||||
paths: ["/settings/task-execution", "/settings/status"],
|
||||
},
|
||||
],
|
||||
dividerBefore: { path: "/system/tasks", label: "Settings" },
|
||||
},
|
||||
];
|
||||
|
||||
function entryFor(path: string): NavEntry {
|
||||
const route = table.find((r) => r.path === path);
|
||||
if (!route) throw new Error(`nav references ${path}, which is not a route`);
|
||||
return {
|
||||
path,
|
||||
label: route.meta?.label ?? path,
|
||||
description: route.meta?.description ?? "",
|
||||
section: route.meta?.section,
|
||||
soon: route.meta?.soon,
|
||||
};
|
||||
}
|
||||
// Reached from the Dashboard's Logs button and the account menu, and by
|
||||
// Jump to, but not from the bar.
|
||||
const unlisted = ["/logs", "/settings/appearance"];
|
||||
|
||||
/**
|
||||
* navTree returns the bar, with routes the serving composition cannot back
|
||||
* removed. A group whose every child is hidden is dropped; a group left with
|
||||
* one child stays a group, so the bar has the same shape on every deployment.
|
||||
*/
|
||||
export function navTree(hidden: string[] = []): NavNode[] {
|
||||
const visible = (e: NavEntry) => !hidden.includes(e.path);
|
||||
const nodes: NavNode[] = [];
|
||||
for (const spec of specs) {
|
||||
if (spec.kind === "link") {
|
||||
const entry = entryFor(spec.path);
|
||||
if (visible(entry)) nodes.push({ kind: "link", entry });
|
||||
continue;
|
||||
}
|
||||
const items = spec.paths.map(entryFor).filter(visible);
|
||||
const divided = items.map((item) => ({
|
||||
...item,
|
||||
dividerBefore:
|
||||
item.path === spec.dividerBefore?.path
|
||||
? spec.dividerBefore.label
|
||||
: undefined,
|
||||
}));
|
||||
if (divided.length > 0)
|
||||
nodes.push({ kind: "group", label: spec.label, items: divided });
|
||||
}
|
||||
return nodes;
|
||||
return buildNav(table, specs, hidden).tree;
|
||||
}
|
||||
|
||||
/** navEntries flattens the tree to the destinations it can reach. */
|
||||
export function navEntries(hidden: string[] = []): NavEntry[] {
|
||||
return navTree(hidden).flatMap((node) =>
|
||||
node.kind === "link" ? [node.entry] : node.items,
|
||||
);
|
||||
/** navEntries lists every destination Jump to can reach. */
|
||||
export function navEntries(hidden: string[] = []) {
|
||||
return buildNav(table, specs, hidden, unlisted).jumpTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user