g1t/apps/web/app/components/shell.tsx

1,252 lines50,433 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.

Agents as a team: lifecycle, merge queue, billing and a new shell1import {
A catalogue of model providers, and settings that feel like settings2 ArrowLeft,
The project menu opens by section, and the workspace has its own panel3 ChevronRight,
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request4 BarChart3,
Agents as a team: lifecycle, merge queue, billing and a new shell5 BookMarked,
6 BookOpen,
7 Check,
8 ChevronsUpDown,
A Vercel-like sidebar and a new mark9 Ellipsis,
Agents as a team: lifecycle, merge queue, billing and a new shell10 CircleDot,
11 Code2,
12 Compass,
13 CornerDownLeft,
14 CreditCard,
15 GitPullRequest,
16 History,
Secrets and variables: one list, rows per environment, for workflows and deployments17 Fingerprint,
Agents as a team: lifecycle, merge queue, billing and a new shell18 KeyRound,
Projects: what a workspace builds and runs, first on every page19 Box,
Agents as a team: lifecycle, merge queue, billing and a new shell20 LayoutDashboard,
Projects: what a workspace builds and runs, first on every page21 LayoutGrid,
Agents as a team: lifecycle, merge queue, billing and a new shell22 ListTree,
23 Lock,
24 LogOut,
25 Menu,
26 Plus,
27 Search,
Integrations: your own model provider, alerts that open issues, tickets agents read28 Plug,
Agents as a team: lifecycle, merge queue, billing and a new shell29 Settings,
30 Users,
Webhooks: every event, to your own addresses, signed and retried31 Webhook,
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs32 PlayCircle,
Pull requests say where they are live; the project menu shows what is coming33 Activity,
34 Bot,
35 Kanban,
36 ShieldCheck,
Deployments: a preview for every pull request, production on g1t.page37 Rocket,
Agents as a team: lifecycle, merge queue, billing and a new shell38 X,
39} from "lucide-react";
40import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
41import { Form, Link, NavLink, useLocation, useNavigate, useNavigation, useSubmit } from "react-router";
42
43import type { User } from "@g1t/contracts";
44import { MICROS_PER_DOLLAR } from "@g1t/contracts";
45
A Vercel-like sidebar and a new mark46import { Mark } from "./logo";
Agents as a team: lifecycle, merge queue, billing and a new shell47import { Avatar } from "./ui";
48import {
49 DropdownMenu,
50 DropdownMenuContent,
51 DropdownMenuItem,
52 DropdownMenuLabel,
53 DropdownMenuSeparator,
54 DropdownMenuTrigger,
55} from "./ui/dropdown-menu";
56
57/** What the sidebar needs, worked out by the root loader for a signed-in person. */
58export type ShellData = {
59 /** The workspace the sidebar is about: the one being looked at, or their first. */
60 workspace: { slug: string; role: "owner" | "member" } | null;
Projects: what a workspace builds and runs, first on every page61 /** Its projects, by name: `name` is the slug in their address. */
62 repos: { namespace: string; name: string; title?: string; isPrivate: boolean }[];
63 /** The project being looked at, if any, whoever owns it. */
Agents as a team: lifecycle, merge queue, billing and a new shell64 repo: {
65 namespace: string;
66 name: string;
67 member: boolean;
68 issues: number;
69 pulls: number;
70 } | null;
Billing accounts, terms and enterprises; g1t is no longer free71 /** Where the workspace stands against its usage limit, if billing is on. */
72 limit: {
73 exposureMicros: number;
74 ceilingMicros: number | null;
75 state: "ok" | "warning" | "stopped";
76 comped: boolean;
77 } | null;
Free while g1t is being built out; agents can check out their own forks78 /** Whether g1t charges nothing for now, while it is being built out. */
79 free?: boolean;
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request80 /** What its agents have cost since the start of the month. */
Usage while free is shown at cost; agents get rustfmt and clippy81 /** This month's usage: charged, or at cost while g1t is free. */
82 monthUsageMicros: number | null;
Agents as a team: lifecycle, merge queue, billing and a new shell83};
84
85function SidebarLink({
86 to,
87 icon,
88 end,
89 count,
90 also,
91 children,
92}: {
93 to: string;
94 icon: ReactNode;
95 end?: boolean;
96 count?: number;
Projects: what a workspace builds and runs, first on every page97 /** Other path prefixes under which this link is the current one. */
98 also?: string | string[];
Agents as a team: lifecycle, merge queue, billing and a new shell99 children: ReactNode;
100}) {
101 const { pathname } = useLocation();
102 return (
103 <NavLink
104 to={to}
105 end={end}
106 prefetch="intent"
107 className={({ isActive, isPending }) => {
Projects: what a workspace builds and runs, first on every page108 const current =
109 isActive || [also ?? []].flat().some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/"));
A Vercel-like sidebar and a new mark110 return `group flex h-8 items-center gap-2.5 rounded-md px-2 text-[0.8125rem] transition-colors ${
Agents as a team: lifecycle, merge queue, billing and a new shell111 current
112 ? "bg-raised font-medium text-fg"
113 : isPending
114 ? "bg-raised/60 text-fg"
115 : "text-muted hover:bg-raised/60 hover:text-fg"
116 }`;
117 }}
118 >
119 <span className="shrink-0 text-faint group-hover:text-muted">{icon}</span>
120 <span className="min-w-0 grow truncate">{children}</span>
121 {count != null && count > 0 && (
122 <span className="rounded bg-line px-1.5 text-[0.6875rem] tabular-nums text-muted">
123 {count}
124 </span>
125 )}
126 </NavLink>
127 );
128}
129
Pull requests say where they are live; the project menu shows what is coming130/**
131 * Something a project will have, shown where it will live so people can
132 * see where g1t is going. Not a link: nothing is behind it yet.
133 */
134function SidebarSoon({ icon, children, about }: { icon: ReactNode; children: ReactNode; about: string }) {
135 return (
136 <div
137 title={about}
138 aria-disabled="true"
139 className="flex h-8 cursor-default items-center gap-2.5 rounded-md px-2 text-[0.8125rem] text-faint"
140 >
141 <span className="shrink-0 opacity-70">{icon}</span>
142 <span className="grow truncate">{children}</span>
143 <span className="rounded-full px-1.5 py-px text-[0.625rem] font-medium tracking-wide text-muted uppercase ring-1 ring-line">
144 Soon
145 </span>
146 </div>
147 );
148}
149
The project menu opens by section, and the workspace has its own panel150/**
151 * A section of the project menu that opens to show its pages, as GitLab's
152 * does: one row with an icon, and its pages indented under it. It opens
153 * by itself when one of its pages is the current one, and otherwise
154 * remembers whether it was left open.
155 */
156function SidebarSection({
157 title,
158 icon,
159 paths = [],
160 soon = false,
161 children,
162}: {
163 title: string;
164 icon: ReactNode;
165 /** Path prefixes of its pages: one being current opens it. */
166 paths?: string[];
167 /** Nothing in it is built yet. */
168 soon?: boolean;
169 children: ReactNode;
170}) {
171 const { pathname } = useLocation();
172 const current = paths.some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/"));
173 const key = `g1t.sidebar.${title}`;
174 const [open, setOpen] = useState<boolean>(current);
175 // What the person left it as, once the page is in the browser.
176 useEffect(() => {
177 if (current) {
178 setOpen(true);
179 return;
180 }
181 try {
182 const saved = localStorage.getItem(key);
183 if (saved != null) setOpen(saved === "1");
184 } catch {
185 // No storage: it stays as it is.
186 }
187 }, [current, key]);
188 const toggle = () => {
189 const next = !open;
190 setOpen(next);
191 try {
192 localStorage.setItem(key, next ? "1" : "0");
193 } catch {
194 // Remembered for this page only.
195 }
196 };
197 return (
198 <section>
199 <button
200 type="button"
201 onClick={toggle}
202 aria-expanded={open}
203 className={`group flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-left text-[0.8125rem] transition-colors hover:bg-raised/60 ${
204 current ? "text-fg" : soon ? "text-faint hover:text-muted" : "text-muted hover:text-fg"
205 }`}
206 >
207 <span className={`shrink-0 ${current ? "text-muted" : "text-faint group-hover:text-muted"}`}>{icon}</span>
208 <span className={`min-w-0 grow truncate ${current ? "font-medium" : ""}`}>{title}</span>
209 {soon && !open && (
210 <span className="rounded-full px-1.5 py-px text-[0.625rem] font-medium tracking-wide text-muted uppercase ring-1 ring-line">
211 Soon
212 </span>
213 )}
214 <ChevronRight
215 size={14}
216 className={`shrink-0 text-faint transition-transform duration-150 ${open ? "rotate-90" : ""}`}
217 aria-hidden="true"
218 />
219 </button>
220 {open && (
221 <div className="relative mt-px mb-1 space-y-px before:absolute before:top-1 before:bottom-1 before:left-[1.1875rem] before:w-px before:bg-line">
222 {children}
223 </div>
224 )}
225 </section>
226 );
227}
228
229/** A page inside a section: indented, without an icon of its own. */
230function SidebarSubLink({
231 to,
232 end,
233 count,
234 also,
235 children,
236}: {
237 to: string;
238 end?: boolean;
239 count?: number;
240 also?: string | string[];
241 children: ReactNode;
242}) {
243 const { pathname } = useLocation();
244 return (
245 <NavLink
246 to={to}
247 end={end}
248 prefetch="intent"
249 className={({ isActive, isPending }) => {
250 const current =
251 isActive || [also ?? []].flat().some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/"));
252 return `relative flex h-8 items-center gap-2 rounded-md pr-2 pl-[2.375rem] text-[0.8125rem] transition-colors ${
253 current
254 ? "bg-raised font-medium text-fg before:absolute before:top-1.5 before:bottom-1.5 before:left-[1.1875rem] before:z-10 before:w-px before:bg-accent"
255 : isPending
256 ? "bg-raised/60 text-fg"
257 : "text-muted hover:bg-raised/60 hover:text-fg"
258 }`;
259 }}
260 >
261 <span className="min-w-0 grow truncate">{children}</span>
262 {count != null && count > 0 && (
263 <span className="rounded bg-line px-1.5 text-[0.6875rem] tabular-nums text-muted">{count}</span>
264 )}
265 </NavLink>
266 );
267}
268
269/** A page a section will have: shown so people can see where g1t is going. */
270function SidebarSubSoon({ about, children }: { about: string; children: ReactNode }) {
271 return (
272 <div
273 title={about}
274 aria-disabled="true"
275 className="flex h-8 cursor-default items-center gap-2 rounded-md pr-2 pl-[2.375rem] text-[0.8125rem] text-faint"
276 >
277 <span className="grow truncate">{children}</span>
278 <span className="rounded-full px-1.5 py-px text-[0.625rem] font-medium tracking-wide text-muted uppercase ring-1 ring-line">
279 Soon
280 </span>
281 </div>
282 );
283}
284
Agents as a team: lifecycle, merge queue, billing and a new shell285function SidebarGroup({ title, action, children }: { title: string; action?: ReactNode; children: ReactNode }) {
286 return (
A Vercel-like sidebar and a new mark287 <section className="mt-6">
288 <div className="mb-1 flex h-6 items-center justify-between px-2">
289 <h2 className="text-xs font-medium text-faint">{title}</h2>
Agents as a team: lifecycle, merge queue, billing and a new shell290 {action}
291 </div>
292 <div className="space-y-px">{children}</div>
293 </section>
294 );
295}
296
297function WorkspaceSwitcher({ user, shell }: { user: User; shell: ShellData }) {
298 const current = shell.workspace?.slug;
299 return (
300 <DropdownMenu>
A Vercel-like sidebar and a new mark301 {/* The name goes to the workspace; only the arrows switch it. */}
302 <Link
303 to={current ? `/${current}` : "/workspaces/new"}
304 className="flex h-8 min-w-0 items-center gap-2 rounded-md px-1.5 transition-colors hover:bg-raised"
305 >
Agents as a team: lifecycle, merge queue, billing and a new shell306 {current ? (
A Vercel-like sidebar and a new mark307 <Avatar name={current} size={20} square />
Agents as a team: lifecycle, merge queue, billing and a new shell308 ) : (
A Vercel-like sidebar and a new mark309 <span className="size-5 rounded-md border border-dashed border-line-strong" />
Agents as a team: lifecycle, merge queue, billing and a new shell310 )}
A Vercel-like sidebar and a new mark311 <span className="min-w-0 truncate text-sm font-medium">{current ?? "Choose a workspace"}</span>
312 {shell.workspace && (
313 <span className="shrink-0 rounded-full bg-raised px-1.5 py-px text-[0.625rem] font-medium text-muted ring-1 ring-line capitalize">
314 {shell.workspace.role}
Agents as a team: lifecycle, merge queue, billing and a new shell315 </span>
A Vercel-like sidebar and a new mark316 )}
317 </Link>
318 <DropdownMenuTrigger
319 aria-label="Switch workspace"
320 className="ml-auto flex h-8 w-6 shrink-0 items-center justify-center rounded-md text-faint outline-none transition-colors hover:bg-raised hover:text-fg data-[state=open]:bg-raised data-[state=open]:text-fg"
321 >
322 <ChevronsUpDown size={14} />
Agents as a team: lifecycle, merge queue, billing and a new shell323 </DropdownMenuTrigger>
324 <DropdownMenuContent align="start" className="w-60">
325 <DropdownMenuLabel>Workspaces</DropdownMenuLabel>
326 {(user.workspaces ?? []).map((membership) => (
327 <DropdownMenuItem asChild key={membership.slug}>
328 <Link to={`/${membership.slug}`}>
329 <Avatar name={membership.slug} size={16} square />
330 <span className="grow">{membership.slug}</span>
331 {membership.slug === current && <Check className="text-accent" />}
332 </Link>
333 </DropdownMenuItem>
334 ))}
335 <DropdownMenuSeparator />
336 <DropdownMenuItem asChild>
337 <Link to="/workspaces/new">
338 <Plus />
339 New workspace
340 </Link>
341 </DropdownMenuItem>
342 </DropdownMenuContent>
343 </DropdownMenu>
344 );
345}
346
Billing accounts, terms and enterprises; g1t is no longer free347/**
348 * This month's usage, and how close the workspace is to its usage limit,
349 * as Vercel shows a plan's usage.
350 */
A Vercel-like sidebar and a new mark351function UsageCard({ slug, shell }: { slug: string; shell: ShellData }) {
Usage while free is shown at cost; agents get rustfmt and clippy352 if (shell.monthUsageMicros == null) return null;
353 const spent = shell.monthUsageMicros;
Billing accounts, terms and enterprises; g1t is no longer free354 const limit = shell.limit;
355 const ceiling = limit?.ceilingMicros ?? null;
356 const share = limit && ceiling ? Math.min(1, limit.exposureMicros / Math.max(ceiling, 1)) : 0;
357 const tone = limit?.state === "stopped" ? "text-danger" : limit?.state === "warning" ? "text-warn" : "text-faint";
358 const bar = limit?.state === "stopped" ? "bg-danger" : limit?.state === "warning" ? "bg-warn" : "bg-accent";
A Vercel-like sidebar and a new mark359 return (
360 <Link
361 to={`/${slug}/-/usage`}
362 className="block rounded-lg bg-surface p-3 ring-1 ring-line transition-colors hover:ring-line-strong"
363 >
364 <span className="flex items-baseline justify-between text-xs">
365 <span className="font-medium text-fg">Usage</span>
366 <span className="text-faint">this month</span>
367 </span>
368 <span className="mt-2 flex items-baseline justify-between">
369 <span className="font-mono text-sm tabular-nums">${(spent / MICROS_PER_DOLLAR).toFixed(2)}</span>
Free while g1t is being built out; agents can check out their own forks370 {shell.free ? (
371 <span className="text-xs text-accent">Free for now</span>
Billing accounts, terms and enterprises; g1t is no longer free372 ) : limit?.comped ? (
373 <span className="text-xs text-accent">Comped</span>
Free while g1t is being built out; agents can check out their own forks374 ) : (
Billing accounts, terms and enterprises; g1t is no longer free375 ceiling != null && (
376 <span className={`text-xs ${tone}`}>
377 {limit?.state === "stopped" ? "Limit reached" : `$${(ceiling / MICROS_PER_DOLLAR).toFixed(2)} limit`}
Free while g1t is being built out; agents can check out their own forks378 </span>
379 )
A Vercel-like sidebar and a new mark380 )}
381 </span>
Billing accounts, terms and enterprises; g1t is no longer free382 {ceiling != null && !limit?.comped && (
383 <span className="mt-2 block h-1 overflow-hidden rounded-full bg-raised">
384 <span
385 className={`block h-full rounded-full ${bar}`}
386 style={{ width: `${Math.max(share * 100, share > 0 ? 3 : 0)}%` }}
387 />
388 </span>
389 )}
A Vercel-like sidebar and a new mark390 </Link>
391 );
392}
393
394function AccountMenu({ user }: { user: User }) {
395 const submit = useSubmit();
396 return (
397 <DropdownMenu>
398 <DropdownMenuTrigger className="flex h-10 w-full items-center gap-2.5 rounded-md px-2 text-left outline-none transition-colors hover:bg-raised data-[state=open]:bg-raised">
399 <Avatar name={user.username} size={22} />
400 <span className="min-w-0 grow truncate text-[0.8125rem] font-medium">{user.username}</span>
401 <Ellipsis size={15} className="shrink-0 text-faint" />
402 </DropdownMenuTrigger>
403 <DropdownMenuContent align="start" side="top" className="w-56">
404 <DropdownMenuLabel>
405 Signed in as <span className="font-mono font-medium text-fg">{user.username}</span>
406 </DropdownMenuLabel>
407 <DropdownMenuSeparator />
408 <DropdownMenuItem asChild>
409 <Link to="/settings">
410 <Settings />
411 Your settings
412 </Link>
413 </DropdownMenuItem>
414 <DropdownMenuItem asChild>
415 <a href="https://docs.g1t.sh/">
416 <BookOpen />
417 Documentation
418 </a>
419 </DropdownMenuItem>
420 <DropdownMenuSeparator />
421 {/* Submitted from here: the menu closes on select, and a button
422 that has left the page cannot submit a form. */}
423 <DropdownMenuItem onSelect={() => submit(null, { method: "post", action: "/logout" })}>
424 <LogOut />
425 Sign out
426 </DropdownMenuItem>
427 </DropdownMenuContent>
428 </DropdownMenu>
429 );
430}
431
A catalogue of model providers, and settings that feel like settings432/** A workspace's settings pages, which the sidebar slides over to. */
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs433const SETTINGS_PAGE = /^\/([^/]+)\/-\/(settings|people|tokens|billing|integrations|webhooks|secrets)(\/|$)/;
A catalogue of model providers, and settings that feel like settings434
Polish: phones, copy boxes, the plan page, the landing page, a real glide435/**
Sidebar: no settings flash on the way into a repository, and a better slide436 * The sidebar's menus are two layers, the way a phone pushes a screen: the
437 * one arriving slides in from the right over the full width, while the one
438 * leaving drifts a quarter of the way left and fades, both on one long
Sidebar: the panels really slide439 * ease-out, the fade quicker than the move so the two never blur together.
440 * Going back reverses it.
Polish: phones, copy boxes, the plan page, the landing page, a real glide441 */
Sidebar: no settings flash on the way into a repository, and a better slide442const LAYER =
Sidebar: the panels really slide443 "absolute inset-0 [transition:translate_380ms_cubic-bezier(0.32,0.72,0,1),opacity_220ms_ease-out] will-change-[translate,opacity] motion-reduce:transition-none";
Sidebar: no settings flash on the way into a repository, and a better slide444/** One menu, filling its layer. */
445const PANEL = "h-full overflow-y-auto px-2 pb-4";
A catalogue of model providers, and settings that feel like settings446
447/** A workspace's settings, as the sidebar shows them in place of everything else. */
448function SettingsMenu({ slug, owner, open }: { slug: string; owner: boolean; open: boolean }) {
449 return (
450 <nav
451 aria-label="Workspace settings"
452 inert={!open}
Polish: phones, copy boxes, the plan page, the landing page, a real glide453 className={PANEL}
A catalogue of model providers, and settings that feel like settings454 >
455 <Link
456 to={`/${slug}`}
457 className="group mt-3 flex h-8 items-center gap-2 rounded-md px-2 text-[0.8125rem] text-muted transition-colors hover:bg-raised/60 hover:text-fg"
458 >
459 <ArrowLeft size={15} className="text-faint transition-transform group-hover:-translate-x-0.5 group-hover:text-muted" />
460 <span className="truncate">{slug}</span>
461 </Link>
462 <SidebarGroup title="Settings">
463 {owner && (
464 <SidebarLink to={`/${slug}/-/settings`} icon={<Settings size={15} />}>
465 General
466 </SidebarLink>
467 )}
468 <SidebarLink to={`/${slug}/-/people`} icon={<Users size={15} />}>
469 Members
470 </SidebarLink>
Secrets and variables: one list, rows per environment, for workflows and deployments471 <SidebarLink to={`/${slug}/-/tokens`} icon={<KeyRound size={15} />}>
472 Access tokens
473 </SidebarLink>
A catalogue of model providers, and settings that feel like settings474 <SidebarLink to={`/${slug}/-/billing`} icon={<CreditCard size={15} />}>
Secrets and variables: one list, rows per environment, for workflows and deployments475 Billing and plans
A catalogue of model providers, and settings that feel like settings476 </SidebarLink>
477 <SidebarLink to={`/${slug}/-/integrations`} icon={<Plug size={15} />}>
478 Integrations
Webhooks: every event, to your own addresses, signed and retried479 </SidebarLink>
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs480 <SidebarLink to={`/${slug}/-/secrets`} icon={<Lock size={15} />}>
481 Secrets and variables
482 </SidebarLink>
Secrets and variables: one list, rows per environment, for workflows and deployments483 <SidebarLink to={`/${slug}/-/webhooks`} icon={<Webhook size={15} />}>
484 Webhooks
A catalogue of model providers, and settings that feel like settings485 </SidebarLink>
486 </SidebarGroup>
487 </nav>
488 );
489}
490
Sidebar: no settings flash on the way into a repository, and a better slide491/**
492 * What the repository menu needs. Known from the address before the page's
493 * data arrives, so the menu is right from the first frame; the counts fill
494 * in once it does.
495 */
496type MenuRepo = {
497 namespace: string;
498 name: string;
499 member: boolean;
500 issues?: number;
501 pulls?: number;
502};
503
504function sameRepo(a: { namespace: string; name: string } | null, b: { namespace: string; name: string } | null) {
505 return (
506 a != null &&
507 b != null &&
508 a.namespace.toLowerCase() === b.namespace.toLowerCase() &&
509 a.name.toLowerCase() === b.name.toLowerCase()
510 );
511}
A repository has its own sidebar, as settings do512
513/**
Projects: what a workspace builds and runs, first on every page514 * A project's own menu, which the sidebar slides to while you are in it,
515 * as it does for settings: everything about the project, running and its
516 * code, and nothing else, with the way back to everything.
A repository has its own sidebar, as settings do517 */
Sidebar: no settings flash on the way into a repository, and a better slide518function RepoMenu({ repo, isPrivate, open }: { repo: MenuRepo; isPrivate: boolean; open: boolean }) {
A repository has its own sidebar, as settings do519 const base = `/${repo.namespace}/${repo.name}`;
520 return (
521 <nav aria-label={`${repo.namespace}/${repo.name}`} inert={!open} className={PANEL}>
522 <Link
523 to="/"
524 className="group mt-3 flex h-8 items-center gap-2 rounded-md px-2 text-[0.8125rem] text-muted transition-colors hover:bg-raised/60 hover:text-fg"
525 >
526 <ArrowLeft size={15} className="text-faint transition-transform group-hover:-translate-x-0.5 group-hover:text-muted" />
527 Mission control
528 </Link>
529 <Link
530 to={base}
531 className="mt-3 flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-raised/60"
532 >
533 <span className="flex size-6 shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line">
Projects: what a workspace builds and runs, first on every page534 {isPrivate ? <Lock size={13} /> : <Box size={13} />}
A repository has its own sidebar, as settings do535 </span>
536 <span className="min-w-0 truncate font-mono text-[0.8125rem]">
537 <span className="text-faint">{repo.namespace}/</span>
538 <span className="font-semibold text-fg">{repo.name}</span>
539 </span>
540 </Link>
Projects: what a workspace builds and runs, first on every page541 <div className="mt-3 space-y-px">
542 <SidebarLink to={base} end icon={<LayoutGrid size={15} />}>
543 Overview
544 </SidebarLink>
The project menu opens by section, and the workspace has its own panel545
546 <SidebarSection title="Plan" icon={<Kanban size={15} />} paths={[`${base}/issues`, `${base}/plans`]}>
547 <SidebarSubLink to={`${base}/issues`} count={repo.issues}>
548 Issues
549 </SidebarSubLink>
550 {repo.member && <SidebarSubLink to={`${base}/plans`}>Outcomes</SidebarSubLink>}
551 <SidebarSubSoon about="Issues and pull requests on boards, by state, owner or outcome.">Boards</SidebarSubSoon>
552 <SidebarSubSoon about="Dates to land outcomes by, with what is left and what is at risk.">Milestones</SidebarSubSoon>
553 <SidebarSubSoon about="Pages about the project that agents keep current as the code changes.">Wiki</SidebarSubSoon>
554 </SidebarSection>
555
556 <SidebarSection
557 title="Code"
558 icon={<Code2 size={15} />}
559 paths={[`${base}/pulls`, `${base}/pull`, `${base}/queue`, `${base}/code`, `${base}/tree`, `${base}/blob`, `${base}/commits`, `${base}/commit`]}
560 >
561 <SidebarSubLink to={`${base}/pulls`} also={`${base}/pull`} count={repo.pulls}>
562 Pull requests
563 </SidebarSubLink>
564 <SidebarSubLink to={`${base}/queue`}>Merge queue</SidebarSubLink>
565 <SidebarSubLink to={`${base}/code`} also={[`${base}/tree`, `${base}/blob`]}>
566 Files
567 </SidebarSubLink>
568 <SidebarSubLink to={`${base}/commits`} also={`${base}/commit`}>
569 Commits
570 </SidebarSubLink>
571 <SidebarSubSoon about="Every branch, who and what is on it, how far behind it is, and its preview.">Branches</SidebarSubSoon>
572 <SidebarSubSoon about="Tags, and the releases made from them.">Tags</SidebarSubSoon>
573 </SidebarSection>
574
575 <SidebarSection title="Agents" icon={<Bot size={15} />} soon>
576 <SidebarSubSoon about="Every agent at work on this project now: what it is doing, what it knows, and a way to steer it.">
577 At work
578 </SidebarSubSoon>
579 <SidebarSubSoon about="Every agent session that changed this project, searchable, with why-blame back to the lines it wrote.">
580 Sessions
581 </SidebarSubSoon>
582 <SidebarSubSoon about="How agents should work here: conventions, commands and checks, kept with the code.">
583 Playbooks
584 </SidebarSubSoon>
585 </SidebarSection>
586
587 <SidebarSection title="Build" icon={<PlayCircle size={15} />} paths={[`${base}/actions`]}>
588 <SidebarSubLink to={`${base}/actions`}>Actions</SidebarSubLink>
589 <SidebarSubSoon about="g1t's machines, or your own, that run workflow jobs and checks.">Runners</SidebarSubSoon>
590 <SidebarSubSoon about="What builds and workflow jobs produce, kept and downloadable.">Artifacts</SidebarSubSoon>
591 <SidebarSubSoon about="Workflows that run on a timetable, and their history.">Schedules</SidebarSubSoon>
592 </SidebarSection>
593
594 <SidebarSection title="Deploy" icon={<Rocket size={15} />} paths={repo.member ? [`${base}/deployments`] : []}>
595 {repo.member && <SidebarSubLink to={`${base}/deployments`}>Deployments</SidebarSubLink>}
596 <SidebarSubSoon about="Staging and other environments, with required approvers and branch rules.">Environments</SidebarSubSoon>
597 <SidebarSubSoon about="Tagged releases with notes written from what landed.">Releases</SidebarSubSoon>
598 <SidebarSubSoon about="npm, container and other packages published from the project.">Packages</SidebarSubSoon>
599 <SidebarSubSoon about="Turn features on per environment or per user, without a deploy.">Feature flags</SidebarSubSoon>
600 </SidebarSection>
601
602 <SidebarSection title="Secure" icon={<ShieldCheck size={15} />} soon>
603 <SidebarSubSoon about="Every finding in one place, by severity, with the agent fixing each.">Security overview</SidebarSubSoon>
604 <SidebarSubSoon about="Keys and tokens found in the code or its history, revoked and removed by an agent.">
605 Secret scanning
606 </SidebarSubSoon>
607 <SidebarSubSoon about="Outdated and vulnerable packages, updated by agents, tested and landed through the queue.">
608 Dependency updates
609 </SidebarSubSoon>
610 <SidebarSubSoon about="Code scanned for vulnerabilities on every change, each finding fixed through the queue.">
611 Code scanning
612 </SidebarSubSoon>
613 </SidebarSection>
614
615 <SidebarSection title="Operate" icon={<Activity size={15} />} soon>
616 <SidebarSubSoon about="Requests, errors and CPU time of each deployment, and its logs.">Logs and metrics</SidebarSubSoon>
617 <SidebarSubSoon about="Errors and incidents from the running app, each becoming an issue an agent can take.">
618 Errors and incidents
619 </SidebarSubSoon>
620 <SidebarSubSoon about="Checks that the app answers, from around the world, and who is told when it does not.">Uptime</SidebarSubSoon>
621 </SidebarSection>
622
623 <SidebarSection title="Analyze" icon={<BarChart3 size={15} />} soon>
624 <SidebarSubSoon about="How work flows: lead time, review time, and the share of changes agents make.">Insights</SidebarSubSoon>
625 <SidebarSubSoon about="What the project costs, by agent run, sandbox, build and app.">Costs</SidebarSubSoon>
626 <SidebarSubSoon about="Deploy frequency, lead time, change failure rate and time to restore.">Delivery metrics</SidebarSubSoon>
627 </SidebarSection>
628
Projects: what a workspace builds and runs, first on every page629 {repo.member && (
The project menu opens by section, and the workspace has its own panel630 <SidebarSection title="Settings" icon={<Settings size={15} />} paths={[`${base}/settings`]}>
631 <SidebarSubLink to={`${base}/settings`} end>
632 General
633 </SidebarSubLink>
634 <SidebarSubLink to={`${base}/settings/repository`}>Repository</SidebarSubLink>
635 <SidebarSubLink to={`${base}/settings/deployments`}>Deployments</SidebarSubLink>
636 <SidebarSubLink to={`${base}/settings/dependencies`}>Dependencies</SidebarSubLink>
637 <SidebarSubLink to={`${base}/settings/secrets`}>Secrets and variables</SidebarSubLink>
638 <SidebarSubLink to={`${base}/settings/webhooks`}>Webhooks</SidebarSubLink>
639 </SidebarSection>
Projects: what a workspace builds and runs, first on every page640 )}
641 </div>
A repository has its own sidebar, as settings do642 </nav>
643 );
644}
645
Account settings in the same shape as a workspace's646/** Your own settings, as the sidebar shows them on the settings page. */
647function AccountSettingsMenu({ open }: { open: boolean }) {
648 const { hash } = useLocation();
649 const item = (id: string, icon: ReactNode, label: string) => (
650 <Link
651 to={`/settings#${id}`}
652 className={`group flex h-8 items-center gap-2.5 rounded-md px-2 text-[0.8125rem] transition-colors ${
653 hash === `#${id}` ? "bg-raised font-medium text-fg" : "text-muted hover:bg-raised/60 hover:text-fg"
654 }`}
655 >
656 <span className="shrink-0 text-faint group-hover:text-muted">{icon}</span>
657 {label}
658 </Link>
659 );
660 return (
661 <nav
662 aria-label="Your settings"
663 inert={!open}
Polish: phones, copy boxes, the plan page, the landing page, a real glide664 className={PANEL}
Account settings in the same shape as a workspace's665 >
666 <Link
667 to="/"
668 className="group mt-3 flex h-8 items-center gap-2 rounded-md px-2 text-[0.8125rem] text-muted transition-colors hover:bg-raised/60 hover:text-fg"
669 >
670 <ArrowLeft size={15} className="text-faint transition-transform group-hover:-translate-x-0.5 group-hover:text-muted" />
671 Mission control
672 </Link>
673 <SidebarGroup title="Account">
Secrets and variables: one list, rows per environment, for workflows and deployments674 {item("ssh-keys", <Fingerprint size={15} />, "SSH keys")}
675 {item("tokens", <KeyRound size={15} />, "Access tokens")}
Account settings in the same shape as a workspace's676 {item("applications", <Plug size={15} />, "Connected applications")}
677 </SidebarGroup>
678 </nav>
679 );
680}
681
A Vercel-like sidebar and a new mark682function Sidebar({ user, shell, onFind }: { user: User; shell: ShellData; onFind: () => void }) {
Agents as a team: lifecycle, merge queue, billing and a new shell683 const ws = shell.workspace;
A catalogue of model providers, and settings that feel like settings684 const { pathname } = useLocation();
685 const going = useNavigation().location?.pathname;
686 // On a workspace's settings page, or on the way to one, its settings take
687 // the sidebar over.
688 const inSettings = ws != null && SETTINGS_PAGE.exec(going ?? pathname)?.[1]?.toLowerCase() === ws.slug;
Account settings in the same shape as a workspace's689 const inAccount = (going ?? pathname) === "/settings";
A repository has its own sidebar, as settings do690 const active = shell.repo;
691 // In a repository, or on the way into one, its own menu takes the sidebar.
692 const target = going ?? pathname;
693 const repoPath = /^\/([^/]+)\/([^/-][^/]*)(\/|$)/.exec(target);
694 const reserved = new Set(["settings", "explore", "search", "new", "workspaces", "login", "logout", "register", "verify", "forgot", "reset", "device", "oauth"]);
695 const inRepo = repoPath != null && !reserved.has(repoPath[1]) && repoPath[2] !== "-";
696 const away = inSettings || inAccount || inRepo;
Sidebar: no settings flash on the way into a repository, and a better slide697 // The repository the menu is for: the one loaded if it is the one being
698 // gone to, else what the address says, at once.
699 const targetRepo = inRepo && repoPath ? { namespace: repoPath[1], name: repoPath[2] } : null;
700 const menuRepo: MenuRepo | null = targetRepo
701 ? sameRepo(active, targetRepo)
702 ? active
703 : {
704 ...targetRepo,
705 member: (user.workspaces ?? []).some((m) => m.slug === targetRepo.namespace.toLowerCase()),
706 }
707 : null;
A repository has its own sidebar, as settings do708 // What sits on the far side of the track. Kept while sliding back, so it
709 // does not vanish on the way out.
710 const side = useRef<"workspace" | "account" | "repo">("workspace");
Polish: phones, copy boxes, the plan page, the landing page, a real glide711 if (inAccount) side.current = "account";
712 else if (inSettings) side.current = "workspace";
A repository has its own sidebar, as settings do713 else if (inRepo) side.current = "repo";
714 // The repository last shown, kept for the slide back.
Sidebar: no settings flash on the way into a repository, and a better slide715 const shown = useRef<MenuRepo | null>(menuRepo);
716 if (menuRepo) shown.current = menuRepo;
717 // Moving between two of the far-side menus (settings to a repository,
718 // one repository to another) crossfades in place instead of sliding.
719 const detailKey = side.current === "repo" ? `repo:${shown.current?.namespace}/${shown.current?.name}` : side.current;
720 const lastAway = useRef(away);
721 const lastKey = useRef(detailKey);
722 const swapped = lastAway.current && away && lastKey.current !== detailKey;
723 useEffect(() => {
724 lastAway.current = away;
725 lastKey.current = detailKey;
726 });
Agents as a team: lifecycle, merge queue, billing and a new shell727 // The repository being looked at is listed even when it is someone else's.
728 const listed =
729 active && !shell.repos.some((repo) => repo.namespace === active.namespace && repo.name === active.name)
730 ? [{ namespace: active.namespace, name: active.name, isPrivate: false }, ...shell.repos]
731 : shell.repos;
732 return (
733 <div className="flex h-full flex-col">
A Vercel-like sidebar and a new mark734 {/* The same height and rule as the top bar, so the two read as one line. */}
Two limits, real invoices, trust that grows by itself, sales signals735 <div className="flex h-16 shrink-0 items-center gap-2 border-b border-line px-3">
736 <Link to="/" aria-label="g1t home" className="shrink-0 rounded-md p-2 hover:bg-raised">
737 <Mark className="size-6" />
Agents as a team: lifecycle, merge queue, billing and a new shell738 </Link>
A Vercel-like sidebar and a new mark739 <span className="shrink-0 text-line-strong" aria-hidden="true">
740 /
741 </span>
742 <WorkspaceSwitcher user={user} shell={shell} />
Agents as a team: lifecycle, merge queue, billing and a new shell743 </div>
A Vercel-like sidebar and a new mark744 <div className="px-2 pt-3">
745 <button
746 type="button"
747 onClick={onFind}
Two limits, real invoices, trust that grows by itself, sales signals748 className="flex h-9 w-full items-center gap-2 rounded-md bg-surface px-2.5 text-[0.8125rem] text-faint ring-1 ring-line transition-colors hover:text-muted hover:ring-line-strong"
A Vercel-like sidebar and a new mark749 >
750 <Search size={14} />
751 <span className="grow text-left">Find…</span>
752 <kbd className="rounded bg-raised px-1.5 font-mono text-[0.625rem] text-muted ring-1 ring-line">⌘K</kbd>
753 </button>
Agents as a team: lifecycle, merge queue, billing and a new shell754 </div>
Sidebar: no settings flash on the way into a repository, and a better slide755 <div className="relative min-h-0 grow overflow-hidden">
756 <div className={`${LAYER} ${away ? "pointer-events-none -translate-x-1/4 opacity-0" : "translate-x-0 opacity-100"}`}>
Polish: phones, copy boxes, the plan page, the landing page, a real glide757 <nav aria-label="g1t" inert={away} className={PANEL}>
Agents as a team: lifecycle, merge queue, billing and a new shell758 <div className="mt-3 space-y-px">
759 <SidebarLink to="/" end icon={<LayoutDashboard size={15} />}>
760 Mission control
761 </SidebarLink>
762 <SidebarLink to="/explore" icon={<Compass size={15} />}>
763 Explore
764 </SidebarLink>
765 </div>
766
767 <SidebarGroup
Projects: what a workspace builds and runs, first on every page768 title="Projects"
Agents as a team: lifecycle, merge queue, billing and a new shell769 action={
770 ws && (
771 <Link
772 to={`/new?workspace=${ws.slug}`}
Projects: what a workspace builds and runs, first on every page773 aria-label="New project"
Agents as a team: lifecycle, merge queue, billing and a new shell774 className="rounded p-0.5 text-faint hover:bg-raised hover:text-fg"
775 >
776 <Plus size={13} />
777 </Link>
778 )
779 }
780 >
781 {listed.length === 0 && (
782 <p className="px-2 py-1 text-xs text-faint">None yet.</p>
783 )}
784 {listed.map((repo) => {
785 const base = `/${repo.namespace}/${repo.name}`;
786 return (
787 <div key={base}>
788 <SidebarLink
789 to={base}
Projects: what a workspace builds and runs, first on every page790 icon={repo.isPrivate ? <Lock size={15} /> : <Box size={15} />}
Agents as a team: lifecycle, merge queue, billing and a new shell791 >
Projects: what a workspace builds and runs, first on every page792 <span className="text-[0.8125rem]">
Agents as a team: lifecycle, merge queue, billing and a new shell793 {repo.namespace !== ws?.slug && (
Projects: what a workspace builds and runs, first on every page794 <span className="font-mono text-faint">{repo.namespace}/</span>
Agents as a team: lifecycle, merge queue, billing and a new shell795 )}
Projects: what a workspace builds and runs, first on every page796 {"title" in repo && repo.title ? repo.title : repo.name}
Agents as a team: lifecycle, merge queue, billing and a new shell797 </span>
798 </SidebarLink>
799 </div>
800 );
801 })}
802 </SidebarGroup>
803 </nav>
Polish: phones, copy boxes, the plan page, the landing page, a real glide804 </div>
Sidebar: no settings flash on the way into a repository, and a better slide805 <div className={`${LAYER} ${away ? "translate-x-0 opacity-100" : "pointer-events-none translate-x-full opacity-0"}`}>
806 <div key={detailKey} className={`h-full ${swapped ? "animate-[g1t-swap_220ms_ease-out]" : ""}`}>
807 {side.current === "repo" && shown.current ? (
808 <RepoMenu
809 repo={shown.current}
810 isPrivate={shell.repos.some((repo) => sameRepo(repo, shown.current) && repo.isPrivate)}
811 open={inRepo}
812 />
813 ) : side.current === "account" || !ws ? (
814 <AccountSettingsMenu open={inAccount} />
815 ) : (
816 <SettingsMenu slug={ws.slug} owner={ws.role === "owner"} open={inSettings} />
817 )}
818 </div>
819 </div>
A catalogue of model providers, and settings that feel like settings820 </div>
Agents as a team: lifecycle, merge queue, billing and a new shell821
The project menu opens by section, and the workspace has its own panel822 {/* The workspace's own things sit at the bottom, by its usage and the
823 account: a panel of their own, ruled off from whatever menu is above,
824 however long it grows. */}
825 <div className="shrink-0 space-y-2 border-t border-line bg-surface/50 p-2 pt-3">
Workspace things at the bottom of the sidebar, and on mission control826 {ws && (
827 <div className="space-y-px">
The project menu opens by section, and the workspace has its own panel828 <p className="flex items-center gap-2 px-2 pb-1 text-[0.6875rem] font-medium uppercase tracking-wider text-faint">
829 <span>Workspace</span>
830 <span className="min-w-0 truncate font-mono normal-case tracking-normal text-muted">{ws.slug}</span>
831 </p>
Workspace things at the bottom of the sidebar, and on mission control832 <SidebarLink to={`/${ws.slug}/-/usage`} icon={<BarChart3 size={15} />}>
833 Usage
834 </SidebarLink>
835 {/* Everything else about the workspace lives in its settings, and only there. */}
836 <SidebarLink
837 to={ws.role === "owner" ? `/${ws.slug}/-/settings` : `/${ws.slug}/-/people`}
838 icon={<Settings size={15} />}
839 >
840 Settings
841 </SidebarLink>
842 </div>
843 )}
A Vercel-like sidebar and a new mark844 {ws && <UsageCard slug={ws.slug} shell={shell} />}
845 <AccountMenu user={user} />
846 </div>
847 </div>
848 );
849}
850
851/** Words for the sections a path can end in. */
852const SECTIONS: Record<string, string> = {
853 issues: "Issues",
854 pulls: "Pull requests",
855 queue: "Merge queue",
856 commits: "Commits",
857 plans: "Plan",
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs858 actions: "Actions",
Deployments: a preview for every pull request, production on g1t.page859 deployments: "Deployments",
Projects: what a workspace builds and runs, first on every page860 repository: "Repository",
Project dependencies: addresses, preview stacks, Affects, and agents who know861 dependencies: "Dependencies",
Projects: what a workspace builds and runs, first on every page862 code: "Code",
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs863 secrets: "Secrets and variables",
A Vercel-like sidebar and a new mark864 settings: "Settings",
A catalogue of model providers, and settings that feel like settings865 people: "Members",
A Vercel-like sidebar and a new mark866 tokens: "Access tokens",
867 usage: "Usage",
Secrets and variables: one list, rows per environment, for workflows and deployments868 billing: "Billing and plans",
A catalogue of model providers, and settings that feel like settings869 integrations: "Integrations",
Webhooks: every event, to your own addresses, signed and retried870 webhooks: "Webhooks",
A Vercel-like sidebar and a new mark871 tree: "Code",
872 blob: "Code",
873};
874
875/** Where the page is, as a trail of links: workspace / repository / section. */
876function Breadcrumbs({ pathname }: { pathname: string }) {
877 const parts = pathname.split("/").filter(Boolean);
878 const reserved = ["settings", "explore", "new", "search", "workspaces"];
879 if (parts.length === 0) return <span className="text-sm font-medium">Mission control</span>;
880 if (reserved.includes(parts[0]!)) {
881 const words: Record<string, string> = {
Account settings in the same shape as a workspace's882 settings: "Account",
A Vercel-like sidebar and a new mark883 explore: "Explore",
Projects live: fixes from walking them end to end884 new: "New project",
A Vercel-like sidebar and a new mark885 search: "Search",
886 workspaces: "New workspace",
887 };
888 return <span className="text-sm font-medium">{words[parts[0]!]}</span>;
889 }
890 const [owner, second, third, fourth] = parts;
891 const trail: { label: string; to: string; mono?: boolean }[] = [{ label: owner!, to: `/${owner}`, mono: true }];
892 if (second === "-") {
A catalogue of model providers, and settings that feel like settings893 const page = `/${owner}/-/${third}`;
894 if (third && SETTINGS_PAGE.test(page)) {
895 trail.push({ label: "Settings", to: `/${owner}/-/settings` });
896 trail.push({ label: third === "settings" ? "General" : (SECTIONS[third] ?? third), to: page });
897 } else if (third) trail.push({ label: SECTIONS[third] ?? third, to: page });
A Vercel-like sidebar and a new mark898 } else if (second) {
899 const repo = `/${owner}/${second}`;
900 trail.push({ label: second, to: repo, mono: true });
901 if (third === "pull" && fourth) trail.push({ label: `Pull request #${fourth}`, to: `${repo}/pull/${fourth}` });
902 else if (third === "issues" && fourth && fourth !== "new") trail.push({ label: `Issue #${fourth}`, to: `${repo}/issues/${fourth}` });
903 else if (third === "commit" && fourth) trail.push({ label: fourth.slice(0, 7), to: `${repo}/commit/${fourth}`, mono: true });
Secrets and variables: one list, rows per environment, for workflows and deployments904 else if (third && SECTIONS[third]) {
905 trail.push({ label: SECTIONS[third]!, to: `${repo}/${third}` });
906 // A settings page names which one: Settings / Secrets and variables.
907 if (third === "settings" && fourth && SECTIONS[fourth]) {
908 trail.push({ label: SECTIONS[fourth]!, to: `${repo}/settings/${fourth}` });
909 }
910 }
A Vercel-like sidebar and a new mark911 }
912 return (
913 <nav aria-label="Where you are" className="flex min-w-0 items-center gap-1.5 text-sm">
914 {trail.map((crumb, index) => (
915 <span key={crumb.to} className="flex min-w-0 items-center gap-1.5">
916 {index > 0 && <span className="text-line-strong">/</span>}
Agents as a team: lifecycle, merge queue, billing and a new shell917 <Link
A Vercel-like sidebar and a new mark918 to={crumb.to}
919 className={`truncate rounded px-1 py-0.5 transition-colors hover:bg-raised ${
920 index === trail.length - 1 ? "font-medium text-fg" : "text-muted hover:text-fg"
921 } ${crumb.mono ? "font-mono text-[0.8125rem]" : ""}`}
Agents as a team: lifecycle, merge queue, billing and a new shell922 >
A Vercel-like sidebar and a new mark923 {crumb.label}
Agents as a team: lifecycle, merge queue, billing and a new shell924 </Link>
A Vercel-like sidebar and a new mark925 </span>
926 ))}
927 </nav>
Agents as a team: lifecycle, merge queue, billing and a new shell928 );
929}
930
931type Command = { label: string; hint?: string; to: string; icon: ReactNode };
932
933/** Everything the palette can jump to, from what the sidebar already knows. */
934function commandsFor(user: User, shell: ShellData): Command[] {
935 const commands: Command[] = [
936 { label: "Mission control", to: "/", icon: <LayoutDashboard size={15} /> },
937 { label: "Explore repositories", to: "/explore", icon: <Compass size={15} /> },
Projects: what a workspace builds and runs, first on every page938 { label: "New project", to: "/new", icon: <Plus size={15} /> },
Agents as a team: lifecycle, merge queue, billing and a new shell939 { label: "New workspace", to: "/workspaces/new", icon: <Plus size={15} /> },
940 { label: "Your settings", to: "/settings", icon: <Settings size={15} /> },
941 ];
942 const repo = shell.repo;
943 if (repo) {
944 const base = `/${repo.namespace}/${repo.name}`;
945 const name = `${repo.namespace}/${repo.name}`;
946 commands.unshift(
Projects: what a workspace builds and runs, first on every page947 { label: "Overview", hint: name, to: base, icon: <LayoutGrid size={15} /> },
948 { label: "Code", hint: name, to: `${base}/code`, icon: <Code2 size={15} /> },
Agents as a team: lifecycle, merge queue, billing and a new shell949 { label: "Issues", hint: name, to: `${base}/issues`, icon: <CircleDot size={15} /> },
950 { label: "New issue", hint: name, to: `${base}/issues/new`, icon: <Plus size={15} /> },
951 { label: "Pull requests", hint: name, to: `${base}/pulls`, icon: <GitPullRequest size={15} /> },
952 { label: "Commits", hint: name, to: `${base}/commits`, icon: <History size={15} /> },
953 ...(repo.member
954 ? [
955 { label: "Plan work", hint: name, to: `${base}/plans`, icon: <ListTree size={15} /> },
Projects: what a workspace builds and runs, first on every page956 { label: "Deployments", hint: name, to: `${base}/deployments`, icon: <Rocket size={15} /> },
957 { label: "Secrets and variables", hint: name, to: `${base}/settings/secrets`, icon: <Lock size={15} /> },
958 { label: "Project settings", hint: name, to: `${base}/settings`, icon: <Settings size={15} /> },
959 { label: "Repository settings", hint: name, to: `${base}/settings/repository`, icon: <Settings size={15} /> },
Agents as a team: lifecycle, merge queue, billing and a new shell960 ]
961 : []),
962 );
963 }
964 for (const membership of user.workspaces ?? []) {
965 commands.push(
966 { label: membership.slug, hint: "Workspace", to: `/${membership.slug}`, icon: <Avatar name={membership.slug} size={15} square /> },
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request967 { label: "Usage", hint: membership.slug, to: `/${membership.slug}/-/usage`, icon: <BarChart3 size={15} /> },
Projects: what a workspace builds and runs, first on every page968 { label: "Billing and plans", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/billing`, icon: <CreditCard size={15} /> },
A catalogue of model providers, and settings that feel like settings969 { label: "Access tokens", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/tokens`, icon: <KeyRound size={15} /> },
970 { label: "Integrations", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/integrations`, icon: <Plug size={15} /> },
Agents as a team: lifecycle, merge queue, billing and a new shell971 );
972 }
973 for (const listed of shell.repos) {
974 commands.push({
Projects: what a workspace builds and runs, first on every page975 label: listed.title ?? listed.name,
976 hint: `${listed.namespace} · Project`,
Agents as a team: lifecycle, merge queue, billing and a new shell977 to: `/${listed.namespace}/${listed.name}`,
Projects: what a workspace builds and runs, first on every page978 icon: <Box size={15} />,
Agents as a team: lifecycle, merge queue, billing and a new shell979 });
980 }
981 return commands;
982}
983
984function CommandPalette({
985 open,
986 onClose,
987 commands,
988}: {
989 open: boolean;
990 onClose: () => void;
991 commands: Command[];
992}) {
993 const navigate = useNavigate();
994 const [query, setQuery] = useState("");
995 const [selected, setSelected] = useState(0);
996 const input = useRef<HTMLInputElement>(null);
997 const matches = useMemo(() => {
998 const words = query.toLowerCase().split(/\s+/).filter(Boolean);
999 return commands
1000 .filter((command) => {
1001 const text = `${command.label} ${command.hint ?? ""}`.toLowerCase();
1002 return words.every((word) => text.includes(word));
1003 })
1004 .slice(0, 12);
1005 }, [commands, query]);
1006
1007 useEffect(() => {
1008 if (!open) return;
1009 setQuery("");
1010 setSelected(0);
1011 input.current?.focus();
1012 }, [open]);
1013 useEffect(() => setSelected(0), [query]);
1014
1015 if (!open) return null;
1016 const go = (command: Command | undefined) => {
1017 if (!command) return;
1018 onClose();
1019 navigate(command.to);
1020 };
1021 return (
1022 <div className="fixed inset-0 z-50 flex items-start justify-center bg-black/50 px-4 pt-[12vh] backdrop-blur-sm" onClick={onClose}>
1023 <div
1024 role="dialog"
1025 aria-label="Go to"
1026 className="w-full max-w-xl overflow-hidden rounded-xl border border-line-strong bg-raised shadow-2xl shadow-black/60"
1027 onClick={(event) => event.stopPropagation()}
1028 >
1029 <div className="flex items-center gap-3 border-b border-line px-4">
1030 <Search size={16} className="text-faint" />
1031 <input
1032 ref={input}
1033 value={query}
1034 onChange={(event) => setQuery(event.target.value)}
1035 onKeyDown={(event) => {
1036 if (event.key === "ArrowDown") {
1037 event.preventDefault();
1038 setSelected((index) => Math.min(index + 1, matches.length - 1));
1039 } else if (event.key === "ArrowUp") {
1040 event.preventDefault();
1041 setSelected((index) => Math.max(index - 1, 0));
1042 } else if (event.key === "Enter") {
1043 event.preventDefault();
1044 go(matches[selected]);
1045 } else if (event.key === "Escape") {
1046 onClose();
1047 }
1048 }}
1049 placeholder="Go to a repository, a page, or an action…"
1050 autoComplete="off"
1051 data-1p-ignore
1052 className="h-12 grow border-0 bg-transparent text-sm shadow-none outline-none ring-0 placeholder:text-faint focus:outline-none focus-visible:outline-none"
1053 />
1054 <kbd className="rounded border border-line px-1.5 font-mono text-[0.6875rem] text-faint">esc</kbd>
1055 </div>
1056 <ul className="max-h-[50vh] overflow-y-auto p-1.5">
1057 {matches.length === 0 && (
1058 <li className="px-3 py-6 text-center text-sm text-faint">Nothing matches.</li>
1059 )}
1060 {matches.map((command, index) => (
1061 <li key={`${command.to}-${command.label}`}>
1062 <button
1063 type="button"
1064 onMouseEnter={() => setSelected(index)}
1065 onClick={() => go(command)}
1066 className={`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm ${
1067 index === selected ? "bg-line text-fg" : "text-muted"
1068 }`}
1069 >
1070 <span className="shrink-0 text-faint">{command.icon}</span>
1071 <span className="min-w-0 grow truncate">{command.label}</span>
1072 {command.hint && <span className="shrink-0 truncate text-xs text-faint">{command.hint}</span>}
1073 {index === selected && <CornerDownLeft size={13} className="shrink-0 text-faint" />}
1074 </button>
1075 </li>
1076 ))}
1077 </ul>
1078 </div>
1079 </div>
1080 );
1081}
1082
1083/**
1084 * A bar across the top of the page while the next one loads, as GitHub
1085 * has: it appears at once, creeps towards the end while waiting, then fills
1086 * and fades when the page arrives.
1087 */
1088export function Progress() {
1089 const navigation = useNavigation();
1090 const busy = navigation.state !== "idle";
1091 const [width, setWidth] = useState(0);
1092 const [visible, setVisible] = useState(false);
1093 useEffect(() => {
1094 if (busy) {
1095 setVisible(true);
1096 setWidth(12);
1097 // Slows as it goes, never quite arriving until the page does.
1098 const timer = setInterval(() => setWidth((now) => now + (90 - now) * 0.12), 200);
1099 return () => clearInterval(timer);
1100 }
1101 setWidth((now) => (now > 0 ? 100 : 0));
1102 const fade = setTimeout(() => setVisible(false), 250);
1103 const reset = setTimeout(() => setWidth(0), 550);
1104 return () => {
1105 clearTimeout(fade);
1106 clearTimeout(reset);
1107 };
1108 }, [busy]);
1109 return (
1110 <div
1111 aria-hidden="true"
1112 className={`pointer-events-none fixed inset-x-0 top-0 z-[60] h-[3px] transition-opacity duration-300 ${
1113 visible ? "opacity-100" : "opacity-0"
1114 }`}
1115 >
1116 <div
1117 className="h-full bg-accent shadow-[0_0_10px_var(--color-accent)] transition-[width] duration-200 ease-out"
1118 style={{ width: `${width}%` }}
1119 />
1120 </div>
1121 );
1122}
1123
1124/**
1125 * The signed-in app: a sidebar with the workspace, its repositories and the
1126 * sections of the one being looked at; a slim bar with search and the
1127 * account; and the page.
1128 */
1129export function AppShell({
1130 user,
1131 shell,
1132 banner,
1133 children,
1134}: {
1135 user: User;
1136 shell: ShellData;
1137 banner?: ReactNode;
1138 children: ReactNode;
1139}) {
1140 const submit = useSubmit();
1141 const { pathname } = useLocation();
1142 const [drawer, setDrawer] = useState(false);
1143 const [palette, setPalette] = useState(false);
1144 const commands = useMemo(() => commandsFor(user, shell), [user, shell]);
1145
1146 // A new page closes the drawer on small screens.
1147 useEffect(() => setDrawer(false), [pathname]);
1148 useEffect(() => {
1149 const onKey = (event: KeyboardEvent) => {
1150 if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
1151 event.preventDefault();
1152 setPalette((open) => !open);
1153 }
1154 };
1155 window.addEventListener("keydown", onKey);
1156 return () => window.removeEventListener("keydown", onKey);
1157 }, []);
1158
1159 return (
1160 <div className="min-h-screen">
1161 <Progress />
1162 <aside className="fixed inset-y-0 left-0 z-40 hidden w-64 border-r border-line bg-[color-mix(in_srgb,var(--color-surface)_70%,var(--color-bg))] lg:block">
A Vercel-like sidebar and a new mark1163 <Sidebar user={user} shell={shell} onFind={() => setPalette(true)} />
Agents as a team: lifecycle, merge queue, billing and a new shell1164 </aside>
1165 {drawer && (
1166 <div className="fixed inset-0 z-50 lg:hidden">
1167 <button
1168 type="button"
1169 aria-label="Close menu"
1170 className="absolute inset-0 bg-black/60"
1171 onClick={() => setDrawer(false)}
1172 />
1173 <aside className="absolute inset-y-0 left-0 w-72 border-r border-line bg-surface">
1174 <button
1175 type="button"
1176 aria-label="Close menu"
1177 onClick={() => setDrawer(false)}
1178 className="absolute top-3 right-3 rounded-md p-1 text-faint hover:bg-raised hover:text-fg"
1179 >
1180 <X size={16} />
1181 </button>
A Vercel-like sidebar and a new mark1182 <Sidebar user={user} shell={shell} onFind={() => setPalette(true)} />
Agents as a team: lifecycle, merge queue, billing and a new shell1183 </aside>
1184 </div>
1185 )}
1186
Polish: phones, copy boxes, the plan page, the landing page, a real glide1187 <div className="flex min-h-screen min-w-0 flex-col lg:pl-64">
Two limits, real invoices, trust that grows by itself, sales signals1188 <header className="sticky top-0 z-30 flex h-16 items-center gap-3 border-b border-line bg-bg/85 px-4 backdrop-blur sm:px-6">
Agents as a team: lifecycle, merge queue, billing and a new shell1189 <button
1190 type="button"
1191 aria-label="Open menu"
1192 onClick={() => setDrawer(true)}
1193 className="rounded-md p-1.5 text-muted hover:bg-raised hover:text-fg lg:hidden"
1194 >
1195 <Menu size={18} />
1196 </button>
A Vercel-like sidebar and a new mark1197 <Breadcrumbs pathname={pathname} />
Agents as a team: lifecycle, merge queue, billing and a new shell1198 <div className="ml-auto flex items-center gap-1.5">
A Vercel-like sidebar and a new mark1199 <a
1200 href="https://docs.g1t.sh/"
Two limits, real invoices, trust that grows by itself, sales signals1201 className="hidden rounded-md px-2.5 py-1.5 text-sm text-muted transition-colors hover:bg-raised hover:text-fg sm:block"
A Vercel-like sidebar and a new mark1202 >
1203 Docs
1204 </a>
Agents as a team: lifecycle, merge queue, billing and a new shell1205 <DropdownMenu>
1206 <DropdownMenuTrigger
1207 aria-label="Create"
Two limits, real invoices, trust that grows by itself, sales signals1208 className="flex h-9 items-center gap-1.5 rounded-md bg-fg px-3 text-sm font-medium text-bg outline-none transition-colors hover:bg-white"
Agents as a team: lifecycle, merge queue, billing and a new shell1209 >
A Vercel-like sidebar and a new mark1210 <Plus size={14} />
1211 New
Agents as a team: lifecycle, merge queue, billing and a new shell1212 </DropdownMenuTrigger>
1213 <DropdownMenuContent align="end">
1214 {shell.repo && (
1215 <DropdownMenuItem asChild>
1216 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/issues/new`}>
1217 <CircleDot />
1218 New issue
1219 </Link>
1220 </DropdownMenuItem>
1221 )}
1222 {shell.repo?.member && (
1223 <DropdownMenuItem asChild>
1224 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/plans`}>
1225 <ListTree />
1226 Plan work
1227 </Link>
1228 </DropdownMenuItem>
1229 )}
1230 <DropdownMenuItem asChild>
1231 <Link to="/new">
Projects: what a workspace builds and runs, first on every page1232 <Box />
1233 New project
Agents as a team: lifecycle, merge queue, billing and a new shell1234 </Link>
1235 </DropdownMenuItem>
1236 <DropdownMenuItem asChild>
1237 <Link to="/workspaces/new">
1238 <Users />
1239 New workspace
1240 </Link>
1241 </DropdownMenuItem>
1242 </DropdownMenuContent>
1243 </DropdownMenu>
1244 </div>
1245 </header>
1246 {banner}
Polish: phones, copy boxes, the plan page, the landing page, a real glide1247 <main className="min-w-0 grow">{children}</main>
Agents as a team: lifecycle, merge queue, billing and a new shell1248 </div>
1249 <CommandPalette open={palette} onClose={() => setPalette(false)} commands={commands} />
1250 </div>
1251 );
1252}