g1t/apps/web/app/root.tsx

332 lines11,016 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,
Workspaces own repositories3 Building2,
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)4 ChevronDown,
5 LayoutDashboard,
6 LogOut,
7 Plus,
8 Search,
9 Settings,
10} from "lucide-react";
11import {
Initial g1t: services, event bus, intents and attempts12 Form,
13 isRouteErrorResponse,
14 Link,
15 Links,
16 Meta,
API and MCP server, Rust identity service, registration, site redesign17 NavLink,
Initial g1t: services, event bus, intents and attempts18 Outlet,
19 Scripts,
20 ScrollRestoration,
21 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";
API and MCP server, Rust identity service, registration, site redesign30import { Avatar, ButtonLink } 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";
Initial g1t: services, event bus, intents and attempts39import { getViewer, viewerMiddleware } from "./lib/session.server";
40
41export const links: Route.LinksFunction = () => [
42 { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" },
43 { rel: "preconnect", href: "https://fonts.googleapis.com" },
44 {
45 rel: "preconnect",
46 href: "https://fonts.gstatic.com",
47 crossOrigin: "anonymous",
48 },
49 {
50 rel: "stylesheet",
API and MCP server, Rust identity service, registration, site redesign51 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 attempts52 },
53];
54
55export const middleware: Route.MiddlewareFunction[] = [viewerMiddleware];
56
57export function loader({ context }: Route.LoaderArgs) {
58 return { user: getViewer(context) };
59}
60
API and MCP server, Rust identity service, registration, site redesign61function HeaderLink({ to, children }: { to: string; children: React.ReactNode }) {
62 return (
63 <NavLink
64 to={to}
65 className={({ isActive }) =>
66 `rounded-md px-2.5 py-1.5 text-sm transition-colors hover:bg-raised hover:text-fg ${
67 isActive ? "text-fg" : "text-muted"
68 }`
69 }
70 >
71 {children}
72 </NavLink>
73 );
74}
75
Email verification, password reset, and Git for AI scale positioning76function Header({ user }: { user: User | null | undefined }) {
Acceptance checks in sandboxes, line comments and review verdicts77 const submit = useSubmit();
API and MCP server, Rust identity service, registration, site redesign78 return (
79 <header className="sticky top-0 z-40 border-b border-line bg-surface/85 backdrop-blur">
80 <div className="mx-auto flex h-14 max-w-6xl items-center gap-2 px-4">
81 <Link to="/" aria-label="g1t home" className="mr-2">
82 <Logo />
83 </Link>
84 <Form action="/search" role="search" className="relative hidden grow sm:block sm:max-w-xs">
85 <Search
86 size={14}
87 className="pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-faint"
88 />
89 <input
90 name="q"
91 placeholder="Search repositories"
92 aria-label="Search repositories"
93 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"
94 />
95 </Form>
96 <nav className="flex items-center gap-0.5">
97 <HeaderLink to="/explore">Explore</HeaderLink>
Docs as their own app; shared theme package98 <HeaderLink to="https://docs.g1t.sh/">Docs</HeaderLink>
API and MCP server, Rust identity service, registration, site redesign99 </nav>
100 <div className="ml-auto flex items-center gap-2">
101 {user ? (
102 <>
103 <Link
104 to="/new"
105 aria-label="New repository"
106 className="rounded-md border border-line p-1.5 text-muted transition-colors hover:border-line-strong hover:text-fg"
107 >
108 <Plus size={16} />
109 </Link>
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)110 <DropdownMenu>
111 <DropdownMenuTrigger
112 aria-label="Account menu"
113 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 redesign114 >
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)115 <Avatar name={user.username} size={24} />
116 <ChevronDown size={14} className="text-faint" />
117 </DropdownMenuTrigger>
118 <DropdownMenuContent align="end" className="w-56">
119 <DropdownMenuLabel>
120 Signed in as{" "}
121 <span className="font-mono font-medium text-fg">
122 {user.username}
123 </span>
124 </DropdownMenuLabel>
125 <DropdownMenuSeparator />
Workspaces own repositories126 {(user.workspaces ?? []).map((membership) => (
127 <DropdownMenuItem asChild key={membership.slug}>
128 <Link to={`/${membership.slug}`}>
129 <Building2 />
130 {membership.slug}
131 </Link>
132 </DropdownMenuItem>
133 ))}
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)134 <DropdownMenuItem asChild>
Workspaces own repositories135 <Link to="/workspaces/new">
136 <Plus />
137 New workspace
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)138 </Link>
139 </DropdownMenuItem>
Workspaces own repositories140 <DropdownMenuSeparator />
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)141 <DropdownMenuItem asChild>
142 <Link to="/">
143 <LayoutDashboard />
144 Mission control
145 </Link>
146 </DropdownMenuItem>
147 <DropdownMenuItem asChild>
148 <Link to="/new">
149 <Plus />
150 New repository
151 </Link>
152 </DropdownMenuItem>
153 <DropdownMenuSeparator />
154 <DropdownMenuItem asChild>
155 <Link to="/settings">
156 <Settings />
157 Settings
158 </Link>
159 </DropdownMenuItem>
160 <DropdownMenuItem asChild>
Docs as their own app; shared theme package161 <Link to="https://docs.g1t.sh/quickstart/">
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)162 <BookOpen />
163 Documentation
164 </Link>
165 </DropdownMenuItem>
166 <DropdownMenuSeparator />
Acceptance checks in sandboxes, line comments and review verdicts167 {/* Submitted from here: the menu closes on select, and a button
168 that has left the page cannot submit a form. */}
169 <DropdownMenuItem
170 onSelect={() => submit(null, { method: "post", action: "/logout" })}
171 >
172 <LogOut />
173 Sign out
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)174 </DropdownMenuItem>
175 </DropdownMenuContent>
176 </DropdownMenu>
API and MCP server, Rust identity service, registration, site redesign177 </>
178 ) : (
179 <>
180 <HeaderLink to="/login">Sign in</HeaderLink>
181 <ButtonLink to="/register">Sign up</ButtonLink>
182 </>
183 )}
184 </div>
185 </div>
186 </header>
187 );
188}
189
190const FOOTER_LINKS: { title: string; links: [string, string][] }[] = [
191 {
192 title: "Product",
193 links: [
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer194 ["Explore repositories", "/explore"],
Docs as their own app; shared theme package195 ["g1t agents", "https://docs.g1t.sh/guides/g1t-agents/"],
196 ["Bring your own agent", "https://docs.g1t.sh/guides/bring-your-own-agent/"],
API and MCP server, Rust identity service, registration, site redesign197 ["Sign up", "/register"],
198 ],
199 },
200 {
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer201 title: "Developers",
API and MCP server, Rust identity service, registration, site redesign202 links: [
Docs as their own app; shared theme package203 ["Quickstart", "https://docs.g1t.sh/quickstart/"],
204 ["Concepts", "https://docs.g1t.sh/concepts/overview/"],
205 ["API reference", "https://docs.g1t.sh/api/reference/"],
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer206 ["OpenAPI", "https://api.g1t.sh/openapi.json"],
207 ["llms.txt", "/llms.txt"],
API and MCP server, Rust identity service, registration, site redesign208 ],
209 },
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer210 {
211 title: "Project",
212 links: [
213 ["Source on g1t", "/syntaqx/g1t"],
214 ["Source on GitHub", "https://github.com/syntaqx/g1t"],
215 ["MIT license", "/syntaqx/g1t/blob/main/LICENSE"],
216 ],
217 },
API and MCP server, Rust identity service, registration, site redesign218];
219
220function Footer() {
221 return (
222 <footer className="mt-24 border-t border-line">
223 <div className="mx-auto flex max-w-6xl flex-wrap gap-x-20 gap-y-8 px-4 py-12">
224 <div className="grow">
225 <Logo />
226 <p className="mt-3 max-w-xs text-sm text-muted">
227 A git forge for agents. Open source under the MIT license, built on
228 Cloudflare Workers and Artifacts.
229 </p>
230 </div>
231 {FOOTER_LINKS.map((group) => (
232 <div key={group.title}>
233 <p className="text-sm font-medium">{group.title}</p>
234 <ul className="mt-3 space-y-2 text-sm text-muted">
235 {group.links.map(([label, to]) => (
236 <li key={to}>
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer237 {/* Plain links: some targets are files or other hosts. */}
238 <a href={to} className="hover:text-fg">
API and MCP server, Rust identity service, registration, site redesign239 {label}
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer240 </a>
API and MCP server, Rust identity service, registration, site redesign241 </li>
242 ))}
243 </ul>
244 </div>
245 ))}
246 </div>
docs.g1t.sh, generated OpenAPI with an interactive reference, full footer247 <div className="border-t border-line">
248 <p className="mx-auto max-w-6xl px-4 py-5 text-xs text-faint">
249 g1t is open source software, built on Cloudflare Workers and
250 Artifacts.
251 </p>
252 </div>
API and MCP server, Rust identity service, registration, site redesign253 </footer>
254 );
255}
256
Initial g1t: services, event bus, intents and attempts257export function Layout({ children }: { children: React.ReactNode }) {
258 // Undefined when the root loader itself failed.
259 const user = useRouteLoaderData<typeof loader>("root")?.user;
260 return (
261 <html lang="en">
262 <head>
263 <meta charSet="utf-8" />
264 <meta name="viewport" content="width=device-width, initial-scale=1" />
API and MCP server, Rust identity service, registration, site redesign265 <meta name="theme-color" content="#0e0d0a" />
Initial g1t: services, event bus, intents and attempts266 <Meta />
267 <Links />
268 </head>
API and MCP server, Rust identity service, registration, site redesign269 <body className="flex min-h-screen flex-col">
270 <Header user={user} />
Email verification, password reset, and Git for AI scale positioning271 {user && !user.verified && (
272 <Form
273 method="post"
274 action="/verify"
275 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"
276 >
277 <span>
278 Confirm your email address to create repositories and push. We
279 sent you a link.
280 </span>
281 <button type="submit" className="font-medium underline underline-offset-4">
282 Send it again
283 </button>
284 </Form>
285 )}
API and MCP server, Rust identity service, registration, site redesign286 <div className="grow">{children}</div>
287 <Footer />
Initial g1t: services, event bus, intents and attempts288 <ScrollRestoration />
289 <Scripts />
290 </body>
291 </html>
292 );
293}
294
295export default function App() {
296 return <Outlet />;
297}
298
299export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
API and MCP server, Rust identity service, registration, site redesign300 let title = "Something went wrong";
301 let details = "An unexpected error occurred. Try again in a moment.";
Initial g1t: services, event bus, intents and attempts302 let stack: string | undefined;
303
304 if (isRouteErrorResponse(error)) {
API and MCP server, Rust identity service, registration, site redesign305 if (error.status === 404) {
306 title = "Page not found";
307 details = "There is nothing at this address, or you do not have access to it.";
308 } else if (typeof error.data === "string" && error.data) {
309 details = error.data;
310 }
311 } else if (import.meta.env.DEV && error instanceof Error) {
Initial g1t: services, event bus, intents and attempts312 details = error.message;
313 stack = error.stack;
314 }
315
316 return (
API and MCP server, Rust identity service, registration, site redesign317 <main className="mx-auto max-w-xl px-4 py-32 text-center">
318 <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
319 <p className="mt-3 text-muted">{details}</p>
320 <div className="mt-8">
321 <ButtonLink to="/" variant="quiet">
322 Back to home
323 </ButtonLink>
324 </div>
Initial g1t: services, event bus, intents and attempts325 {stack && (
API and MCP server, Rust identity service, registration, site redesign326 <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 attempts327 <code>{stack}</code>
328 </pre>
329 )}
330 </main>
331 );
332}