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.
| Projects: what a workspace builds and runs, first on every page | 1 | import { Box, CircleDot, Code2, GitPullRequest, History, LayoutGrid, ListTree, Lock, Rocket, Settings } from "lucide-react"; |
| 2 | import { Link, Outlet, data, useRouteLoaderData } from "react-router"; | |
| 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"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 8 | import { Pill, TabLink as Tab } from "../../components/ui"; |
| Projects: what a workspace builds and runs, first on every page | 9 | import { projects, repos, work } from "../../lib/services.server"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 10 | import { getViewer, roleIn, unwrap } from "../../lib/session.server"; |
| Initial g1t: services, event bus, intents and attempts | 11 | |
| Social cards for every page: og.g1t.sh | 12 | export function meta({ loaderData: loaded, params, ...args }: Route.MetaArgs) { |
| 13 | return page(args, { title: `${loaded?.project?.name ?? params.repo} · ${params.owner} · g1t` }); | |
| Initial g1t: services, event bus, intents and attempts | 14 | } |
| 15 | ||
| 16 | export async function loader({ params, context }: Route.LoaderArgs) { | |
| 17 | const viewer = getViewer(context); | |
| 18 | const path = { namespace: params.owner, name: params.repo }; | |
| Projects: what a workspace builds and runs, first on every page | 19 | const [repo, counts, found] = await Promise.all([ |
| Rust repos service with shipping; pull requests kept in the model | 20 | repos.get(path, viewer), |
| Issues and pull requests replace intents and attempts | 21 | work.counts(path, viewer), |
| Projects: what a workspace builds and runs, first on every page | 22 | projects.get(params.owner, params.repo, viewer), |
| Initial g1t: services, event bus, intents and attempts | 23 | ]); |
| Projects: what a workspace builds and runs, first on every page | 24 | if (!repo.ok && !found.ok) throw data(null, { status: 404 }); |
| 25 | let project: Project | null = found.ok ? found.value : null; | |
| 26 | // A repository made a moment ago, before its project: make it now. | |
| 27 | if (!project && repo.ok && !repo.value.forkOf) { | |
| 28 | const own = await projects.byRepo(repo.value.id); | |
| 29 | project = own.find((p) => p.slug === params.repo.toLowerCase()) ?? own[0] ?? null; | |
| 30 | } | |
| Initial g1t: services, event bus, intents and attempts | 31 | return { |
| 32 | repo: unwrap(repo), | |
| Projects: what a workspace builds and runs, first on every page | 33 | project, |
| Issues and pull requests replace intents and attempts | 34 | open: counts.ok ? counts.value : { issues: 0, pulls: 0 }, |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 35 | member: roleIn(viewer, params.owner) != null, |
| Initial g1t: services, event bus, intents and attempts | 36 | }; |
| 37 | } | |
| 38 | ||
| Projects: what a workspace builds and runs, first on every page | 39 | /** The project the page is in, for the pages under it. */ |
| 40 | export function useProject() { | |
| 41 | return useRouteLoaderData<typeof loader>("routes/repo/layout"); | |
| 42 | } | |
| 43 | ||
| 44 | function Header({ project, isPrivate, namespace, name, description, large }: { | |
| 45 | project: Project | null; | |
| 46 | isPrivate: boolean; | |
| 47 | namespace: string; | |
| 48 | name: string; | |
| 49 | description: string | null; | |
| 50 | large?: boolean; | |
| 51 | }) { | |
| 52 | const base = `/${namespace}/${name}`; | |
| 53 | return ( | |
| 54 | <div className="flex flex-wrap items-center gap-x-3 gap-y-1"> | |
| 55 | <span | |
| 56 | className={`flex shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line ${large ? "size-8" : "size-6"}`} | |
| 57 | > | |
| 58 | {isPrivate ? <Lock size={large ? 15 : 13} /> : <Box size={large ? 15 : 13} />} | |
| 59 | </span> | |
| 60 | <h1 className={large ? "text-lg" : "text-[0.9375rem]"}> | |
| 61 | <Link to={`/${namespace}`} className="font-mono text-muted hover:text-fg"> | |
| 62 | {namespace} | |
| 63 | </Link> | |
| 64 | <span className="mx-1.5 text-faint">/</span> | |
| 65 | <Link to={base} className="font-semibold hover:underline"> | |
| 66 | {project?.name ?? name} | |
| 67 | </Link> | |
| 68 | </h1> | |
| 69 | <Pill>{isPrivate ? "private" : "public"}</Pill> | |
| 70 | {description && <p className="min-w-0 truncate text-sm text-muted">{description}</p>} | |
| 71 | </div> | |
| 72 | ); | |
| 73 | } | |
| 74 | ||
| 75 | export default function ProjectLayout({ loaderData }: Route.ComponentProps) { | |
| 76 | const { repo, project, open, member } = loaderData; | |
| Initial g1t: services, event bus, intents and attempts | 77 | const base = `/${repo.namespace}/${repo.name}`; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 78 | const signedIn = useRouteLoaderData("root")?.user != null; |
| Projects: what a workspace builds and runs, first on every page | 79 | const description = project?.description ?? repo.description; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 80 | if (signedIn) { |
| 81 | return ( | |
| 82 | <> | |
| 83 | <div className="border-b border-line"> | |
| Projects: what a workspace builds and runs, first on every page | 84 | <div className="mx-auto max-w-6xl px-4 py-3 sm:px-6"> |
| 85 | <Header | |
| 86 | project={project} | |
| 87 | isPrivate={repo.isPrivate} | |
| 88 | namespace={repo.namespace} | |
| 89 | name={repo.name} | |
| 90 | description={description} | |
| 91 | /> | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 92 | </div> |
| 93 | </div> | |
| 94 | <div className="mx-auto max-w-6xl px-4 py-6 sm:px-6"> | |
| 95 | <Outlet /> | |
| 96 | </div> | |
| 97 | </> | |
| 98 | ); | |
| 99 | } | |
| Initial g1t: services, event bus, intents and attempts | 100 | return ( |
| API and MCP server, Rust identity service, registration, site redesign | 101 | <> |
| Projects: what a workspace builds and runs, first on every page | 102 | {/* The project's own header band, under the site header. */} |
| API and MCP server, Rust identity service, registration, site redesign | 103 | <div className="border-b border-line bg-surface/60"> |
| 104 | <div className="mx-auto max-w-6xl px-4 pt-6"> | |
| Projects: what a workspace builds and runs, first on every page | 105 | <Header |
| 106 | project={project} | |
| 107 | isPrivate={repo.isPrivate} | |
| 108 | namespace={repo.namespace} | |
| 109 | name={repo.name} | |
| 110 | description={null} | |
| 111 | large | |
| 112 | /> | |
| 113 | {description && <p className="mt-2 max-w-2xl text-sm text-muted">{description}</p>} | |
| 114 | <nav className="mt-5 flex gap-6 overflow-x-auto"> | |
| 115 | <Tab to={base} end icon={<LayoutGrid size={15} />}> | |
| 116 | Overview | |
| 117 | </Tab> | |
| 118 | <Tab to={`${base}/code`} also={`${base}/tree`} icon={<Code2 size={15} />}> | |
| API and MCP server, Rust identity service, registration, site redesign | 119 | Code |
| 120 | </Tab> | |
| Issues and pull requests replace intents and attempts | 121 | <Tab to={`${base}/issues`} icon={<CircleDot size={15} />} count={open.issues}> |
| 122 | Issues | |
| 123 | </Tab> | |
| Projects: what a workspace builds and runs, first on every page | 124 | <Tab to={`${base}/pulls`} also={`${base}/pull`} icon={<GitPullRequest size={15} />} count={open.pulls}> |
| Issues and pull requests replace intents and attempts | 125 | Pull requests |
| API and MCP server, Rust identity service, registration, site redesign | 126 | </Tab> |
| 127 | <Tab to={`${base}/commits`} icon={<History size={15} />}> | |
| 128 | Commits | |
| 129 | </Tab> | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 130 | {member && ( |
| 131 | <Tab to={`${base}/plans`} icon={<ListTree size={15} />}> | |
| 132 | Plan | |
| 133 | </Tab> | |
| 134 | )} | |
| 135 | {member && ( | |
| Projects: what a workspace builds and runs, first on every page | 136 | <Tab to={`${base}/deployments`} icon={<Rocket size={15} />}> |
| 137 | Deployments | |
| 138 | </Tab> | |
| 139 | )} | |
| 140 | {member && ( | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 141 | <Tab to={`${base}/settings`} icon={<Settings size={15} />}> |
| 142 | Settings | |
| 143 | </Tab> | |
| 144 | )} | |
| API and MCP server, Rust identity service, registration, site redesign | 145 | </nav> |
| 146 | </div> | |
| 147 | </div> | |
| 148 | <div className="mx-auto max-w-6xl px-4 py-6"> | |
| 149 | <Outlet /> | |
| 150 | </div> | |
| 151 | </> | |
| Initial g1t: services, event bus, intents and attempts | 152 | ); |
| 153 | } |