g1t/apps/web/app/routes/workspace/layout.tsx
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.
| Integrations: your own model provider, alerts that open issues, tickets agents read | 1 | import { CreditCard, KeyRound, LayoutGrid, Plug, Plus, Settings, Users } from "lucide-react"; |
| A catalogue of model providers, and settings that feel like settings | 2 | import { Outlet, data, useLocation, useRouteLoaderData } from "react-router"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 3 | |
| 4 | import type { Route } from "./+types/layout"; | |
| Social cards for every page: og.g1t.sh | 5 | import { page } from "../../lib/meta"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 6 | import { Avatar, ButtonLink, Pill, TabLink } from "../../components/ui"; |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 7 | import { redirectIfRenamed } from "../../lib/renamed.server"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 8 | import { identity } from "../../lib/services.server"; |
| 9 | import { getViewer, roleIn } from "../../lib/session.server"; | |
| 10 | ||
| Social cards for every page: og.g1t.sh | 11 | export function meta({ loaderData, params, ...args }: Route.MetaArgs) { |
| 12 | return page(args, { title: `${loaderData?.workspace.name ?? params.owner} · g1t` }); | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 13 | } |
| 14 | ||
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 15 | export async function loader({ params, context, request }: Route.LoaderArgs) { |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 16 | const workspace = await identity.getWorkspace(params.owner); |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 17 | if (!workspace) { |
| 18 | // A workspace's old name, after a rename: its pages are at the new one. | |
| 19 | await redirectIfRenamed(request, params.owner); | |
| 20 | throw data(null, { status: 404 }); | |
| 21 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 22 | return { workspace, role: roleIn(getViewer(context), workspace.slug) }; |
| 23 | } | |
| 24 | ||
| A catalogue of model providers, and settings that feel like settings | 25 | /** A workspace's own pages, each with its title and what it is for. */ |
| 26 | const PAGES: Record<string, { title: string; about: string }> = { | |
| Workspace names and icons, and a component kit for every control | 27 | settings: { title: "General", about: "The workspace's name, icon, address and description." }, |
| A catalogue of model providers, and settings that feel like settings | 28 | people: { |
| 29 | title: "Members", | |
| 30 | about: "Members create repositories, push, manage issues and merge pull requests. Owners also manage members, tokens, billing and integrations.", | |
| 31 | }, | |
| 32 | tokens: { | |
| 33 | title: "Access tokens", | |
| 34 | about: "Tokens that belong to the workspace, not a person: for CI, integrations and agents that work for the whole team.", | |
| 35 | }, | |
| 36 | usage: { title: "Usage", about: "What the workspace's agents cost, run by run, by repository, pull request and model." }, | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 37 | billing: { title: "Billing and plans", about: "Paid plans, agent credit, and every charge against it." }, |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 38 | agents: { |
| 39 | title: "Agent fleet", | |
| 40 | about: "Every agent at work across the workspace's projects: what each holds, what it is doing now, and what it has cost.", | |
| 41 | }, | |
| 42 | memory: { | |
| 43 | title: "Workspace memory", | |
| 44 | about: "What holds across all of the workspace's projects, given to every agent in every one of them, beside each project's own memory.", | |
| 45 | }, | |
| Webhooks: every event, to your own addresses, signed and retried | 46 | webhooks: { |
| 47 | title: "Webhooks", | |
| 48 | about: "Every repository's events, sent to your own addresses as they happen. A repository can also have its own, under its settings.", | |
| 49 | }, | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 50 | secrets: { |
| 51 | title: "Secrets and variables", | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 52 | about: "Shared with every repository, or the ones you link: read by workflows, deployments, or both. A repository's own row of the same key wins.", |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 53 | }, |
| A catalogue of model providers, and settings that feel like settings | 54 | integrations: { |
| 55 | title: "Integrations", | |
| 56 | about: "Model providers, alerts and trackers. Secrets are sealed when saved, and agents never see them.", | |
| 57 | }, | |
| 58 | }; | |
| 59 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 60 | export default function WorkspaceLayout({ loaderData }: Route.ComponentProps) { |
| 61 | const { workspace, role } = loaderData; | |
| 62 | const base = `/${workspace.slug}`; | |
| 63 | const signedIn = useRouteLoaderData("root")?.user != null; | |
| A catalogue of model providers, and settings that feel like settings | 64 | // The sidebar finds the workspace's pages for someone signed in, so its |
| 65 | // pages need a title, not the workspace's whole header again. | |
| 66 | const page = PAGES[useLocation().pathname.split("/-/")[1]?.split("/")[0] ?? ""]; | |
| 67 | if (signedIn && page) { | |
| 68 | return ( | |
| 69 | <div className="mx-auto max-w-5xl px-4 py-10 sm:px-8"> | |
| 70 | <header className="mb-8 border-b border-line pb-6"> | |
| 71 | <h1 className="text-2xl font-semibold tracking-tight">{page.title}</h1> | |
| 72 | <p className="mt-1.5 text-sm text-muted">{page.about}</p> | |
| 73 | </header> | |
| 74 | <Outlet /> | |
| 75 | </div> | |
| 76 | ); | |
| 77 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 78 | return ( |
| 79 | <> | |
| 80 | {/* The workspace's own header band, under the site header. */} | |
| 81 | <div className="border-b border-line bg-surface/60"> | |
| 82 | <div className="mx-auto max-w-6xl px-4 pt-8"> | |
| 83 | <div className="flex flex-wrap items-center gap-4"> | |
| Workspace names and icons, and a component kit for every control | 84 | <Avatar name={workspace.slug} image={workspace.avatar} size={52} square /> |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 85 | <div className="min-w-0 grow"> |
| 86 | <div className="flex flex-wrap items-center gap-2.5"> | |
| 87 | <h1 className="truncate text-2xl font-semibold tracking-tight"> | |
| 88 | {workspace.name} | |
| 89 | </h1> | |
| 90 | {role && <Pill>{role}</Pill>} | |
| 91 | </div> | |
| 92 | <p className="font-mono text-sm text-muted">g1t.sh/{workspace.slug}</p> | |
| 93 | </div> | |
| 94 | {role && ( | |
| 95 | <ButtonLink to={`/new?workspace=${workspace.slug}`}> | |
| 96 | <Plus size={15} /> | |
| Projects live: fixes from walking them end to end | 97 | New project |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 98 | </ButtonLink> |
| 99 | )} | |
| 100 | </div> | |
| 101 | {workspace.description && ( | |
| 102 | <p className="mt-4 max-w-2xl text-sm text-muted">{workspace.description}</p> | |
| 103 | )} | |
| 104 | {signedIn ? ( | |
| 105 | <div className="pb-8" /> | |
| 106 | ) : ( | |
| 107 | <nav className="mt-6 flex flex-wrap gap-x-6"> | |
| 108 | <TabLink to={base} end icon={<LayoutGrid size={15} />}> | |
| 109 | Overview | |
| 110 | </TabLink> | |
| 111 | {role && ( | |
| 112 | <> | |
| 113 | <TabLink | |
| 114 | to={`${base}/-/people`} | |
| 115 | icon={<Users size={15} />} | |
| 116 | count={workspace.memberCount} | |
| 117 | > | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 118 | Members |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 119 | </TabLink> |
| 120 | <TabLink to={`${base}/-/tokens`} icon={<KeyRound size={15} />}> | |
| 121 | Access tokens | |
| 122 | </TabLink> | |
| 123 | <TabLink to={`${base}/-/billing`} icon={<CreditCard size={15} />}> | |
| 124 | Billing | |
| 125 | </TabLink> | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 126 | <TabLink to={`${base}/-/integrations`} icon={<Plug size={15} />}> |
| 127 | Integrations | |
| 128 | </TabLink> | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 129 | </> |
| 130 | )} | |
| 131 | {role === "owner" && ( | |
| 132 | <TabLink to={`${base}/-/settings`} icon={<Settings size={15} />}> | |
| 133 | Settings | |
| 134 | </TabLink> | |
| 135 | )} | |
| 136 | </nav> | |
| 137 | )} | |
| 138 | </div> | |
| 139 | </div> | |
| 140 | <div className="mx-auto max-w-6xl px-4 py-8"> | |
| 141 | <Outlet /> | |
| 142 | </div> | |
| 143 | </> | |
| 144 | ); | |
| 145 | } |