flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/root.tsx

424 lines14,870 bytesCodeBlame

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.

Initial g1t: services, event bus, intents and attempts1import {
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)2 BookOpen,
3 ChevronDown,
4 LayoutDashboard,
5 LogOut,
6 Plus,
7 Search,
8 Settings,
9} from "lucide-react";
10import {
Initial g1t: services, event bus, intents and attempts11 Form,
12 isRouteErrorResponse,
13 Link,
14 Links,
15 Meta,
API and MCP server, Rust identity service, registration, site redesign16 NavLink,
Initial g1t: services, event bus, intents and attempts17 Outlet,
18 Scripts,
19 ScrollRestoration,
Agents as a team: lifecycle, merge queue, billing and a new shell20 type ShouldRevalidateFunctionArgs,
Initial g1t: services, event bus, intents and attempts21 useRouteLoaderData,
Acceptance checks in sandboxes, line comments and review verdicts22 useSubmit,
Initial g1t: services, event bus, intents and attempts23} from "react-router";
24
Email verification, password reset, and Git for AI scale positioning25import type { User } from "@g1t/contracts";
26
Initial g1t: services, event bus, intents and attempts27import type { Route } from "./+types/root";
28import "./app.css";
29import { Logo } from "./components/logo";
Agents as a team: lifecycle, merge queue, billing and a new shell30import { Avatar, ButtonLink, notACredential } from "./components/ui";
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)31import {
32 DropdownMenu,
33 DropdownMenuContent,
34 DropdownMenuItem,
35 DropdownMenuLabel,
36 DropdownMenuSeparator,
37 DropdownMenuTrigger,
38} from "./components/ui/dropdown-menu";
Agents as a team: lifecycle, merge queue, billing and a new shell39import { AppShell, Progress, type ShellData } from "./components/shell";
Projects: what a workspace builds and runs, first on every page40import { billing, projects, work } from "./lib/services.server";
Agents as a team: lifecycle, merge queue, billing and a new shell41import { getViewer, roleIn, viewerMiddleware } from "./lib/session.server";
Initial g1t: services, event bus, intents and attempts42
43export const links: Route.LinksFunction = () => [
The fleet: g1t's new mark44 { rel: "icon", href: "/favicon.ico", sizes: "32x32" },
Initial g1t: services, event bus, intents and attempts45 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
The fleet: g1t's new mark46 { rel: "icon", type: "image/png", sizes: "192x192", href: "/icon-192.png" },
47 { rel: "apple-touch-icon", href: "/apple-touch-icon.png" },
Initial g1t: services, event bus, intents and attempts48 { rel: "preconnect", href: "https://fonts.googleapis.com" },
49 {
50 rel: "preconnect",
51 href: "https://fonts.gstatic.com",
52 crossOrigin: "anonymous",
53 },
54 {
55 rel: "stylesheet",
API and MCP server, Rust identity service, registration, site redesign56 href: "https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&family=JetBrains+Mono:wght@400;500;600&display=swap",
Initial g1t: services, event bus, intents and attempts57 },
58];
59
60export const middleware: Route.MiddlewareFunction[] = [viewerMiddleware];
61
Agents as a team: lifecycle, merge queue, billing and a new shell62export async function loader({ context, params }: Route.LoaderArgs) {
63 const user = getViewer(context);
64 return { user, shell: user ? await shellFor(user, params) : null };
Initial g1t: services, event bus, intents and attempts65}
66
Agents as a team: lifecycle, merge queue, billing and a new shell67/**
68 * The sidebar only changes with the workspace or repository being looked
69 * at, or after something was submitted: not on every page within them.
70 */
71export function shouldRevalidate({
72 currentParams,
73 nextParams,
74 formMethod,
75 defaultShouldRevalidate,
76}: ShouldRevalidateFunctionArgs) {
77 if (formMethod && formMethod !== "GET") return defaultShouldRevalidate;
78 return currentParams.owner !== nextParams.owner || currentParams.repo !== nextParams.repo;
79}
80
81/**
82 * The sidebar: the workspace being looked at if they belong to it, else
83 * their first; its repositories; and the repository being looked at.
84 */
85async function shellFor(
86 user: User,
87 params: { owner?: string; repo?: string },
88): Promise<ShellData> {
89 const memberships = user.workspaces ?? [];
90 const here = params.owner ? memberships.find((m) => m.slug === params.owner?.toLowerCase()) : undefined;
91 const workspace = here ?? memberships[0] ?? null;
92 const path = params.owner && params.repo ? { namespace: params.owner, name: params.repo } : null;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request93 const now = new Date();
94 const monthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)).toISOString();
Billing accounts, terms and enterprises; g1t is no longer free95 const [listed, counts, account, usage, limit] = await Promise.all([
Projects: what a workspace builds and runs, first on every page96 workspace ? projects.list(workspace.slug, user) : Promise.resolve(null),
Agents as a team: lifecycle, merge queue, billing and a new shell97 path ? work.counts(path, user) : Promise.resolve(null),
98 workspace ? billing.account(workspace.slug, user) : Promise.resolve(null),
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request99 workspace ? billing.usage(workspace.slug, user, monthStart) : Promise.resolve(null),
Billing accounts, terms and enterprises; g1t is no longer free100 workspace ? billing.limit(workspace.slug, user).catch(() => null) : Promise.resolve(null),
Agents as a team: lifecycle, merge queue, billing and a new shell101 ]);
102 return {
103 workspace,
Projects: what a workspace builds and runs, first on every page104 // Projects are what the sidebar lists: what the workspace builds and runs.
105 repos: listed?.ok
106 ? listed.value.map((project) => ({
107 namespace: project.workspace,
108 name: project.slug,
109 title: project.name,
110 isPrivate: project.private,
111 }))
112 : [],
Agents as a team: lifecycle, merge queue, billing and a new shell113 repo:
114 path && counts?.ok
115 ? {
116 ...path,
117 member: roleIn(user, path.namespace) != null,
118 issues: counts.value.issues,
119 pulls: counts.value.pulls,
120 }
121 : null,
Billing accounts, terms and enterprises; g1t is no longer free122 // Where the workspace stands against its usage limit, once billing is on.
123 limit:
124 account?.ok && account.value.status.enabled && limit?.ok
125 ? {
126 exposureMicros: limit.value.exposureMicros,
127 ceilingMicros: limit.value.ceilingMicros,
128 state: limit.value.state,
129 comped: limit.value.trust === "internal",
130 }
131 : null,
Free while g1t is being built out; agents can check out their own forks132 free: account?.ok ? Boolean(account.value.status.free) : false,
Usage while free is shown at cost; agents get rustfmt and clippy133 // While g1t is free every charge is zero, so usage is shown at cost.
134 monthUsageMicros: usage?.ok ? (usage.value.free ? usage.value.usedMicros : usage.value.spentMicros) : null,
Agents as a team: lifecycle, merge queue, billing and a new shell135 };
136}
137
API and MCP server, Rust identity service, registration, site redesign138function HeaderLink({ to, children }: { to: string; children: React.ReactNode }) {
139 return (
140 <NavLink
141 to={to}
142 className={({ isActive }) =>
143 `rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-raised hover:text-fg ${
144 isActive ? "text-fg" : "text-muted"
145 }`
146 }
147 >
148 {children}
149 </NavLink>
150 );
151}
152
Email verification, password reset, and Git for AI scale positioning153function Header({ user }: { user: User | null | undefined }) {
Acceptance checks in sandboxes, line comments and review verdicts154 const submit = useSubmit();
API and MCP server, Rust identity service, registration, site redesign155 return (
156 <header className="sticky top-0 z-40 border-b border-line bg-surface/85 backdrop-blur">
157 <div className="mx-auto flex h-14 max-w-6xl items-center gap-2 px-4">
158 <Link to="/" aria-label="g1t home" className="mr-2">
159 <Logo />
160 </Link>
161 <Form action="/search" role="search" className="relative hidden grow sm:block sm:max-w-xs">
162 <Search
163 size={14}
164 className="pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-faint"
165 />
166 <input
167 name="q"
Agents as a team: lifecycle, merge queue, billing and a new shell168 {...notACredential()}
API and MCP server, Rust identity service, registration, site redesign169 placeholder="Search repositories"
170 aria-label="Search repositories"
171 className="w-full rounded-md border border-line bg-bg py-1.5 pr-3 pl-8 text-sm outline-none transition-colors placeholder:text-faint hover:border-line-strong focus:border-accent-dim"
172 />
173 </Form>
174 <nav className="flex items-center gap-0.5">
175 <HeaderLink to="/explore">Explore</HeaderLink>
Prices keep themselves current with what g1t pays176 <HeaderLink to="/pricing">Pricing</HeaderLink>
Docs as their own app; shared theme package177 <HeaderLink to="https://docs.g1t.sh/">Docs</HeaderLink>
API and MCP server, Rust identity service, registration, site redesign178 </nav>
179 <div className="ml-auto flex items-center gap-2">
180 {user ? (
181 <>
182 <Link
183 to="/new"
Projects live: fixes from walking them end to end184 aria-label="New project"
API and MCP server, Rust identity service, registration, site redesign185 className="rounded-md border border-line p-1.5 text-muted transition-colors hover:border-line-strong hover:text-fg"
186 >
187 <Plus size={16} />
188 </Link>
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)189 <DropdownMenu>
190 <DropdownMenuTrigger
191 aria-label="Account menu"
192 className="flex items-center gap-1.5 rounded-md p-1 outline-none transition-colors hover:bg-raised data-[state=open]:bg-raised"
API and MCP server, Rust identity service, registration, site redesign193 >
Workspace names and icons, and a component kit for every control194 <Avatar name={user.username} image={user.avatar} size={24} />
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)195 <ChevronDown size={14} className="text-faint" />
196 </DropdownMenuTrigger>
197 <DropdownMenuContent align="end" className="w-56">
198 <DropdownMenuLabel>
199 Signed in as{" "}
200 <span className="font-mono font-medium text-fg">
201 {user.username}
202 </span>
203 </DropdownMenuLabel>
204 <DropdownMenuSeparator />
Workspaces own repositories205 {(user.workspaces ?? []).map((membership) => (
206 <DropdownMenuItem asChild key={membership.slug}>
207 <Link to={`/${membership.slug}`}>
Workspace names and icons, and a component kit for every control208 <Avatar name={membership.slug} image={membership.avatar} size={16} square />
209 <span className="min-w-0 truncate">{membership.name || membership.slug}</span>
Workspaces own repositories210 </Link>
211 </DropdownMenuItem>
212 ))}
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)213 <DropdownMenuItem asChild>
Workspaces own repositories214 <Link to="/workspaces/new">
215 <Plus />
216 New workspace
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)217 </Link>
218 </DropdownMenuItem>
Workspaces own repositories219 <DropdownMenuSeparator />
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)220 <DropdownMenuItem asChild>
221 <Link to="/">
222 <LayoutDashboard />
223 Mission control
224 </Link>
225 </DropdownMenuItem>
226 <DropdownMenuItem asChild>
227 <Link to="/new">
228 <Plus />
Projects live: fixes from walking them end to end229 New project
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)230 </Link>
231 </DropdownMenuItem>
232 <DropdownMenuSeparator />
233 <DropdownMenuItem asChild>
234 <Link to="/settings">
235 <Settings />
236 Settings
237 </Link>
238 </DropdownMenuItem>
239 <DropdownMenuItem asChild>
Docs as their own app; shared theme package240 <Link to="https://docs.g1t.sh/quickstart/">
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)241 <BookOpen />
242 Documentation
243 </Link>
244 </DropdownMenuItem>
245 <DropdownMenuSeparator />
Acceptance checks in sandboxes, line comments and review verdicts246 {/* Submitted from here: the menu closes on select, and a button
247 that has left the page cannot submit a form. */}
248 <DropdownMenuItem
249 onSelect={() => submit(null, { method: "post", action: "/logout" })}
250 >
251 <LogOut />
252 Sign out
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)253 </DropdownMenuItem>
254 </DropdownMenuContent>
255 </DropdownMenu>
API and MCP server, Rust identity service, registration, site redesign256 </>
257 ) : (
258 <>
259 <HeaderLink to="/login">Sign in</HeaderLink>
260 <ButtonLink to="/register">Sign up</ButtonLink>
261 </>
262 )}
263 </div>
264 </div>
265 </header>
266 );
267}
268
269const FOOTER_LINKS: { title: string; links: [string, string][] }[] = [
270 {
271 title: "Product",
272 links: [
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer273 ["Explore repositories", "/explore"],
Prices keep themselves current with what g1t pays274 ["Pricing", "/pricing"],
Docs as their own app; shared theme package275 ["g1t agents", "https://docs.g1t.sh/guides/g1t-agents/"],
276 ["Bring your own agent", "https://docs.g1t.sh/guides/bring-your-own-agent/"],
Polish: phones, copy boxes, the plan page, the landing page, a real glide277 ["Integrations", "https://docs.g1t.sh/guides/integrations/"],
278 ["Model providers", "https://docs.g1t.sh/guides/models/"],
API and MCP server, Rust identity service, registration, site redesign279 ["Sign up", "/register"],
280 ],
281 },
282 {
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer283 title: "Developers",
API and MCP server, Rust identity service, registration, site redesign284 links: [
Docs as their own app; shared theme package285 ["Quickstart", "https://docs.g1t.sh/quickstart/"],
Polish: phones, copy boxes, the plan page, the landing page, a real glide286 ["How g1t works", "https://docs.g1t.sh/concepts/overview/"],
Merge branch 'worktree-agent-ab2e39e11a6493412'287 ["API reference", "https://docs.g1t.sh/reference/api/"],
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer288 ["OpenAPI", "https://api.g1t.sh/openapi.json"],
289 ["llms.txt", "/llms.txt"],
API and MCP server, Rust identity service, registration, site redesign290 ],
291 },
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer292 {
293 title: "Project",
294 links: [
295 ["Source on g1t", "/syntaqx/g1t"],
296 ["MIT license", "/syntaqx/g1t/blob/main/LICENSE"],
297 ],
298 },
API and MCP server, Rust identity service, registration, site redesign299];
300
301function Footer() {
302 return (
303 <footer className="mt-24 border-t border-line">
304 <div className="mx-auto flex max-w-6xl flex-wrap gap-x-20 gap-y-8 px-4 py-12">
305 <div className="grow">
306 <Logo />
307 <p className="mt-3 max-w-xs text-sm text-muted">
308 A git forge for agents. Open source under the MIT license, built on
309 Cloudflare Workers and Artifacts.
310 </p>
311 </div>
312 {FOOTER_LINKS.map((group) => (
313 <div key={group.title}>
314 <p className="text-sm font-medium">{group.title}</p>
315 <ul className="mt-3 space-y-2 text-sm text-muted">
316 {group.links.map(([label, to]) => (
317 <li key={to}>
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer318 {/* Plain links: some targets are files or other hosts. */}
319 <a href={to} className="hover:text-fg">
API and MCP server, Rust identity service, registration, site redesign320 {label}
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer321 </a>
API and MCP server, Rust identity service, registration, site redesign322 </li>
323 ))}
324 </ul>
325 </div>
326 ))}
327 </div>
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer328 <div className="border-t border-line">
329 <p className="mx-auto max-w-6xl px-4 py-5 text-xs text-faint">
330 g1t is open source software, built on Cloudflare Workers and
331 Artifacts.
332 </p>
333 </div>
API and MCP server, Rust identity service, registration, site redesign334 </footer>
335 );
336}
337
Initial g1t: services, event bus, intents and attempts338export function Layout({ children }: { children: React.ReactNode }) {
339 // Undefined when the root loader itself failed.
Agents as a team: lifecycle, merge queue, billing and a new shell340 const root = useRouteLoaderData<typeof loader>("root");
341 const user = root?.user;
342 const banner = user && !user.verified && (
343 <Form
344 method="post"
345 action="/verify"
346 className="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 border-b border-warn/30 bg-warn/10 px-4 py-2 text-sm"
347 >
348 <span>
349 Confirm your email address to create repositories and push. We
350 sent you a link.
351 </span>
352 <button type="submit" className="font-medium underline underline-offset-4">
353 Send it again
354 </button>
355 </Form>
356 );
Initial g1t: services, event bus, intents and attempts357 return (
358 <html lang="en">
359 <head>
360 <meta charSet="utf-8" />
361 <meta name="viewport" content="width=device-width, initial-scale=1" />
Dark gray base with lavender as an accent, and a live outcome view for plans362 <meta name="theme-color" content="#0f0f11" />
Initial g1t: services, event bus, intents and attempts363 <Meta />
364 <Links />
365 </head>
API and MCP server, Rust identity service, registration, site redesign366 <body className="flex min-h-screen flex-col">
Agents as a team: lifecycle, merge queue, billing and a new shell367 {user && root?.shell ? (
368 <AppShell user={user} shell={root.shell} banner={banner}>
369 {children}
370 </AppShell>
371 ) : (
372 <>
373 <Progress />
374 <Header user={user} />
375 {banner}
376 <div className="grow">{children}</div>
377 <Footer />
378 </>
Email verification, password reset, and Git for AI scale positioning379 )}
Initial g1t: services, event bus, intents and attempts380 <ScrollRestoration />
381 <Scripts />
382 </body>
383 </html>
384 );
385}
386
387export default function App() {
388 return <Outlet />;
389}
390
391export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
API and MCP server, Rust identity service, registration, site redesign392 let title = "Something went wrong";
393 let details = "An unexpected error occurred. Try again in a moment.";
Initial g1t: services, event bus, intents and attempts394 let stack: string | undefined;
395
396 if (isRouteErrorResponse(error)) {
API and MCP server, Rust identity service, registration, site redesign397 if (error.status === 404) {
398 title = "Page not found";
399 details = "There is nothing at this address, or you do not have access to it.";
400 } else if (typeof error.data === "string" && error.data) {
401 details = error.data;
402 }
403 } else if (import.meta.env.DEV && error instanceof Error) {
Initial g1t: services, event bus, intents and attempts404 details = error.message;
405 stack = error.stack;
406 }
407
408 return (
API and MCP server, Rust identity service, registration, site redesign409 <main className="mx-auto max-w-xl px-4 py-32 text-center">
410 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
411 <p className="mt-3 text-muted">{details}</p>
412 <div className="mt-8">
413 <ButtonLink to="/" variant="quiet">
414 Back to home
415 </ButtonLink>
416 </div>
Initial g1t: services, event bus, intents and attempts417 {stack && (
API and MCP server, Rust identity service, registration, site redesign418 <pre className="mt-8 overflow-x-auto rounded-lg border border-line p-4 text-left text-xs">
Initial g1t: services, event bus, intents and attempts419 <code>{stack}</code>
420 </pre>
421 )}
422 </main>
423 );
424}

This file's history is long; its oldest lines are credited to the oldest commit read.