g1t/apps/web/app/routes/repo/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.
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 1 | import { Box, Lock } from "lucide-react"; |
| 2 | import { Link, NavLink, Outlet, useLocation, useRouteLoaderData } from "react-router"; | |
| Projects: what a workspace builds and runs, first on every page | 3 | |
| 4 | import type { Project } from "@g1t/contracts"; | |
| Initial g1t: services, event bus, intents and attempts | 5 | |
| 6 | import type { Route } from "./+types/layout"; | |
| Social cards for every page: og.g1t.sh | 7 | import { page } from "../../lib/meta"; |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 8 | import { type Tab as PageTab, tabsFor } from "../../lib/project-nav"; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 9 | import { Pill } from "../../components/ui"; |
| 10 | import { notFound } from "../../lib/not-found.server"; | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 11 | import { redirectIfRenamed } from "../../lib/renamed.server"; |
| Projects: what a workspace builds and runs, first on every page | 12 | import { projects, repos, work } from "../../lib/services.server"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 13 | import { getViewer, roleIn, unwrap } from "../../lib/session.server"; |
| Initial g1t: services, event bus, intents and attempts | 14 | |
| Social cards for every page: og.g1t.sh | 15 | export function meta({ loaderData: loaded, params, ...args }: Route.MetaArgs) { |
| 16 | return page(args, { title: `${loaded?.project?.name ?? params.repo} · ${params.owner} · g1t` }); | |
| Initial g1t: services, event bus, intents and attempts | 17 | } |
| 18 | ||
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 19 | export async function loader({ params, context, request }: Route.LoaderArgs) { |
| Initial g1t: services, event bus, intents and attempts | 20 | const viewer = getViewer(context); |
| 21 | const path = { namespace: params.owner, name: params.repo }; | |
| Projects: what a workspace builds and runs, first on every page | 22 | const [repo, counts, found] = await Promise.all([ |
| Rust repos service with shipping; pull requests kept in the model | 23 | repos.get(path, viewer), |
| Issues and pull requests replace intents and attempts | 24 | work.counts(path, viewer), |
| Projects: what a workspace builds and runs, first on every page | 25 | projects.get(params.owner, params.repo, viewer), |
| Initial g1t: services, event bus, intents and attempts | 26 | ]); |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 27 | if (!repo.ok && !found.ok) { |
| 28 | // Under a workspace's old name, after a rename: the project is at the new one. | |
| 29 | await redirectIfRenamed(request, params.owner); | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 30 | throw notFound("project"); |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 31 | } |
| Projects: what a workspace builds and runs, first on every page | 32 | let project: Project | null = found.ok ? found.value : null; |
| 33 | // A repository made a moment ago, before its project: make it now. | |
| 34 | if (!project && repo.ok && !repo.value.forkOf) { | |
| 35 | const own = await projects.byRepo(repo.value.id); | |
| 36 | project = own.find((p) => p.slug === params.repo.toLowerCase()) ?? own[0] ?? null; | |
| 37 | } | |
| Initial g1t: services, event bus, intents and attempts | 38 | return { |
| 39 | repo: unwrap(repo), | |
| Projects: what a workspace builds and runs, first on every page | 40 | project, |
| Issues and pull requests replace intents and attempts | 41 | open: counts.ok ? counts.value : { issues: 0, pulls: 0 }, |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 42 | member: roleIn(viewer, params.owner) != null, |
| Initial g1t: services, event bus, intents and attempts | 43 | }; |
| 44 | } | |
| 45 | ||
| Projects: what a workspace builds and runs, first on every page | 46 | /** The project the page is in, for the pages under it. */ |
| 47 | export function useProject() { | |
| 48 | return useRouteLoaderData<typeof loader>("routes/repo/layout"); | |
| 49 | } | |
| 50 | ||
| Search across all of g1t, Explore, and a command palette | 51 | /** A repository's topics, each a way into Explore. */ |
| 52 | function Topics({ topics }: { topics: string[] | undefined }) { | |
| 53 | if (!topics?.length) return null; | |
| 54 | return ( | |
| 55 | <div className="mt-2 flex flex-wrap gap-1.5"> | |
| 56 | {topics.map((topic) => ( | |
| 57 | <Link | |
| 58 | key={topic} | |
| 59 | to={`/explore?topic=${encodeURIComponent(topic)}`} | |
| 60 | className="rounded-full bg-accent/10 px-2 py-px text-xs text-accent ring-1 ring-accent/30 transition-colors hover:bg-accent/20" | |
| 61 | > | |
| 62 | {topic} | |
| 63 | </Link> | |
| 64 | ))} | |
| 65 | </div> | |
| 66 | ); | |
| 67 | } | |
| 68 | ||
| Projects: what a workspace builds and runs, first on every page | 69 | function Header({ project, isPrivate, namespace, name, description, large }: { |
| 70 | project: Project | null; | |
| 71 | isPrivate: boolean; | |
| 72 | namespace: string; | |
| 73 | name: string; | |
| 74 | description: string | null; | |
| 75 | large?: boolean; | |
| 76 | }) { | |
| 77 | const base = `/${namespace}/${name}`; | |
| 78 | return ( | |
| 79 | <div className="flex flex-wrap items-center gap-x-3 gap-y-1"> | |
| 80 | <span | |
| 81 | className={`flex shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line ${large ? "size-8" : "size-6"}`} | |
| 82 | > | |
| 83 | {isPrivate ? <Lock size={large ? 15 : 13} /> : <Box size={large ? 15 : 13} />} | |
| 84 | </span> | |
| 85 | <h1 className={large ? "text-lg" : "text-[0.9375rem]"}> | |
| 86 | <Link to={`/${namespace}`} className="font-mono text-muted hover:text-fg"> | |
| 87 | {namespace} | |
| 88 | </Link> | |
| 89 | <span className="mx-1.5 text-faint">/</span> | |
| 90 | <Link to={base} className="font-semibold hover:underline"> | |
| 91 | {project?.name ?? name} | |
| 92 | </Link> | |
| 93 | </h1> | |
| 94 | <Pill>{isPrivate ? "private" : "public"}</Pill> | |
| 95 | {description && <p className="min-w-0 truncate text-sm text-muted">{description}</p>} | |
| 96 | </div> | |
| 97 | ); | |
| 98 | } | |
| 99 | ||
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 100 | /** |
| 101 | * The views of the page the project is on, as tabs across its top: Files, | |
| 102 | * Commits and what is coming under Code, and so on. Soon tabs open their | |
| 103 | * roadmap page, under the same tabs. | |
| 104 | */ | |
| 105 | function PageTabs({ base, tabs }: { base: string; tabs: PageTab[] }) { | |
| 106 | const { pathname } = useLocation(); | |
| 107 | const rest = pathname.slice(base.length + 1); | |
| 108 | const current = (tab: PageTab) => | |
| 109 | [tab.path, ...(tab.also ?? [])].some((path) => rest === path || rest.startsWith(`${path}/`)); | |
| 110 | return ( | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 111 | <nav aria-label="Views" className="relative -mb-px flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"> |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 112 | {tabs.map((tab) => ( |
| 113 | <NavLink | |
| 114 | key={tab.path} | |
| 115 | to={`${base}/${tab.path}`} | |
| 116 | title={tab.about} | |
| 117 | prefetch="intent" | |
| 118 | className={`flex shrink-0 items-center gap-1.5 border-b-2 px-3 pt-1 pb-2.5 text-sm transition-colors ${ | |
| 119 | current(tab) | |
| 120 | ? "border-accent font-medium text-fg" | |
| 121 | : tab.soon | |
| 122 | ? "border-transparent text-faint hover:text-muted" | |
| 123 | : "border-transparent text-muted hover:text-fg" | |
| 124 | }`} | |
| 125 | > | |
| 126 | {tab.label} | |
| Observability gets its own page; tabs never overflow | 127 | {/* Soon, said quietly: a dot, with the word for screen readers. */} |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 128 | {tab.soon && ( |
| Observability gets its own page; tabs never overflow | 129 | <> |
| 130 | <span aria-hidden="true" className="size-1.5 rounded-full bg-accent/70" /> | |
| 131 | <span className="sr-only">(soon)</span> | |
| 132 | </> | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 133 | )} |
| 134 | </NavLink> | |
| 135 | ))} | |
| 136 | </nav> | |
| 137 | ); | |
| 138 | } | |
| 139 | ||
| Projects: what a workspace builds and runs, first on every page | 140 | export default function ProjectLayout({ loaderData }: Route.ComponentProps) { |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 141 | const { repo, project, member } = loaderData; |
| Initial g1t: services, event bus, intents and attempts | 142 | const base = `/${repo.namespace}/${repo.name}`; |
| Projects: what a workspace builds and runs, first on every page | 143 | const description = project?.description ?? repo.description; |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 144 | const { pathname } = useLocation(); |
| 145 | const tabs = tabsFor(pathname.slice(base.length + 1), member); | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 146 | // Everyone, signed in or not, finds the project's pages in the sidebar; |
| 147 | // the page shows its name, and the views of the page it is on as tabs. | |
| Initial g1t: services, event bus, intents and attempts | 148 | return ( |
| API and MCP server, Rust identity service, registration, site redesign | 149 | <> |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 150 | <div className="border-b border-line"> |
| 151 | <div className={`mx-auto max-w-6xl px-4 sm:px-6 ${tabs ? "pt-3" : "py-3"}`}> | |
| Projects: what a workspace builds and runs, first on every page | 152 | <Header |
| 153 | project={project} | |
| 154 | isPrivate={repo.isPrivate} | |
| 155 | namespace={repo.namespace} | |
| 156 | name={repo.name} | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 157 | description={description} |
| Projects: what a workspace builds and runs, first on every page | 158 | /> |
| Search across all of g1t, Explore, and a command palette | 159 | <Topics topics={repo.topics} /> |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 160 | {tabs && ( |
| 161 | <div className="mt-3"> | |
| 162 | <PageTabs base={base} tabs={tabs} /> | |
| 163 | </div> | |
| 164 | )} | |
| API and MCP server, Rust identity service, registration, site redesign | 165 | </div> |
| 166 | </div> | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 167 | <div className="mx-auto max-w-6xl px-4 py-6 sm:px-6"> |
| API and MCP server, Rust identity service, registration, site redesign | 168 | <Outlet /> |
| 169 | </div> | |
| 170 | </> | |
| Initial g1t: services, event bus, intents and attempts | 171 | ); |
| 172 | } |