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