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