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