Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 1 | /** |
| 2 | * A project's pages and the tabs within them, in one place: the sidebar | |
| 3 | * lists the pages, and a page with more than one view shows them as tabs | |
| 4 | * across its top, the way GitHub and Vercel do. Soon tabs come from the | |
| 5 | * roadmap and open its page for them, under the same tabs. | |
| 6 | */ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 7 | import type { Abilities, Capability } from "@g1t/contracts"; |
| 8 | ||
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 9 | import { type RoadmapItem, roadmapIn } from "./roadmap"; |
| 10 | ||
| 11 | export type Tab = { | |
| 12 | label: string; | |
| 13 | /** Under the project, without a leading slash; "" is its overview. */ | |
| 14 | path: string; | |
| 15 | /** Other paths under which this tab is the current one. */ | |
| 16 | also?: string[]; | |
| 17 | soon?: boolean; | |
| 18 | about?: string; | |
| 19 | /** Members only. */ | |
| 20 | members?: boolean; | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 21 | /** Current on its own path only, not on the paths under it. */ |
| 22 | exact?: boolean; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 23 | /** Only for viewers whose role has this capability, once it is known. */ |
| 24 | needs?: Capability; | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 25 | }; |
| 26 | ||
| 27 | export type Section = { | |
| 28 | key: RoadmapItem["section"] | "Workflows" | "Settings"; | |
| 29 | tabs: Tab[]; | |
| 30 | }; | |
| 31 | ||
| 32 | function soon(section: RoadmapItem["section"]): Tab[] { | |
| 33 | return roadmapIn(section).map((item) => ({ label: item.title, path: `soon/${item.key}`, soon: true, about: item.summary })); | |
| 34 | } | |
| 35 | ||
| 36 | export const SECTIONS: Section[] = [ | |
| 37 | { | |
| 38 | key: "Code", | |
| 39 | tabs: [ | |
| 40 | { label: "Files", path: "code", also: ["tree", "blob"] }, | |
| 41 | { label: "Commits", path: "commits", also: ["commit"] }, | |
| Branches and Tags pages, each file's last commit, and the branch menu on files | 42 | { label: "Branches", path: "branches" }, |
| 43 | { label: "Tags", path: "tags" }, | |
| Compare: any two branches, the commits one has that the other does not, and the diff, with Open a pull request | 44 | { label: "Compare", path: "compare" }, |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 45 | ...soon("Code"), |
| 46 | ], | |
| 47 | }, | |
| 48 | { | |
| 49 | key: "Issues", | |
| 50 | tabs: [ | |
| 51 | { label: "Issues", path: "issues" }, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 52 | { label: "Outcomes", path: "plans" }, |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 53 | { label: "Milestones", path: "milestones" }, |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 54 | ...soon("Issues"), |
| 55 | ], | |
| 56 | }, | |
| 57 | { | |
| 58 | key: "Agents", | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 59 | tabs: [ |
| 60 | { label: "At work", path: "agents" }, | |
| 61 | { label: "Sessions", path: "sessions" }, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 62 | { label: "Memory", path: "memory" }, |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 63 | ...soon("Agents"), |
| 64 | ], | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 65 | }, |
| 66 | { | |
| 67 | key: "Deployments", | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 68 | tabs: [{ label: "Deployments", path: "deployments" }, ...soon("Deployments")], |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 69 | }, |
| Observability gets its own page; tabs never overflow | 70 | { key: "Observability", tabs: soon("Observability") }, |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 71 | { |
| 72 | key: "Security", | |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 73 | tabs: [ |
| 74 | { label: "Overview", path: "security", members: true, needs: "push", exact: true }, | |
| 75 | { label: "Secret scanning", path: "security/secret-scanning", members: true, needs: "push" }, | |
| 76 | { label: "Code scanning", path: "security/code-scanning", members: true, needs: "push", also: ["security/pulls"] }, | |
| 77 | { label: "Vulnerabilities", path: "security/vulnerabilities", members: true, needs: "push" }, | |
| 78 | { label: "Dependency graph", path: "security/dependency-graph", members: true, needs: "push" }, | |
| 79 | { label: "Dependency updates", path: "security/dependency-updates", members: true, needs: "push" }, | |
| 80 | { label: "Settings", path: "security/settings", members: true, needs: "push" }, | |
| 81 | ...soon("Security"), | |
| 82 | ], | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 83 | }, |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 84 | { key: "Insights", tabs: soon("Insights") }, |
| 85 | ]; | |
| 86 | ||
| 87 | /** Pull requests and the merge queue share a page's tabs too. */ | |
| 88 | export const PULLS: Section = { | |
| 89 | key: "Code", | |
| 90 | tabs: [ | |
| 91 | { label: "Pull requests", path: "pulls", also: ["pull"] }, | |
| 92 | { label: "Merge queue", path: "queue" }, | |
| 93 | ], | |
| 94 | }; | |
| 95 | ||
| 96 | function matches(rest: string, tab: Tab): boolean { | |
| 97 | return [tab.path, ...(tab.also ?? [])].some((path) => path !== "" && (rest === path || rest.startsWith(`${path}/`))); | |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | * The tabs for the page at `rest` (the path under the project), if it | |
| 102 | * belongs to a page with more than one view. | |
| 103 | */ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 104 | export function tabsFor(rest: string, member: boolean, can?: Partial<Abilities>): Tab[] | null { |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 105 | for (const section of [...SECTIONS, PULLS]) { |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 106 | const visible = section.tabs.filter( |
| 107 | (tab) => (member || !tab.members) && (!tab.needs || !can || Boolean(can[tab.needs])), | |
| 108 | ); | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 109 | if (visible.length > 1 && visible.some((tab) => matches(rest, tab))) return visible; |
| 110 | } | |
| 111 | return null; | |
| 112 | } | |
| 113 | ||
| 114 | /** The first page of a section, for its sidebar link: a built one if any. */ | |
| 115 | export function entryOf(key: Section["key"]): Tab | undefined { | |
| 116 | return SECTIONS.find((section) => section.key === key)?.tabs[0]; | |
| 117 | } |