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