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.
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 1 | import { waitUntil } from "cloudflare:workers"; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 2 | import { Box, Lock } from "lucide-react"; |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 3 | import type { ReactNode } from "react"; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 4 | import { Link, NavLink, Outlet, type ShouldRevalidateFunctionArgs, data, useLocation, useRouteLoaderData } from "react-router"; |
| Projects: what a workspace builds and runs, first on every page | 5 | |
| 6 | import type { Project } from "@g1t/contracts"; | |
| Initial g1t: services, event bus, intents and attempts | 7 | |
| 8 | import type { Route } from "./+types/layout"; | |
| Topics sit in About on the files pages, under the description | 9 | import { Topics } from "../../components/topics"; |
| Social cards for every page: og.g1t.sh | 10 | import { page } from "../../lib/meta"; |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 11 | 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 | 12 | import { Pill } from "../../components/ui"; |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 13 | import { WatchMenu } from "../../components/notifications"; |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 14 | import { PinButton } from "../../components/pin-button"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 15 | import { ArchivedBanner } from "../../components/repo-lifecycle"; |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 16 | import { WelcomeBanner } from "../../components/welcome"; |
| 17 | import { clearWelcome, welcomes } from "../../lib/invites"; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 18 | import { notFound } from "../../lib/not-found.server"; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 19 | import { redirectIfRenamed, redirectIfTransferred } from "../../lib/renamed.server"; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 20 | import { accessFor, countsFor, repoFor } from "../../lib/access.server"; |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 21 | import { inbox, projects } from "../../lib/services.server"; |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 22 | import { getViewer, roleIn, unwrap } from "../../lib/session.server"; |
| Initial g1t: services, event bus, intents and attempts | 23 | |
| Social cards for every page: og.g1t.sh | 24 | export function meta({ loaderData: loaded, params, ...args }: Route.MetaArgs) { |
| 25 | return page(args, { title: `${loaded?.project?.name ?? params.repo} · ${params.owner} · g1t` }); | |
| Initial g1t: services, event bus, intents and attempts | 26 | } |
| 27 | ||
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 28 | export async function loader({ params, context, request }: Route.LoaderArgs) { |
| Initial g1t: services, event bus, intents and attempts | 29 | const viewer = getViewer(context); |
| 30 | const path = { namespace: params.owner, name: params.repo }; | |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 31 | // Members pin the workspace's projects, and what they open is their Recent. |
| 32 | const member = viewer ? roleIn(viewer, params.owner) != null : false; | |
| 33 | const [repo, counts, found, watching, shortcuts] = await Promise.all([ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 34 | repoFor(context, params), |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 35 | countsFor(context, params), |
| Projects: what a workspace builds and runs, first on every page | 36 | projects.get(params.owner, params.repo, viewer), |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 37 | // How the person watches it, for the header's Watch menu, as soon as |
| 38 | // the repository is known. | |
| 39 | viewer | |
| 40 | ? repoFor(context, params).then((found) => (found.ok ? inbox.watching(viewer.username, found.value.id).catch(() => null) : null)) | |
| 41 | : null, | |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 42 | // Whether they pinned it, for the header's Pin button. |
| 43 | member ? projects.shortcuts(params.owner, viewer).catch(() => null) : null, | |
| Initial g1t: services, event bus, intents and attempts | 44 | ]); |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 45 | if (!repo.ok && !found.ok) { |
| 46 | // Under a workspace's old name, after a rename: the project is at the new one. | |
| 47 | await redirectIfRenamed(request, params.owner); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 48 | // A repository transferred to another workspace: it is there now. |
| 49 | await redirectIfTransferred(request, params.owner, params.repo, viewer); | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 50 | throw notFound("project"); |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 51 | } |
| Projects: what a workspace builds and runs, first on every page | 52 | let project: Project | null = found.ok ? found.value : null; |
| 53 | // A repository made a moment ago, before its project: make it now. | |
| 54 | if (!project && repo.ok && !repo.value.forkOf) { | |
| 55 | const own = await projects.byRepo(repo.value.id); | |
| 56 | project = own.find((p) => p.slug === params.repo.toLowerCase()) ?? own[0] ?? null; | |
| 57 | } | |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 58 | // Opened just now: it leads their Recent, recorded after the page is sent. |
| 59 | if (member && project) waitUntil(projects.visited(viewer!, project.id).catch(() => undefined)); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 60 | const value = unwrap(repo); |
| 61 | // The viewer's role on the repository and what it lets them do, for the | |
| 62 | // pages under it and the sidebar. | |
| 63 | const access = accessFor(viewer, value); | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 64 | // Just given access with an invite: welcomed once (routes/invite.tsx). |
| 65 | const welcome = Boolean(access.role) && welcomes(request.headers.get("cookie"), `${value.namespace}/${value.name}`); | |
| 66 | const headers = welcome ? { "Set-Cookie": clearWelcome(new URL(request.url).protocol === "https:") } : undefined; | |
| 67 | return data({ | |
| 68 | welcome, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 69 | repo: value, |
| Projects: what a workspace builds and runs, first on every page | 70 | project, |
| Issues and pull requests replace intents and attempts | 71 | open: counts.ok ? counts.value : { issues: 0, pulls: 0 }, |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 72 | access, |
| 73 | member: access.insider, | |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 74 | watching, |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 75 | // Null when they cannot pin it: not one of their workspaces. |
| 76 | pinned: member && project ? (shortcuts?.pinned ?? []).some((pinned) => pinned.id === project.id) : null, | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 77 | }, { headers }); |
| Initial g1t: services, event bus, intents and attempts | 78 | } |
| 79 | ||
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 80 | /** |
| 81 | * The project's header, tabs and the viewer's role change with the project | |
| 82 | * or after something was submitted, not from one page of it to the next, | |
| 83 | * nor when a page refreshes itself. | |
| 84 | */ | |
| 85 | export function shouldRevalidate({ currentParams, nextParams, formMethod, defaultShouldRevalidate }: ShouldRevalidateFunctionArgs) { | |
| 86 | if (formMethod && formMethod !== "GET") return defaultShouldRevalidate; | |
| 87 | return currentParams.owner !== nextParams.owner || currentParams.repo !== nextParams.repo; | |
| 88 | } | |
| 89 | ||
| Projects: what a workspace builds and runs, first on every page | 90 | /** The project the page is in, for the pages under it. */ |
| 91 | export function useProject() { | |
| 92 | return useRouteLoaderData<typeof loader>("routes/repo/layout"); | |
| 93 | } | |
| 94 | ||
| Search across all of g1t, Explore, and a command palette | 95 | /** A repository's topics, each a way into Explore. */ |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 96 | function Header({ project, isPrivate, archived, namespace, name, description, large, actions }: { |
| Projects: what a workspace builds and runs, first on every page | 97 | project: Project | null; |
| 98 | isPrivate: boolean; | |
| 99 | namespace: string; | |
| 100 | name: string; | |
| 101 | description: string | null; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 102 | archived?: boolean; |
| Projects: what a workspace builds and runs, first on every page | 103 | large?: boolean; |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 104 | /** At the end of the row: the Watch menu. */ |
| 105 | actions?: ReactNode; | |
| Projects: what a workspace builds and runs, first on every page | 106 | }) { |
| 107 | const base = `/${namespace}/${name}`; | |
| 108 | return ( | |
| 109 | <div className="flex flex-wrap items-center gap-x-3 gap-y-1"> | |
| 110 | <span | |
| 111 | className={`flex shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line ${large ? "size-8" : "size-6"}`} | |
| 112 | > | |
| 113 | {isPrivate ? <Lock size={large ? 15 : 13} /> : <Box size={large ? 15 : 13} />} | |
| 114 | </span> | |
| 115 | <h1 className={large ? "text-lg" : "text-[0.9375rem]"}> | |
| 116 | <Link to={`/${namespace}`} className="font-mono text-muted hover:text-fg"> | |
| 117 | {namespace} | |
| 118 | </Link> | |
| 119 | <span className="mx-1.5 text-faint">/</span> | |
| 120 | <Link to={base} className="font-semibold hover:underline"> | |
| 121 | {project?.name ?? name} | |
| 122 | </Link> | |
| 123 | </h1> | |
| 124 | <Pill>{isPrivate ? "private" : "public"}</Pill> | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 125 | {archived && <Pill>archived</Pill>} |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 126 | {/* On a phone, on its own line under the name and the Watch menu. */} |
| 127 | {description && <p className="order-last min-w-0 basis-full truncate text-sm text-muted sm:order-none sm:basis-0 sm:flex-1">{description}</p>} | |
| 128 | {actions && <div className="ml-auto flex shrink-0 items-center gap-2">{actions}</div>} | |
| Projects: what a workspace builds and runs, first on every page | 129 | </div> |
| 130 | ); | |
| 131 | } | |
| 132 | ||
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 133 | /** |
| 134 | * The views of the page the project is on, as tabs across its top: Files, | |
| 135 | * Commits and what is coming under Code, and so on. Soon tabs open their | |
| 136 | * roadmap page, under the same tabs. | |
| 137 | */ | |
| 138 | function PageTabs({ base, tabs }: { base: string; tabs: PageTab[] }) { | |
| 139 | const { pathname } = useLocation(); | |
| 140 | const rest = pathname.slice(base.length + 1); | |
| 141 | const current = (tab: PageTab) => | |
| 142 | [tab.path, ...(tab.also ?? [])].some((path) => rest === path || rest.startsWith(`${path}/`)); | |
| 143 | return ( | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 144 | <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 | 145 | {tabs.map((tab) => ( |
| 146 | <NavLink | |
| 147 | key={tab.path} | |
| 148 | to={`${base}/${tab.path}`} | |
| 149 | title={tab.about} | |
| 150 | prefetch="intent" | |
| 151 | className={`flex shrink-0 items-center gap-1.5 border-b-2 px-3 pt-1 pb-2.5 text-sm transition-colors ${ | |
| 152 | current(tab) | |
| 153 | ? "border-accent font-medium text-fg" | |
| 154 | : tab.soon | |
| 155 | ? "border-transparent text-faint hover:text-muted" | |
| 156 | : "border-transparent text-muted hover:text-fg" | |
| 157 | }`} | |
| 158 | > | |
| 159 | {tab.label} | |
| Observability gets its own page; tabs never overflow | 160 | {/* 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 | 161 | {tab.soon && ( |
| Observability gets its own page; tabs never overflow | 162 | <> |
| 163 | <span aria-hidden="true" className="size-1.5 rounded-full bg-accent/70" /> | |
| 164 | <span className="sr-only">(soon)</span> | |
| 165 | </> | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 166 | )} |
| 167 | </NavLink> | |
| 168 | ))} | |
| 169 | </nav> | |
| 170 | ); | |
| 171 | } | |
| 172 | ||
| Projects: what a workspace builds and runs, first on every page | 173 | export default function ProjectLayout({ loaderData }: Route.ComponentProps) { |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 174 | const { repo, project, member, access, welcome, watching, pinned } = loaderData; |
| Initial g1t: services, event bus, intents and attempts | 175 | const base = `/${repo.namespace}/${repo.name}`; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 176 | // The project's own description, else the repository's as it is now. |
| 177 | const description = (project && !project.descriptionInherited ? project.description : null) ?? repo.description; | |
| A flat project menu with Code first, views as tabs, and Stripe for every owner | 178 | const { pathname } = useLocation(); |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 179 | const tabs = tabsFor(pathname.slice(base.length + 1), member, access.can); |
| Topics sit in About on the files pages, under the description | 180 | // The files' own About says what it is and its topics, as the one place. |
| Compare: any two branches, the commits one has that the other does not, and the diff, with Open a pull request | 181 | const filesPage = /^(code|tree|blob|commits?|branches|tags|compare)(\/|$)/.test(pathname.slice(base.length + 1)); |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 182 | // Everyone, signed in or not, finds the project's pages in the sidebar; |
| 183 | // the page shows its name, and the views of the page it is on as tabs. | |
| Initial g1t: services, event bus, intents and attempts | 184 | return ( |
| API and MCP server, Rust identity service, registration, site redesign | 185 | <> |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 186 | <div className="border-b border-line"> |
| 187 | <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 | 188 | <Header |
| 189 | project={project} | |
| 190 | isPrivate={repo.isPrivate} | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 191 | archived={Boolean(repo.archivedAt)} |
| Projects: what a workspace builds and runs, first on every page | 192 | namespace={repo.namespace} |
| 193 | name={repo.name} | |
| Files pages say Files in the trail and keep the description in About only | 194 | // The files' own About says it there, as the one place. |
| Topics sit in About on the files pages, under the description | 195 | description={filesPage ? null : description} |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 196 | actions={ |
| Navigation: the workspace's own page with tabs, pins and recent in the sidebar | 197 | watching || (project && pinned != null) ? ( |
| 198 | <> | |
| 199 | {project && pinned != null && ( | |
| 200 | <PinButton workspace={project.workspace} slug={project.slug} name={project.name} pinned={pinned} /> | |
| 201 | )} | |
| 202 | {watching && <WatchMenu action={`${base}/notifications`} level={watching.level} events={watching.events} />} | |
| 203 | </> | |
| Inbox on the site: reasons, a reason filter, Subscribe, Watch and settings | 204 | ) : null |
| 205 | } | |
| Projects: what a workspace builds and runs, first on every page | 206 | /> |
| Topics sit in About on the files pages, under the description | 207 | {/* On the files' pages, About shows them. */} |
| 208 | {!filesPage && <Topics topics={repo.topics} />} | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 209 | {tabs && ( |
| 210 | <div className="mt-3"> | |
| 211 | <PageTabs base={base} tabs={tabs} /> | |
| 212 | </div> | |
| 213 | )} | |
| API and MCP server, Rust identity service, registration, site redesign | 214 | </div> |
| 215 | </div> | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 216 | <div className="mx-auto max-w-6xl px-4 py-6 sm:px-6"> |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 217 | {welcome && ( |
| 218 | <div className="mb-6"> | |
| 219 | <WelcomeBanner title={`You're in ${repo.namespace}/${repo.name}`}> | |
| 220 | You have the {access.role} role on it now. Its code, issues and pull requests are yours to work on. | |
| 221 | </WelcomeBanner> | |
| 222 | </div> | |
| 223 | )} | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 224 | {repo.archivedAt && ( |
| 225 | <div className="mb-6"> | |
| 226 | <ArchivedBanner base={base} owner={access.can.administer} settings={/^settings(\/|$)/.test(pathname.slice(base.length + 1))} /> | |
| 227 | </div> | |
| 228 | )} | |
| API and MCP server, Rust identity service, registration, site redesign | 229 | <Outlet /> |
| 230 | </div> | |
| 231 | </> | |
| Initial g1t: services, event bus, intents and attempts | 232 | ); |
| 233 | } |