// The hive UI's tabs and the pure parts of its routing, kept apart from // `shell.js` (which needs Preact and the shared shell) so `npm test` can run // them. Routes are the URL hash. export const TABS = [ { href: "agents", label: "agents", accent: "var(--green)" }, { href: "rebuild", label: "rebuild queue", accent: "var(--yellow)" }, { href: "kept", label: "kept state", accent: "var(--red)" }, ]; /** The tab the URL hash names; the first tab for none or an unknown one. */ export function tabOfHash(hash) { const id = hash.replace(/^#/, ""); return TABS.some((t) => t.href === id) ? id : TABS[0].href; } /** Menu entries for a state snapshot. The API docs open in place; the swarm * UI is another site, so it opens in a new tab. The swarm entry only exists * when `/api/state` carries `swarm_public_url`, so a hive without a * configured swarm domain shows no dead link. */ export function menuLinks(state) { const links = [ { icon: "🧬", label: "api docs", url: "/api/docs/", external: false }, ]; if (state && state.swarm_public_url) { links.push({ icon: "🐝", label: "swarm", url: state.swarm_public_url }); } return links; }