Skip to content

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

1,831 lines74,957 bytesCodeBlame
1import { Activity, BarChart3, Bell, BookMarked, BookOpen, Bot, Box, Brain, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, CircleDot, GripVertical, CircleUserRound, Code2, Compass, CreditCard, Fingerprint, GanttChart, Gauge, GitBranch, GitPullRequest, Globe, History, House, KanbanSquare, KeyRound, LayoutGrid, LifeBuoy, ListTree, Lock, LogIn, LogOut, Mail, Menu, Network, Package, PlayCircle, Plug, Plus, Rocket, Search, ServerCog, Settings, ShieldCheck, Sparkles, Ticket, Users, UsersRound, Webhook, X } from "lucide-react";
2import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
3import { Link, NavLink, useFetcher, useLocation, useNavigation, useRouteLoaderData, useSubmit } from "react-router";
4
5import type { Abilities, InboxCounts, Membership, Spike, User } from "@g1t/contracts";
6
7import { CommandPalette, type PaletteCommand, PaletteKey, usePaletteShortcut } from "./command-palette";
8import { AgentButton, InboxBell } from "./inbox";
9import { PinButton } from "./pin-button";
10import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
11import { Sheet, SheetContent, SheetTitle, SheetTrigger } from "./ui/sheet";
12import { StatusDot, useSiteStatus } from "./footer";
13import { Logo, Mark } from "./logo";
14import { Avatar, SoonPill } from "./ui";
15import { Skeleton } from "./ui/skeleton";
16import {
17 DropdownMenu,
18 DropdownMenuContent,
19 DropdownMenuGroup,
20 DropdownMenuItem,
21 DropdownMenuLabel,
22 DropdownMenuSeparator,
23 DropdownMenuTrigger,
24} from "./ui/dropdown-menu";
25import { type RoadmapItem, roadmapIn } from "../lib/roadmap";
26import { SETTINGS_CAPABILITY, type ViewerAccess, seesSettings } from "../lib/access";
27import { VISITOR_LINKS, projectPages } from "../lib/chrome";
28import { ACCOUNT_SETTINGS, type AccountSettingsPage, FIRST_SETTINGS_PAGE, accountSettingsPage } from "../lib/account-settings";
29import { GithubMark } from "./github";
30import { withNext } from "../lib/next";
31import { useSignUpCopy } from "../lib/registration";
32import { STATUS_URL, statusTitle } from "../lib/status";
33import { type ShortcutProject, movedPin, recentWith } from "../lib/pins";
34import type { AccountMenuData } from "../routes/settings-menu-json";
35
36/**
37 * What the sidebar needs, worked out by the root loader. For a visitor who
38 * is not signed in there is no workspace, no projects and no usage: only
39 * the project being looked at, if they can see it.
40 */
41export type ShellData = {
42 /** The workspace the sidebar is about: the one being looked at, or their first. */
43 workspace: Membership | null;
44 /** All its projects, by name, for the palette: `name` is the slug in their address. */
45 repos: ShortcutProject[];
46 /** The person's pinned projects in it, in their order (lib/pins.ts). */
47 pinned?: ShortcutProject[];
48 /** What they opened there last, latest first, leaving out the pinned. */
49 recent?: ShortcutProject[];
50 /** Repositories shared with them in workspaces they do not belong to. */
51 shared?: { namespace: string; name: string; isPrivate: boolean }[];
52 /** The project being looked at, if any, whoever owns it. */
53 repo: {
54 namespace: string;
55 name: string;
56 member: boolean;
57 issues: number;
58 pulls: number;
59 } | null;
60 /** Where the workspace stands against its usage limit, if billing is on. */
61 limit: {
62 exposureMicros: number;
63 ceilingMicros: number | null;
64 state: "ok" | "warning" | "stopped";
65 comped: boolean;
66 } | null;
67 /** Whether g1t charges nothing for now, while it is being built out. */
68 free?: boolean;
69 /** What its agents have cost since the start of the month. */
70 /** This month's usage: charged, or at cost while g1t is free. */
71 monthUsageMicros: number | null;
72 /** Whether new compute is paused (a spend spike or a hold), and whether the viewer can answer it. */
73 compute?: { paused: string | null; spike: Spike | null; owner: boolean } | null;
74 /** What is unread in their inbox, for the bell. Absent for a visitor. */
75 inbox?: InboxCounts | null;
76};
77
78function SidebarLink({
79 to,
80 icon,
81 end,
82 count,
83 also,
84 drill,
85 children,
86}: {
87 to: string;
88 icon: ReactNode;
89 end?: boolean;
90 count?: number;
91 /** Other path prefixes under which this link is the current one. */
92 also?: string | string[];
93 /** It opens a list of its own: a chevron says so, always or on hover. */
94 drill?: boolean | "hover";
95 children: ReactNode;
96}) {
97 const { pathname } = useLocation();
98 return (
99 <NavLink
100 to={to}
101 end={end}
102 prefetch="intent"
103 className={({ isActive, isPending }) => {
104 const current =
105 isActive || [also ?? []].flat().some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/"));
106 return `group flex h-8 items-center gap-2.5 rounded-md px-2 text-[0.8125rem] transition-colors ${
107 current
108 ? "bg-raised font-medium text-fg"
109 : isPending
110 ? "bg-raised/60 text-fg"
111 : "text-muted hover:bg-raised/60 hover:text-fg"
112 }`;
113 }}
114 >
115 <span className="shrink-0 text-faint group-hover:text-muted">{icon}</span>
116 <span className="min-w-0 grow truncate">{children}</span>
117 {count != null && count > 0 && (
118 <span className="rounded bg-line px-1.5 text-[0.6875rem] tabular-nums text-muted">
119 {count}
120 </span>
121 )}
122 {drill && (
123 <ChevronRight
124 size={14}
125 aria-hidden="true"
126 className={`-mr-0.5 shrink-0 text-faint transition-opacity ${drill === "hover" ? "opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100" : ""}`}
127 />
128 )}
129 </NavLink>
130 );
131}
132
133/**
134 * Something a project will have, shown where it will live so people can
135 * see where g1t is going. Not a link: nothing is behind it yet.
136 */
137function SidebarSoon({ icon, children, about }: { icon: ReactNode; children: ReactNode; about: string }) {
138 return (
139 <div
140 title={about}
141 aria-disabled="true"
142 className="flex h-8 cursor-default items-center gap-2.5 rounded-md px-2 text-[0.8125rem] text-faint"
143 >
144 <span className="shrink-0 opacity-70">{icon}</span>
145 <span className="grow truncate">{children}</span>
146 <SoonPill />
147 </div>
148 );
149}
150
151/**
152 * A page that is coming, as a link to its roadmap page: faint, with Soon,
153 * and marked current on any of its section's Soon pages.
154 */
155function SidebarSoonLink({
156 to,
157 also,
158 icon,
159 about,
160 children,
161}: {
162 to: string;
163 also?: string[];
164 icon: ReactNode;
165 about: string;
166 children: ReactNode;
167}) {
168 const { pathname } = useLocation();
169 return (
170 <NavLink
171 to={to}
172 title={about}
173 prefetch="intent"
174 className={({ isActive }) => {
175 const current = isActive || (also ?? []).some((prefix) => pathname === prefix || pathname.startsWith(prefix + "/"));
176 return `group flex h-8 items-center gap-2.5 rounded-md px-2 text-[0.8125rem] transition-colors ${
177 current ? "bg-raised font-medium text-fg" : "text-faint hover:bg-raised/60 hover:text-muted"
178 }`;
179 }}
180 >
181 <span className="shrink-0 opacity-80">{icon}</span>
182 <span className="min-w-0 grow truncate">{children}</span>
183 <SoonPill />
184 </NavLink>
185 );
186}
187
188/** Icons for what spans projects. */
189const WORKSPACE_ICONS: Record<string, ReactNode> = {
190 board: <KanbanSquare size={15} />,
191 roadmap: <GanttChart size={15} />,
192 teams: <UsersRound size={15} />,
193 packages: <Package size={15} />,
194 fleet: <Bot size={15} />,
195};
196
197/** The Soon pages of a section, as paths, so its link is current on them. */
198function soonPaths(base: string, section: RoadmapItem["section"]): string[] {
199 return roadmapIn(section).map((item) => `${base}/soon/${item.key}`);
200}
201
202function SidebarGroup({
203 title,
204 action,
205 className = "",
206 children,
207}: {
208 title: string;
209 action?: ReactNode;
210 className?: string;
211 children: ReactNode;
212}) {
213 return (
214 <section className={className}>
215 <div className="mb-1 flex h-6 items-center justify-between px-2">
216 <h2 className="text-xs font-medium text-faint">{title}</h2>
217 {action}
218 </div>
219 <div className="space-y-px">{children}</div>
220 </section>
221 );
222}
223
224/** What a workspace is called where people read it: its display name, else its slug. */
225function displayName(membership: Membership): string {
226 return membership.name?.trim() || membership.slug;
227}
228
229function WorkspaceSwitcher({ user, shell }: { user: User; shell: ShellData }) {
230 const workspace = shell.workspace;
231 const current = workspace?.slug;
232 const label = workspace ? displayName(workspace) : "Choose a workspace";
233 return (
234 <DropdownMenu>
235 {/* The name goes to the workspace; only the arrows switch it. The
236 name gets all the room there is, and the whole of it on hover. */}
237 <Link
238 to={current ? `/${current}` : "/workspaces/new"}
239 prefetch="intent"
240 title={workspace ? `${label} · g1t.sh/${workspace.slug}` : undefined}
241 className="flex h-9 min-w-0 grow items-center gap-2 rounded-md px-2 transition-colors hover:bg-raised"
242 >
243 {workspace ? (
244 <Avatar name={workspace.slug} image={workspace.avatar} size={20} square />
245 ) : (
246 <span className="size-5 shrink-0 rounded-md border border-dashed border-line-strong" />
247 )}
248 <span className="min-w-0 truncate text-[0.8125rem] font-medium">{label}</span>
249 </Link>
250 <DropdownMenuTrigger
251 aria-label="Switch workspace"
252 className="flex h-9 w-7 shrink-0 items-center justify-center rounded-md text-faint outline-none transition-colors hover:bg-raised hover:text-fg focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:bg-raised data-[state=open]:text-fg"
253 >
254 <ChevronsUpDown size={14} />
255 </DropdownMenuTrigger>
256 <DropdownMenuContent align="start" className="w-64">
257 {workspace && (
258 <>
259 {/* The workspace's own page: its projects, packages and people. */}
260 <DropdownMenuItem asChild>
261 <Link to={`/${workspace.slug}`}>
262 <LayoutGrid />
263 Workspace overview
264 </Link>
265 </DropdownMenuItem>
266 <DropdownMenuItem asChild>
267 <Link to={`/${workspace.slug}/-/projects`}>
268 <Box />
269 All projects
270 </Link>
271 </DropdownMenuItem>
272 <DropdownMenuSeparator />
273 </>
274 )}
275 <DropdownMenuLabel>Workspaces</DropdownMenuLabel>
276 {(user.workspaces ?? []).map((membership) => (
277 <DropdownMenuItem asChild key={membership.slug}>
278 <Link to={`/${membership.slug}`} title={displayName(membership)}>
279 <Avatar name={membership.slug} image={membership.avatar} size={24} square />
280 <span className="flex min-w-0 grow flex-col leading-tight">
281 <span className="truncate">{displayName(membership)}</span>
282 <span className="truncate font-mono text-[0.6875rem] text-faint">{membership.slug}</span>
283 </span>
284 <span className="shrink-0 text-[0.6875rem] text-faint capitalize">{membership.role}</span>
285 {membership.slug === current ? (
286 <Check className="shrink-0 text-accent" />
287 ) : (
288 <span className="size-4 shrink-0" aria-hidden="true" />
289 )}
290 </Link>
291 </DropdownMenuItem>
292 ))}
293 <DropdownMenuSeparator />
294 <DropdownMenuItem asChild>
295 <Link to="/workspaces/new">
296 <Plus />
297 New workspace
298 </Link>
299 </DropdownMenuItem>
300 </DropdownMenuContent>
301 </DropdownMenu>
302 );
303}
304
305/**
306 * The fine print, as one quiet row at the foot of the account menu and the
307 * visitor's panel: each link a full-height target, left-aligned. In the
308 * menu each is a menu item, so the arrow keys reach it.
309 */
310const LEGAL_LINKS: [string, string][] = [
311 ["Policies", "/policies"],
312 ["Privacy", "/policies/privacy"],
313 ["Security", "/security"],
314];
315const LEGAL_LINK = "flex h-7 items-center rounded px-1.5 text-xs text-faint outline-none transition-colors";
316
317function MenuLegalRow() {
318 return (
319 <div role="group" aria-label="Legal" className="flex items-center gap-0.5 px-0.5 pt-0.5">
320 {LEGAL_LINKS.map(([label, to], index) => (
321 <span key={to} className="flex items-center gap-0.5">
322 {index > 0 && (
323 <span aria-hidden="true" className="text-[0.625rem] text-line-strong">
324 ·
325 </span>
326 )}
327 <DropdownMenuItem asChild className={`${LEGAL_LINK} py-0 data-highlighted:bg-line data-highlighted:text-fg`}>
328 <Link to={to}>{label}</Link>
329 </DropdownMenuItem>
330 </span>
331 ))}
332 </div>
333 );
334}
335
336/** Status's row: the live dot and two or three words, fetched when the menu opens. */
337function StatusSummary({ open }: { open: boolean }) {
338 const status = useSiteStatus(open);
339 const words = statusTitle(status);
340 return (
341 <span className="ml-auto flex min-w-0 items-center gap-1.5 pl-2 text-xs text-faint">
342 {/* The words say it; the dot's own words for screen readers would repeat them. */}
343 <span aria-hidden="true" className="flex">
344 <StatusDot state={status?.overall.state ?? null} />
345 </span>
346 {words ? <span className="truncate">{words}</span> : <Skeleton className="h-3 w-20" />}
347 </span>
348 );
349}
350
351/** A menu row: an icon, words, and whatever sits at its end. */
352const MENU_ROW = "h-9 gap-2.5 px-2.5 text-[0.8125rem]";
353
354function AccountMenu({ user }: { user: User }) {
355 const submit = useSubmit();
356 const [open, setOpen] = useState(false);
357 // Name, primary address and invites left: asked for once, as soon as the
358 // pointer or focus reaches the button, so they are there when it opens.
359 const details = useFetcher<AccountMenuData | null>({ key: "account-menu" });
360 const prefetch = () => {
361 if (details.state === "idle" && details.data === undefined) details.load("/settings/menu.json");
362 };
363 useEffect(() => {
364 if (open) prefetch();
365 // eslint-disable-next-line react-hooks/exhaustive-deps
366 }, [open]);
367 const me = details.data ?? null;
368 // Still on its way: shapes where the words will be, the same size.
369 const loading = details.data === undefined && details.state !== "idle";
370 const profile = `/u/${user.username}`;
371 return (
372 <DropdownMenu open={open} onOpenChange={setOpen}>
373 <DropdownMenuTrigger
374 aria-label={`Account menu for ${user.username}`}
375 onPointerEnter={prefetch}
376 onFocus={prefetch}
377 className="flex h-10 w-full items-center gap-2.5 rounded-md px-2 text-left outline-none transition-colors hover:bg-raised focus-visible:ring-2 focus-visible:ring-merged/60 data-[state=open]:bg-raised"
378 >
379 <Avatar name={user.username} image={user.avatar} size={22} />
380 <span className="min-w-0 grow truncate text-[0.8125rem] font-medium">{user.username}</span>
381 <ChevronsUpDown size={14} className="shrink-0 text-faint" />
382 </DropdownMenuTrigger>
383 <DropdownMenuContent align="start" side="top" collisionPadding={8} className="w-[17.5rem] p-1.5">
384 {/* Who is signed in, and a way to their profile. */}
385 <DropdownMenuItem asChild className="gap-3 px-2 py-2">
386 <Link to={profile} aria-label={`${me?.name ?? user.username} (@${user.username}), your profile`}>
387 <Avatar name={user.username} image={user.avatar} size={36} />
388 <span className="flex min-w-0 grow flex-col leading-tight" aria-busy={loading}>
389 {loading ? (
390 <Skeleton className="my-[0.1875rem] h-3.5 w-28" />
391 ) : (
392 <span className="truncate text-sm font-medium text-fg">{me?.name ?? user.username}</span>
393 )}
394 <span className="truncate font-mono text-xs text-muted">@{user.username}</span>
395 {loading ? (
396 <Skeleton className="mt-1 h-3 w-40" />
397 ) : (
398 me?.email && <span className="mt-0.5 truncate text-xs text-faint">{me.email}</span>
399 )}
400 </span>
401 </Link>
402 </DropdownMenuItem>
403 <DropdownMenuSeparator className="my-1.5" />
404 <DropdownMenuGroup>
405 <DropdownMenuItem asChild className={MENU_ROW}>
406 <Link to={profile}>
407 <CircleUserRound />
408 Your profile
409 </Link>
410 </DropdownMenuItem>
411 <DropdownMenuItem asChild className={MENU_ROW}>
412 <Link to={FIRST_SETTINGS_PAGE}>
413 <Settings />
414 Your settings
415 </Link>
416 </DropdownMenuItem>
417 <DropdownMenuItem asChild className={MENU_ROW}>
418 <Link to="/settings/invites">
419 <Ticket />
420 Invites
421 {loading && <Skeleton className="ml-auto h-4 w-12 rounded-full" />}
422 {me?.invites_left != null && (
423 <span className="ml-auto rounded-full bg-line px-1.5 text-[0.6875rem] tabular-nums text-muted">
424 {me.invites_left} left
425 </span>
426 )}
427 </Link>
428 </DropdownMenuItem>
429 </DropdownMenuGroup>
430 <DropdownMenuSeparator className="my-1.5" />
431 <DropdownMenuGroup>
432 <DropdownMenuItem asChild className={MENU_ROW}>
433 <a href="https://docs.g1t.sh/">
434 <BookOpen />
435 Documentation
436 </a>
437 </DropdownMenuItem>
438 <DropdownMenuItem asChild className={MENU_ROW}>
439 <Link to="/support">
440 <LifeBuoy />
441 Support
442 </Link>
443 </DropdownMenuItem>
444 <DropdownMenuItem asChild className={MENU_ROW}>
445 <a href={STATUS_URL}>
446 <Activity />
447 Status
448 <StatusSummary open={open} />
449 </a>
450 </DropdownMenuItem>
451 </DropdownMenuGroup>
452 <DropdownMenuSeparator className="my-1.5" />
453 {/* Submitted from here: the menu closes on select, and a button
454 that has left the page cannot submit a form. */}
455 <DropdownMenuItem className={MENU_ROW} onSelect={() => submit(null, { method: "post", action: "/logout" })}>
456 <LogOut />
457 Sign out
458 </DropdownMenuItem>
459 <DropdownMenuSeparator className="my-1.5" />
460 <MenuLegalRow />
461 </DropdownMenuContent>
462 </DropdownMenu>
463 );
464}
465
466/**
467 * A workspace's settings pages, which the sidebar drills into: how it is
468 * set up and connected (guardrails, secrets, runners, integrations,
469 * webhooks), what it pays, its repositories, tokens and record. The main
470 * list keeps the places work happens and who belongs; every member can
471 * still open these.
472 */
473const SETTINGS_PAGE =
474 /^\/([^/]+)\/-\/(settings|repositories|tokens|guardrails|secrets|runners|integrations|webhooks|billing|audit)(\/|$)/;
475/** A project's settings pages, which the project's menu drills into. */
476const REPO_SETTINGS_PAGE = /^\/([^/]+)\/([^/-][^/]*)\/settings(\/|$)/;
477
478/**
479 * The sidebar's lists are a stack, the way a phone pushes a screen: one
480 * drilled into slides in from the right over the full width, while the one
481 * it covers drifts a quarter of the way left and fades, both on one long
482 * ease-out, the fade quicker than the move so the two never blur together.
483 * Going back reverses it.
484 */
485const LAYER =
486 "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";
487/** One list, filling its layer. */
488const PANEL = "h-full overflow-y-auto px-2 pb-4";
489
490/** One list in the stack: what it is, and its rows. */
491type Level = { key: string; node: ReactNode };
492
493/** True once the page has hydrated, so what the server drew never animates in. */
494function useHydrated(): boolean {
495 const [hydrated, setHydrated] = useState(false);
496 useEffect(() => setHydrated(true), []);
497 return hydrated;
498}
499
500/**
501 * Drilling in and out of the sidebar's lists. `trail` is the way from the
502 * main list to the one shown, worked out from the address, so a link
503 * straight to a settings page opens the sidebar already drilled in, and
504 * leaving it comes back out. Lists deeper than the one shown stay in
505 * place, off to the right, so going back slides them away rather than
506 * dropping them. Moving to a list at the same depth (a workspace's settings
507 * to a project) fades the new one in where it is.
508 */
509function Drill({ trail }: { trail: Level[] }) {
510 const depth = trail.length - 1;
511 const hydrated = useHydrated();
512 const stack = useRef<Level[]>(trail);
513 const before = stack.current;
514 const within = trail.every((level, index) => before[index]?.key === level.key);
515 stack.current = within ? [...trail, ...before.slice(trail.length)] : trail;
516 const levels = stack.current;
517 // What was showing last time, to tell drilling in from moving across.
518 const shown = useRef({ depth, keys: levels.map((level) => level.key) });
519 useEffect(() => {
520 shown.current = { depth, keys: levels.map((level) => level.key) };
521 });
522 return (
523 <div className="relative min-h-0 grow overflow-hidden">
524 {levels.map((level, index) => {
525 const current = index === depth;
526 const place =
527 index < depth
528 ? "pointer-events-none -translate-x-1/4 opacity-0"
529 : current
530 ? "translate-x-0 opacity-100"
531 : "pointer-events-none translate-x-full opacity-0";
532 // A list that was not there before arrives: from the right when
533 // drilling in, in place when moving across.
534 const arriving = hydrated && current && !shown.current.keys.includes(level.key);
535 const enter = arriving
536 ? depth > shown.current.depth
537 ? "starting:translate-x-full starting:opacity-0"
538 : "starting:opacity-0"
539 : "";
540 return (
541 <div key={level.key} className={`${LAYER} ${place} ${enter}`} inert={!current} aria-hidden={!current || undefined}>
542 {level.node}
543 </div>
544 );
545 })}
546 </div>
547 );
548}
549
550/**
551 * The row at the top of a list drilled into: the list's name, which goes
552 * back out, and what it belongs to, faint at the end.
553 */
554function BackRow({ to, label, context }: { to: string; label: ReactNode; context?: ReactNode }) {
555 return (
556 <Link
557 to={to}
558 prefetch="intent"
559 className="group mt-3 flex h-8 items-center gap-1.5 rounded-md pr-2 pl-1 text-[0.8125rem] font-medium text-fg transition-colors hover:bg-raised/60"
560 >
561 <ChevronLeft size={16} className="shrink-0 text-faint transition-transform group-hover:-translate-x-0.5 group-hover:text-muted" />
562 <span className="min-w-0 shrink-0 truncate">{label}</span>
563 {context && (
564 <span className="ml-auto min-w-0 truncate pl-2 font-mono text-[0.6875rem] font-normal text-faint">{context}</span>
565 )}
566 </Link>
567 );
568}
569
570/** A thin rule between groups of a list. */
571function Rule() {
572 return <div role="separator" className="mx-2 my-2.5 h-px bg-line" />;
573}
574
575/** A quiet heading inside a group: Pinned, Recent. */
576function SidebarSubhead({ children }: { children: ReactNode }) {
577 return <h3 className="px-2 pt-1.5 pb-0.5 text-[0.6875rem] font-medium tracking-wide text-faint">{children}</h3>;
578}
579
580/**
581 * The workspace's projects as the sidebar keeps them, however many there
582 * are: the person's pins in their order, what they opened last, and the
583 * way to all of them. Pins move by dragging, or with Alt and the arrow
584 * keys; the projects service keeps the order.
585 */
586function SidebarProjects({ slug, shell }: { slug: string; shell: ShellData }) {
587 const reorder = useFetcher({ key: `pins:${slug}` });
588 const saved = shell.pinned ?? [];
589 // While a new order is on its way, it shows as made.
590 const asked = reorder.formData?.get("intent") === "reorder" ? reorder.formData.getAll("slug").map(String) : null;
591 const pinned = asked
592 ? asked.map((name) => saved.find((project) => project.name === name)).filter((project): project is ShortcutProject => project != null)
593 : saved;
594 const active = shell.repo ? { namespace: shell.repo.namespace, name: shell.repo.name, isPrivate: false } : null;
595 const recent = recentWith(shell.recent ?? [], pinned, active, slug);
596 const [dragging, setDragging] = useState<number | null>(null);
597 const move = (from: number, by: number) => {
598 const next = movedPin(pinned, from, by);
599 if (!next) return;
600 const form = new FormData();
601 form.set("intent", "reorder");
602 for (const project of next) form.append("slug", project.name);
603 reorder.submit(form, { method: "post", action: `/${slug}/-/pins` });
604 };
605 // Each row pins or unpins in place: the pin shows on hover or focus, and
606 // stays shown on a pinned row's hover so it reads as "unpin".
607 const row = (project: ShortcutProject, isPinned: boolean) => (
608 <div className="group/row relative">
609 <SidebarLink to={`/${project.namespace}/${project.name}`} icon={project.isPrivate ? <Lock size={15} /> : <Box size={15} />} drill="hover">
610 <span className="block truncate pr-6">{project.title ?? project.name}</span>
611 </SidebarLink>
612 <PinButton
613 workspace={slug}
614 slug={project.name}
615 name={project.title ?? project.name}
616 pinned={isPinned}
617 small
618 className="absolute top-1/2 right-6 -translate-y-1/2 opacity-0 transition-opacity group-hover/row:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100"
619 />
620 </div>
621 );
622 return (
623 <SidebarGroup
624 title="Projects"
625 action={
626 <Link to={`/new?workspace=${slug}`} aria-label="New project" className="rounded p-0.5 text-faint hover:bg-raised hover:text-fg">
627 <Plus size={13} />
628 </Link>
629 }
630 >
631 {/* Only there once something is pinned: each row below has its own pin. */}
632 {pinned.length > 0 && (
633 <>
634 <SidebarSubhead>Pinned</SidebarSubhead>
635 <ul aria-label="Pinned projects" className="space-y-px">
636 {pinned.map((project, index) => (
637 <li
638 key={project.name}
639 draggable={pinned.length > 1}
640 onDragStart={(event) => {
641 setDragging(index);
642 event.dataTransfer.effectAllowed = "move";
643 }}
644 onDragOver={(event) => {
645 if (dragging != null) event.preventDefault();
646 }}
647 onDrop={(event) => {
648 event.preventDefault();
649 if (dragging != null && dragging !== index) move(dragging, index - dragging);
650 setDragging(null);
651 }}
652 onDragEnd={() => setDragging(null)}
653 onKeyDown={(event) => {
654 if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
655 event.preventDefault();
656 move(index, event.key === "ArrowUp" ? -1 : 1);
657 }}
658 title={pinned.length > 1 ? "Drag, or Alt and an arrow key, to reorder" : undefined}
659 className={`group/pin relative ${dragging === index ? "opacity-50" : ""}`}
660 >
661 {row(project, true)}
662 {pinned.length > 1 && (
663 <GripVertical
664 size={12}
665 aria-hidden="true"
666 className="pointer-events-none absolute top-1/2 -left-1.5 -translate-y-1/2 text-faint opacity-0 transition-opacity group-hover/pin:opacity-100"
667 />
668 )}
669 </li>
670 ))}
671 </ul>
672 </>
673 )}
674 {recent.length > 0 && (
675 <>
676 <SidebarSubhead>Recent</SidebarSubhead>
677 {recent.map((project) => (
678 <div key={`${project.namespace}/${project.name}`}>{row(project, false)}</div>
679 ))}
680 </>
681 )}
682 <div className="pt-1">
683 <SidebarLink to={`/${slug}/-/projects`} icon={<LayoutGrid size={15} />} count={shell.repos.length}>
684 All projects
685 </SidebarLink>
686 </div>
687 </SidebarGroup>
688 );
689}
690
691/**
692 * The main list: where you go, the projects, what the workspace builds and
693 * runs with across them, then its usage, support and settings.
694 */
695function MainMenu({ user, shell }: { user: User | null; shell: ShellData }) {
696 const ws = shell.workspace;
697 // A visitor browses: no workspace, no projects of their own.
698 if (!user) {
699 return (
700 <nav aria-label="g1t" className={PANEL}>
701 <div className="mt-3 space-y-px">
702 {VISITOR_LINKS.map((link) => (
703 <SidebarLink key={link.to} to={link.to} icon={link.to === "/search" ? <Search size={15} /> : <Compass size={15} />}>
704 {link.label}
705 </SidebarLink>
706 ))}
707 </div>
708 </nav>
709 );
710 }
711 return (
712 <nav aria-label="g1t" className={PANEL}>
713 {/* Everything here is the workspace the switcher names: its home first.
714 The workspace's own page is the switcher's; Explore, all of g1t,
715 is in the top bar. */}
716 <div className="mt-3 space-y-px">
717 <SidebarLink to="/" end icon={<House size={15} />}>
718 Mission control
719 </SidebarLink>
720 </div>
721
722 <Rule />
723 {ws ? (
724 <SidebarProjects slug={ws.slug} shell={shell} />
725 ) : (
726 <SidebarGroup title="Projects">
727 <p className="px-2 py-1 text-xs text-faint">None yet.</p>
728 </SidebarGroup>
729 )}
730 {(shell.shared ?? []).length > 0 && (
731 <SidebarGroup title="Shared with you" className="mt-3">
732 {(shell.shared ?? []).map((repo) => (
733 <SidebarLink
734 key={`${repo.namespace}/${repo.name}`}
735 to={`/${repo.namespace}/${repo.name}`}
736 icon={repo.isPrivate ? <Lock size={15} /> : <Box size={15} />}
737 drill="hover"
738 >
739 <span className="font-mono text-faint">{repo.namespace}/</span>
740 {repo.name}
741 </SidebarLink>
742 ))}
743 </SidebarGroup>
744 )}
745
746 {ws && (
747 <>
748 <Rule />
749 <SidebarGroup title="Workspace">
750 <SidebarLink to={`/${ws.slug}/-/agents`} icon={<Bot size={15} />}>
751 Agent fleet
752 </SidebarLink>
753 <SidebarLink to={`/${ws.slug}/-/context`} icon={<Network size={15} />}>
754 Context
755 </SidebarLink>
756 <SidebarLink to={`/${ws.slug}/-/memory`} icon={<Brain size={15} />}>
757 Memory
758 </SidebarLink>
759 <SidebarLink to={`/${ws.slug}/-/security`} icon={<ShieldCheck size={15} />}>
760 Security
761 </SidebarLink>
762 <SidebarLink to={`/${ws.slug}/-/packages`} icon={<Package size={15} />}>
763 Packages
764 </SidebarLink>
765 {roadmapIn("Workspace").filter((item) => item.key !== "insights").map((item) => (
766 <SidebarSoonLink
767 key={item.key}
768 to={`/${ws.slug}/-/soon/${item.key}`}
769 icon={WORKSPACE_ICONS[item.key] ?? <Sparkles size={15} />}
770 about={item.summary}
771 >
772 {item.title === "Board" ? "Boards" : item.title}
773 </SidebarSoonLink>
774 ))}
775 </SidebarGroup>
776
777 <Rule />
778 <div className="space-y-px">
779 {/* Who belongs, for every member to see; owners invite and manage there. */}
780 <SidebarLink to={`/${ws.slug}/-/people`} icon={<Users size={15} />}>
781 People
782 </SidebarLink>
783 <SidebarLink to={`/${ws.slug}/-/teams`} icon={WORKSPACE_ICONS.teams}>
784 Teams
785 </SidebarLink>
786 <SidebarLink to={`/${ws.slug}/-/usage`} icon={<BarChart3 size={15} />}>
787 Usage
788 </SidebarLink>
789 <SidebarLink to="/support" icon={<LifeBuoy size={15} />}>
790 Support
791 </SidebarLink>
792 {/* How it is set up and connected, what it pays and its record: a list of their own. */}
793 <SidebarLink
794 to={ws.role === "owner" ? `/${ws.slug}/-/settings` : `/${ws.slug}/-/repositories`}
795 icon={<Settings size={15} />}
796 drill
797 >
798 Settings
799 </SidebarLink>
800 </div>
801 </>
802 )}
803 </nav>
804 );
805}
806
807/** A workspace's settings, drilled into from Settings in the main list. */
808function SettingsMenu({ slug, owner }: { slug: string; owner: boolean }) {
809 return (
810 <nav aria-label="Workspace settings" className={PANEL}>
811 <BackRow to={`/${slug}`} label="Settings" context={slug} />
812 <div className="mt-2 space-y-px">
813 {owner && (
814 <SidebarLink to={`/${slug}/-/settings`} icon={<Settings size={15} />}>
815 General
816 </SidebarLink>
817 )}
818 <SidebarLink to={`/${slug}/-/repositories`} icon={<BookMarked size={15} />}>
819 Repositories
820 </SidebarLink>
821 <SidebarLink to={`/${slug}/-/tokens`} icon={<KeyRound size={15} />}>
822 Access tokens
823 </SidebarLink>
824 </div>
825 <SidebarGroup title="Agents and runs" className="mt-3">
826 <SidebarLink to={`/${slug}/-/guardrails`} icon={<Gauge size={15} />}>
827 Guardrails
828 </SidebarLink>
829 <SidebarLink to={`/${slug}/-/secrets`} icon={<Lock size={15} />}>
830 Secrets and variables
831 </SidebarLink>
832 {owner && (
833 <SidebarLink to={`/${slug}/-/runners`} icon={<ServerCog size={15} />}>
834 Runners
835 </SidebarLink>
836 )}
837 </SidebarGroup>
838 <SidebarGroup title="Connections" className="mt-3">
839 <SidebarLink to={`/${slug}/-/integrations`} icon={<Plug size={15} />}>
840 Integrations
841 </SidebarLink>
842 <SidebarLink to={`/${slug}/-/webhooks`} icon={<Webhook size={15} />}>
843 Webhooks
844 </SidebarLink>
845 </SidebarGroup>
846 <Rule />
847 <div className="space-y-px">
848 <SidebarLink to={`/${slug}/-/billing`} icon={<CreditCard size={15} />}>
849 Billing and plans
850 </SidebarLink>
851 <SidebarLink to={`/${slug}/-/audit`} icon={<History size={15} />}>
852 Audit log
853 </SidebarLink>
854 </div>
855 </nav>
856 );
857}
858
859/**
860 * What the repository menu needs. Known from the address before the page's
861 * data arrives, so the menu is right from the first frame; the counts fill
862 * in once it does.
863 */
864type MenuRepo = {
865 namespace: string;
866 name: string;
867 member: boolean;
868 /** Whether they see its settings; from the repository's page once it loads. */
869 settings?: boolean;
870 /** What they may do there, once the repository's page loads. */
871 can?: Abilities;
872 issues?: number;
873 pulls?: number;
874};
875
876function sameRepo(a: { namespace: string; name: string } | null, b: { namespace: string; name: string } | null) {
877 return (
878 a != null &&
879 b != null &&
880 a.namespace.toLowerCase() === b.namespace.toLowerCase() &&
881 a.name.toLowerCase() === b.name.toLowerCase()
882 );
883}
884
885/**
886 * A project's own list, drilled into while you are in it: everything about
887 * the project, running and its code, and nothing else, with the way back
888 * out to all of them.
889 */
890function RepoMenu({
891 repo,
892 isPrivate,
893 back,
894}: {
895 repo: MenuRepo;
896 isPrivate: boolean;
897 /** Where the way back leads: the workspace's projects, mission control, or Explore. */
898 back: { to: string; label: string };
899}) {
900 const base = `/${repo.namespace}/${repo.name}`;
901 // What a member sees, and what everyone who can see the project does.
902 const shows = new Set(projectPages(repo.member, repo.can));
903 return (
904 <nav aria-label={`${repo.namespace}/${repo.name}`} className={PANEL}>
905 <BackRow to={back.to} label={back.label} />
906 <NavLink
907 to={base}
908 end
909 prefetch="intent"
910 title="Overview"
911 className={({ isActive }) =>
912 `mt-2 flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors ${isActive ? "bg-raised" : "hover:bg-raised/60"}`
913 }
914 >
915 <span className="flex size-6 shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line">
916 {isPrivate ? <Lock size={13} /> : <Box size={13} />}
917 </span>
918 <span className="min-w-0 truncate font-mono text-[0.8125rem]">
919 <span className="text-faint">{repo.namespace}/</span>
920 <span className="font-semibold text-fg">{repo.name}</span>
921 </span>
922 </NavLink>
923 {/* A project's pages, in the order people use them. A page with more
924 than one view shows them as tabs across its top. */}
925 <Rule />
926 <div className="space-y-px">
927 <SidebarLink to={`${base}/code`} also={[`${base}/tree`, `${base}/blob`, `${base}/commits`, `${base}/commit`, `${base}/branches`, `${base}/tags`, `${base}/compare`, ...soonPaths(base, "Code")]} icon={<Code2 size={15} />}>
928 Code
929 </SidebarLink>
930 <SidebarLink to={`${base}/issues`} also={[`${base}/plans`, `${base}/milestones`, `${base}/labels`, ...soonPaths(base, "Issues")]} icon={<CircleDot size={15} />} count={repo.issues}>
931 Issues
932 </SidebarLink>
933 <SidebarLink to={`${base}/pulls`} also={[`${base}/pull`, `${base}/queue`]} icon={<GitPullRequest size={15} />} count={repo.pulls}>
934 Pull requests
935 </SidebarLink>
936 <SidebarLink to={`${base}/agents`} also={[`${base}/sessions`, `${base}/memory`, ...soonPaths(base, "Agents")]} icon={<Bot size={15} />}>
937 Agents
938 </SidebarLink>
939 <SidebarLink to={`${base}/actions`} icon={<PlayCircle size={15} />}>
940 Workflows
941 </SidebarLink>
942 </div>
943 <Rule />
944 <div className="space-y-px">
945 {shows.has("deployments") ? (
946 <SidebarLink to={`${base}/deployments`} also={soonPaths(base, "Deployments")} icon={<Rocket size={15} />}>
947 Deployments
948 </SidebarLink>
949 ) : null}
950 <SidebarSoonLink to={`${base}/soon/logs`} also={soonPaths(base, "Observability")} icon={<Activity size={15} />} about="Logs, errors, uptime and analytics of the project's deployed apps.">
951 Observability
952 </SidebarSoonLink>
953 {shows.has("security") ? (
954 <SidebarLink to={`${base}/security`} also={soonPaths(base, "Security")} icon={<ShieldCheck size={15} />}>
955 Security
956 </SidebarLink>
957 ) : null}
958 <SidebarSoonLink to={`${base}/soon/delivery`} also={soonPaths(base, "Insights")} icon={<BarChart3 size={15} />} about="Delivery metrics, costs and the work agents do.">
959 Insights
960 </SidebarSoonLink>
961 </div>
962 {(repo.settings ?? shows.has("settings")) && (
963 <>
964 <Rule />
965 <SidebarLink to={`${base}/settings`} icon={<Settings size={15} />} drill>
966 Settings
967 </SidebarLink>
968 </>
969 )}
970 </nav>
971 );
972}
973
974/**
975 * A project's settings, drilled into from its list: what is about running
976 * it, then its agents, then its code and who can reach it. The way back
977 * leads to the project.
978 */
979function RepoSettingsMenu({ repo }: { repo: MenuRepo }) {
980 const base = `/${repo.namespace}/${repo.name}`;
981 // Each page shows to the roles that can use it, once the role is known.
982 const shows = (page: string) => !repo.can || repo.can[SETTINGS_CAPABILITY[page] ?? "administer"];
983 const running = shows("deployments");
984 const agents = shows("agents") || shows("guardrails");
985 return (
986 <nav aria-label={`${repo.namespace}/${repo.name} settings`} className={PANEL}>
987 <BackRow to={base} label="Settings" context={`${repo.namespace}/${repo.name}`} />
988 {shows("") && (
989 <div className="mt-2 space-y-px">
990 <SidebarLink to={`${base}/settings`} end icon={<Settings size={15} />}>
991 General
992 </SidebarLink>
993 </div>
994 )}
995 {running && (
996 <>
997 {shows("") && <Rule />}
998 <div className={shows("") ? "space-y-px" : "mt-2 space-y-px"}>
999 <SidebarLink to={`${base}/settings/deployments`} icon={<Rocket size={15} />}>
1000 Deployments
1001 </SidebarLink>
1002 <SidebarLink to={`${base}/settings/domains`} icon={<Globe size={15} />}>
1003 Domains
1004 </SidebarLink>
1005 <SidebarLink to={`${base}/settings/dependencies`} icon={<Network size={15} />}>
1006 Dependencies
1007 </SidebarLink>
1008 </div>
1009 </>
1010 )}
1011 {agents && (
1012 <>
1013 <Rule />
1014 <div className="space-y-px">
1015 {shows("agents") && (
1016 <SidebarLink to={`${base}/settings/agents`} icon={<Bot size={15} />}>
1017 Agents
1018 </SidebarLink>
1019 )}
1020 {shows("guardrails") && (
1021 <SidebarLink to={`${base}/settings/guardrails`} icon={<ShieldCheck size={15} />}>
1022 Guardrails
1023 </SidebarLink>
1024 )}
1025 </div>
1026 </>
1027 )}
1028 <Rule />
1029 <div className="space-y-px">
1030 {shows("repository") && (
1031 <SidebarLink to={`${base}/settings/repository`} icon={<BookMarked size={15} />}>
1032 Repository
1033 </SidebarLink>
1034 )}
1035 {shows("access") && (
1036 <SidebarLink to={`${base}/settings/access`} icon={<Users size={15} />}>
1037 Access
1038 </SidebarLink>
1039 )}
1040 {shows("branches") && (
1041 <SidebarLink to={`${base}/settings/branches`} icon={<GitBranch size={15} />}>
1042 Branches and merging
1043 </SidebarLink>
1044 )}
1045 {shows("secrets") && (
1046 <SidebarLink to={`${base}/settings/secrets`} icon={<Lock size={15} />}>
1047 Secrets and variables
1048 </SidebarLink>
1049 )}
1050 {shows("runners") && (
1051 <SidebarLink to={`${base}/settings/runners`} icon={<ServerCog size={15} />}>
1052 Runners
1053 </SidebarLink>
1054 )}
1055 {shows("webhooks") && (
1056 <SidebarLink to={`${base}/settings/webhooks`} icon={<Webhook size={15} />}>
1057 Webhooks
1058 </SidebarLink>
1059 )}
1060 </div>
1061 </nav>
1062 );
1063}
1064
1065/** Your own settings, drilled into from Your settings: one page each. */
1066function AccountSettingsMenu({ username }: { username: string }) {
1067 const link = (page: AccountSettingsPage, icon: ReactNode) => (
1068 <SidebarLink to={`/settings/${page}`} icon={icon}>
1069 {ACCOUNT_SETTINGS[page].title}
1070 </SidebarLink>
1071 );
1072 return (
1073 <nav aria-label="Your settings" className={PANEL}>
1074 <BackRow to="/" label="Your settings" context={username} />
1075 <div className="mt-2 space-y-px">
1076 {link("profile", <CircleUserRound size={15} />)}
1077 {link("emails", <Mail size={15} />)}
1078 {link("invites", <Ticket size={15} />)}
1079 </div>
1080 <Rule />
1081 <div className="space-y-px">
1082 {link("keys", <Fingerprint size={15} />)}
1083 {link("tokens", <KeyRound size={15} />)}
1084 </div>
1085 <Rule />
1086 <div className="space-y-px">
1087 {link("github", <GithubMark className="size-[15px]" />)}
1088 {link("applications", <Plug size={15} />)}
1089 </div>
1090 <Rule />
1091 <div className="space-y-px">
1092 {link("security-log", <History size={15} />)}
1093 </div>
1094 </nav>
1095 );
1096}
1097
1098/**
1099 * Signing in and signing up, in place of the account for a visitor. Signing
1100 * in brings them back to the page they are on.
1101 */
1102/** Help, status and the fine print under a visitor's sign-in buttons. */
1103function VisitorLinks() {
1104 const status = useSiteStatus();
1105 const quiet = `${LEGAL_LINK} hover:bg-raised hover:text-fg focus-visible:ring-2 focus-visible:ring-merged/60`;
1106 const dot = (
1107 <span aria-hidden="true" className="text-[0.625rem] text-line-strong">
1108 ·
1109 </span>
1110 );
1111 return (
1112 // Two short rows, so a narrow sidebar never starts a line with a dot.
1113 <nav aria-label="About g1t" className="pt-0.5">
1114 <div className="flex items-center gap-0.5">
1115 <a href={STATUS_URL} className={`${quiet} gap-1.5`}>
1116 <StatusDot state={status?.overall.state ?? null} />
1117 Status
1118 </a>
1119 {dot}
1120 <Link to="/support" className={quiet}>
1121 Support
1122 </Link>
1123 </div>
1124 <div className="flex items-center gap-0.5">
1125 {LEGAL_LINKS.map(([label, to], index) => (
1126 <span key={to} className="flex items-center gap-0.5">
1127 {index > 0 && dot}
1128 <Link to={to} className={quiet}>
1129 {label}
1130 </Link>
1131 </span>
1132 ))}
1133 </div>
1134 </nav>
1135 );
1136}
1137
1138function VisitorPanel() {
1139 const { pathname, search } = useLocation();
1140 const signUp = useSignUpCopy();
1141 return (
1142 <div className="space-y-2">
1143 <p className="px-1 text-xs text-muted">Sign in to open issues, review pull requests and run agents.</p>
1144 <div className="grid grid-cols-2 gap-2">
1145 <Link
1146 to={withNext("/login", pathname + search)}
1147 className="flex h-9 items-center justify-center gap-1.5 rounded-md border border-line text-[0.8125rem] font-medium text-fg/90 transition-colors hover:border-line-strong hover:bg-raised hover:text-fg"
1148 >
1149 <LogIn size={14} />
1150 Sign in
1151 </Link>
1152 <Link
1153 to={withNext("/register", pathname + search)}
1154 className="flex h-9 items-center justify-center rounded-md bg-fg text-[0.8125rem] font-medium text-bg transition-colors hover:bg-white"
1155 >
1156 {signUp.primary}
1157 </Link>
1158 </div>
1159 <VisitorLinks />
1160 </div>
1161 );
1162}
1163
1164function Sidebar({
1165 user,
1166 shell,
1167 missing = false,
1168 onFind,
1169 onClose,
1170}: {
1171 user: User | null;
1172 shell: ShellData;
1173 /** The page is a 404: the address names nothing the viewer can see. */
1174 missing?: boolean;
1175 onFind: () => void;
1176 /** In the sheet on a small screen: closing it, at the end of the top row. */
1177 onClose?: () => void;
1178}) {
1179 const ws = shell.workspace;
1180 const { pathname } = useLocation();
1181 const going = useNavigation().location?.pathname;
1182 // Where the sidebar is drilled to follows the page being gone to, so it
1183 // moves as the link is followed, not once the page arrives.
1184 const target = going ?? pathname;
1185 // On a 404, the address is not a place: no list is drilled into from it,
1186 // except the project's own when the project is real and visible and only
1187 // something inside it is missing (a file, a commit, an issue).
1188 const lost = missing && going == null;
1189 const inSettings = !lost && ws != null && SETTINGS_PAGE.exec(target)?.[1]?.toLowerCase() === ws.slug;
1190 const inAccount = !lost && target === "/settings" || target.startsWith("/settings/");
1191 const active = shell.repo;
1192 // In a repository, or on the way into one, its own list.
1193 const repoPath = /^\/([^/]+)\/([^/-][^/]*)(\/|$)/.exec(target);
1194 const reserved = new Set(["settings", "explore", "search", "new", "u", "pricing", "avatars", "workspaces", "login", "logout", "register", "verify", "forgot", "reset", "device", "oauth", "policies", "security", "support", "status", "invite", "inbox", ".well-known"]);
1195 // An invitation to a repository is answered before its menu means anything.
1196 const inRepo =
1197 repoPath != null &&
1198 !reserved.has(repoPath[1]) &&
1199 repoPath[2] !== "-" &&
1200 !/^\/[^/]+\/[^/]+\/invitations\/?$/.test(target) &&
1201 (!lost || sameRepo(active, { namespace: repoPath[1]!, name: repoPath[2]! }));
1202 // A project's settings, one level further in.
1203 const inRepoSettings = inRepo && REPO_SETTINGS_PAGE.test(target);
1204 // The repository the menu is for: the one loaded if it is the one being
1205 // gone to, else what the address says, at once.
1206 const targetRepo = inRepo && repoPath ? { namespace: repoPath[1], name: repoPath[2] } : null;
1207 const guessed: MenuRepo | null = targetRepo
1208 ? sameRepo(active, targetRepo)
1209 ? active
1210 : {
1211 ...targetRepo,
1212 member: (user?.workspaces ?? []).some((m) => m.slug === targetRepo.namespace.toLowerCase()),
1213 }
1214 : null;
1215 // The viewer's role there, from the repository's page once it has loaded.
1216 const page = useRouteLoaderData("routes/repo/layout") as
1217 | { repo?: { namespace: string; name: string }; access?: ViewerAccess }
1218 | undefined;
1219 const menuRepo: MenuRepo | null =
1220 guessed && page?.access && page.repo && sameRepo(page.repo, guessed)
1221 ? { ...guessed, member: page.access.insider, settings: seesSettings(page.access), can: page.access.can }
1222 : guessed;
1223
1224 // The way from the main list to the one shown.
1225 const trail: Level[] = [{ key: "main", node: <MainMenu user={user} shell={shell} /> }];
1226 if (user && inAccount) {
1227 trail.push({ key: "account", node: <AccountSettingsMenu username={user.username} /> });
1228 } else if (ws && inSettings) {
1229 trail.push({ key: `settings:${ws.slug}`, node: <SettingsMenu slug={ws.slug} owner={ws.role === "owner"} /> });
1230 } else if (menuRepo) {
1231 const key = `repo:${menuRepo.namespace}/${menuRepo.name}`.toLowerCase();
1232 // Out of a project: to its workspace's projects when they are yours.
1233 const home = (user?.workspaces ?? []).find((m) => m.slug === menuRepo.namespace.toLowerCase());
1234 const back = !user
1235 ? { to: "/explore", label: "Explore" }
1236 : home
1237 ? { to: `/${home.slug}/-/projects`, label: "All projects" }
1238 : { to: "/", label: "Mission control" };
1239 trail.push({
1240 key,
1241 node: (
1242 <RepoMenu
1243 repo={menuRepo}
1244 isPrivate={[...shell.repos, ...(shell.shared ?? [])].some((repo) => sameRepo(repo, menuRepo) && repo.isPrivate)}
1245 back={back}
1246 />
1247 ),
1248 });
1249 if (inRepoSettings) trail.push({ key: `${key}:settings`, node: <RepoSettingsMenu repo={menuRepo} /> });
1250 }
1251
1252 return (
1253 <div className="flex h-full flex-col">
1254 {/* The same height and rule as the top bar, so the two read as one line. */}
1255 <div className="flex h-14 shrink-0 items-center gap-1 border-b border-line pr-2 pl-2.5">
1256 {user ? (
1257 <>
1258 {/* The 1 alone beside the workspace: a square hover the height of the
1259 switcher, the mark as tall as the workspace avatar. */}
1260 <Link to="/" aria-label="g1t home" className="flex size-9 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-raised">
1261 <Mark tight className="h-4 w-auto" />
1262 </Link>
1263 <span className="shrink-0 text-line-strong" aria-hidden="true">
1264 /
1265 </span>
1266 <WorkspaceSwitcher user={user} shell={shell} />
1267 </>
1268 ) : (
1269 <Link to="/" aria-label="g1t home" className="mr-auto flex h-9 items-center rounded-md px-2 transition-colors hover:bg-raised">
1270 <Logo className="text-[1.25rem]" />
1271 </Link>
1272 )}
1273 {onClose && (
1274 <button
1275 type="button"
1276 aria-label="Close menu"
1277 onClick={onClose}
1278 className="flex size-9 shrink-0 items-center justify-center rounded-md text-faint hover:bg-raised hover:text-fg"
1279 >
1280 <X size={16} />
1281 </button>
1282 )}
1283 </div>
1284 <div className="px-2 pt-3">
1285 <button
1286 type="button"
1287 onClick={onFind}
1288 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"
1289 >
1290 <Search size={14} />
1291 <span className="grow text-left">Search or jump to…</span>
1292 <PaletteKey className="rounded bg-raised px-1.5 font-mono text-[0.625rem] text-muted ring-1 ring-line" />
1293 </button>
1294 </div>
1295 <Drill trail={trail} />
1296 {/* The account, or signing in, as one row at the very bottom. */}
1297 <div className="shrink-0 border-t border-line p-2">
1298 {user ? <AccountMenu user={user} /> : <VisitorPanel />}
1299 </div>
1300 </div>
1301 );
1302}
1303
1304/** Words for the sections a path can end in. */
1305const SECTIONS: Record<string, string> = {
1306 issues: "Issues",
1307 milestones: "Milestones",
1308 labels: "Labels",
1309 pulls: "Pull requests",
1310 queue: "Merge queue",
1311 commits: "Commits",
1312 plans: "Outcomes",
1313 actions: "Workflows",
1314 soon: "Soon",
1315 deployments: "Deployments",
1316 repository: "Repository",
1317 access: "Access",
1318 invitations: "Invitation",
1319 repositories: "Repositories",
1320 branches: "Branches",
1321 tags: "Tags",
1322 compare: "Compare",
1323 dependencies: "Dependencies",
1324 code: "Files",
1325 secrets: "Secrets and variables",
1326 settings: "Settings",
1327 people: "People",
1328 projects: "Projects",
1329 teams: "Teams",
1330 tokens: "Access tokens",
1331 usage: "Usage",
1332 billing: "Billing and plans",
1333 integrations: "Integrations",
1334 webhooks: "Webhooks",
1335 domains: "Domains",
1336 guardrails: "Guardrails",
1337 audit: "Audit log",
1338 tree: "Files",
1339 blob: "Files",
1340 agents: "Agents",
1341 context: "Context",
1342 memory: "Memory",
1343 security: "Security",
1344 packages: "Packages",
1345 runners: "Runners",
1346 workflows: "Workflows",
1347 observability: "Observability",
1348 insights: "Insights",
1349 sessions: "Sessions",
1350};
1351
1352/** Where the page is, as a trail of links: workspace / repository / section. */
1353function Breadcrumbs({ pathname, missing, repo }: { pathname: string; missing?: boolean; repo?: ShellData["repo"] }) {
1354 // A 404 names nothing from the address, unless the project is real and
1355 // visible and only something inside it is missing.
1356 const visibleRepo = /^\/([^/]+)\/([^/-][^/]*)(\/|$)/.exec(pathname);
1357 if (missing && !(visibleRepo && sameRepo(repo ?? null, { namespace: visibleRepo[1]!, name: visibleRepo[2]! }))) {
1358 return <span className="text-sm font-medium">Not found</span>;
1359 }
1360 const parts = pathname.split("/").filter(Boolean);
1361 const reserved = ["settings", "explore", "new", "search", "workspaces", "policies", "security", "support", "status", "invite", "inbox"];
1362 if (parts.length === 0) return <span className="text-sm font-medium">Mission control</span>;
1363 // Your settings: Settings / Emails.
1364 if (parts[0] === "settings") {
1365 const page = accountSettingsPage(pathname);
1366 return <Trail trail={[{ label: "Settings", to: FIRST_SETTINGS_PAGE }, ...(page ? [{ label: ACCOUNT_SETTINGS[page].title, to: `/settings/${page}` }] : [])]} />;
1367 }
1368 if (reserved.includes(parts[0]!)) {
1369 const words: Record<string, string> = {
1370 settings: "Account",
1371 explore: "Explore",
1372 new: "New project",
1373 search: "Search",
1374 workspaces: "New workspace",
1375 policies: "Policies",
1376 security: "Security",
1377 support: "Support",
1378 status: "Status",
1379 invite: "Invite",
1380 inbox: "Inbox",
1381 };
1382 return <span className="text-sm font-medium">{words[parts[0]!]}</span>;
1383 }
1384 // A person's profile, by their handle.
1385 if (parts[0] === "u" && parts[1]) {
1386 return <span className="truncate font-mono text-[0.8125rem] font-medium">@{parts[1]}</span>;
1387 }
1388 const [owner, second, third, fourth] = parts;
1389 const trail: Crumb[] = [{ label: owner!, to: `/${owner}`, mono: true }];
1390 if (second === "-") {
1391 const page = `/${owner}/-/${third}`;
1392 if (third && SETTINGS_PAGE.test(page)) {
1393 trail.push({ label: "Settings", to: `/${owner}/-/settings` });
1394 trail.push({ label: third === "settings" ? "General" : (SECTIONS[third] ?? third), to: page });
1395 } else if (third) trail.push({ label: SECTIONS[third] ?? third, to: page });
1396 } else if (second) {
1397 const repo = `/${owner}/${second}`;
1398 trail.push({ label: second, to: repo, mono: true });
1399 if (third === "pull" && fourth) trail.push({ label: `Pull request #${fourth}`, short: `#${fourth}`, to: `${repo}/pull/${fourth}` });
1400 else if (third === "issues" && fourth && fourth !== "new") trail.push({ label: `Issue #${fourth}`, short: `#${fourth}`, to: `${repo}/issues/${fourth}` });
1401 else if (third === "commit" && fourth) trail.push({ label: fourth.slice(0, 7), to: `${repo}/commit/${fourth}`, mono: true });
1402 else if (third && SECTIONS[third]) {
1403 trail.push({ label: SECTIONS[third]!, to: `${repo}/${third}` });
1404 // A settings page names which one: Settings / Secrets and variables.
1405 if (third === "settings" && fourth && SECTIONS[fourth]) {
1406 trail.push({ label: fourth === "branches" ? "Branches and merging" : SECTIONS[fourth]!, to: `${repo}/settings/${fourth}` });
1407 }
1408 }
1409 }
1410 return <Trail trail={trail} />;
1411}
1412
1413/** One link of the trail; `short` is what a phone shows when it is the page itself. */
1414type Crumb = { label: string; to: string; mono?: boolean; short?: string };
1415
1416/**
1417 * The trail of links. On a phone there is room for one: the page itself,
1418 * with a way back to where it sits; the whole trail from a wider screen up.
1419 */
1420function Trail({ trail }: { trail: Crumb[] }) {
1421 const up = trail.length > 1 ? trail[trail.length - 2]! : null;
1422 return (
1423 <nav aria-label="Where you are" className="flex min-w-0 items-center gap-1.5 text-sm">
1424 {up && (
1425 <Link
1426 to={up.to}
1427 prefetch="intent"
1428 aria-label={`Back to ${up.label}`}
1429 className="-ml-1 flex size-8 shrink-0 items-center justify-center rounded-md text-muted transition-colors hover:bg-raised hover:text-fg sm:hidden"
1430 >
1431 <ChevronLeft size={16} />
1432 </Link>
1433 )}
1434 {trail.map((crumb, index) => {
1435 const last = index === trail.length - 1;
1436 return (
1437 <span key={index} className={`min-w-0 items-center gap-1.5 ${last ? "flex" : "hidden sm:flex"}`}>
1438 {index > 0 && <span className="hidden text-line-strong sm:inline">/</span>}
1439 <Link
1440 to={crumb.to}
1441 prefetch="intent"
1442 aria-current={last ? "page" : undefined}
1443 className={`truncate rounded px-1 py-0.5 transition-colors hover:bg-raised ${
1444 last ? "font-medium text-fg" : "text-muted hover:text-fg"
1445 } ${crumb.mono ? "font-mono text-[0.8125rem]" : ""}`}
1446 >
1447 {last && crumb.short ? (
1448 <>
1449 <span className="sm:hidden">{crumb.short}</span>
1450 <span className="hidden sm:inline">{crumb.label}</span>
1451 </>
1452 ) : (
1453 crumb.label
1454 )}
1455 </Link>
1456 </span>
1457 );
1458 })}
1459 </nav>
1460 );
1461}
1462
1463type Command = PaletteCommand;
1464
1465/** Everything the palette can jump to, from what the sidebar already knows. */
1466function commandsFor(user: User | null, shell: ShellData, here: string, signUpLabel = "Sign up"): Command[] {
1467 if (!user) return visitorCommands(shell, here, signUpLabel);
1468 const commands: Command[] = [
1469 { label: "Mission control", to: "/", icon: <House size={15} /> },
1470 ...(shell.repos.length > 0
1471 ? [{ label: "Put an agent on it", hint: "Open an issue and assign g1t", to: "/?agent=new", icon: <Sparkles size={15} /> }]
1472 : []),
1473 { label: "Explore repositories", to: "/explore", icon: <Compass size={15} /> },
1474 { label: "Search g1t", hint: "Repositories, code, issues, people", to: "/search", icon: <Search size={15} /> },
1475 { label: "Inbox", hint: "What needs you", to: "/inbox", icon: <Bell size={15} /> },
1476 { label: "New project", to: "/new", icon: <Plus size={15} /> },
1477 { label: "New workspace", to: "/workspaces/new", icon: <Plus size={15} /> },
1478 { label: "Your settings", to: FIRST_SETTINGS_PAGE, icon: <Settings size={15} /> },
1479 ...(Object.keys(ACCOUNT_SETTINGS) as AccountSettingsPage[])
1480 .filter((page) => page !== "profile")
1481 .map((page) => ({ label: ACCOUNT_SETTINGS[page].title, hint: "Your settings", to: `/settings/${page}`, icon: <Settings size={15} /> })),
1482 ];
1483 const repo = shell.repo;
1484 if (repo) {
1485 const base = `/${repo.namespace}/${repo.name}`;
1486 const name = `${repo.namespace}/${repo.name}`;
1487 commands.unshift(
1488 { label: "Overview", hint: name, to: base, icon: <LayoutGrid size={15} /> },
1489 { label: "Code", hint: name, to: `${base}/code`, icon: <Code2 size={15} /> },
1490 { label: "Issues", hint: name, to: `${base}/issues`, icon: <CircleDot size={15} /> },
1491 { label: "New issue", hint: name, to: `${base}/issues/new`, icon: <Plus size={15} /> },
1492 ...(repo.member
1493 ? [{ label: `Put an agent on ${repo.name}`, hint: name, to: `${base}/issues/new?agent=1`, icon: <Sparkles size={15} /> }]
1494 : []),
1495 { label: "Pull requests", hint: name, to: `${base}/pulls`, icon: <GitPullRequest size={15} /> },
1496 { label: "Commits", hint: name, to: `${base}/commits`, icon: <History size={15} /> },
1497 ...(repo.member
1498 ? [
1499 { label: "Plan work", hint: name, to: `${base}/plans`, icon: <ListTree size={15} /> },
1500 { label: "Deployments", hint: name, to: `${base}/deployments`, icon: <Rocket size={15} /> },
1501 { label: "Secrets and variables", hint: name, to: `${base}/settings/secrets`, icon: <Lock size={15} /> },
1502 { label: "Project settings", hint: name, to: `${base}/settings`, icon: <Settings size={15} /> },
1503 { label: "Repository settings", hint: name, to: `${base}/settings/repository`, icon: <Settings size={15} /> },
1504 ]
1505 : []),
1506 );
1507 }
1508 for (const membership of user.workspaces ?? []) {
1509 commands.push(
1510 { label: displayName(membership), hint: `Workspace · ${membership.slug}`, to: `/${membership.slug}`, icon: <Avatar name={membership.slug} image={membership.avatar} size={15} square /> },
1511 { label: "All projects", hint: membership.slug, to: `/${membership.slug}/-/projects`, icon: <LayoutGrid size={15} /> },
1512 { label: "People", hint: membership.slug, to: `/${membership.slug}/-/people`, icon: <Users size={15} /> },
1513 { label: "Usage", hint: membership.slug, to: `/${membership.slug}/-/usage`, icon: <BarChart3 size={15} /> },
1514 { label: "Billing and plans", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/billing`, icon: <CreditCard size={15} /> },
1515 { label: "Access tokens", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/tokens`, icon: <KeyRound size={15} /> },
1516 { label: "Integrations", hint: membership.slug, to: `/${membership.slug}/-/integrations`, icon: <Plug size={15} /> },
1517 );
1518 }
1519 for (const listed of shell.repos) {
1520 commands.push({
1521 label: listed.title ?? listed.name,
1522 hint: `${listed.namespace} · Project`,
1523 to: `/${listed.namespace}/${listed.name}`,
1524 icon: <Box size={15} />,
1525 });
1526 }
1527 // "Put an agent on …": one per project, after the projects themselves.
1528 for (const listed of shell.repos) {
1529 if (repo && listed.namespace === repo.namespace && listed.name === repo.name) continue;
1530 commands.push({
1531 label: `Put an agent on ${listed.title ?? listed.name}`,
1532 hint: `${listed.namespace}/${listed.name}`,
1533 to: `/${listed.namespace}/${listed.name}/issues/new?agent=1`,
1534 icon: <Sparkles size={15} />,
1535 });
1536 }
1537 return commands;
1538}
1539
1540/** What the palette offers a visitor: browsing, the project they are in, and signing in. */
1541function visitorCommands(shell: ShellData, here: string, signUpLabel: string): Command[] {
1542 const commands: Command[] = [];
1543 const repo = shell.repo;
1544 if (repo) {
1545 const base = `/${repo.namespace}/${repo.name}`;
1546 const name = `${repo.namespace}/${repo.name}`;
1547 commands.push(
1548 { label: "Overview", hint: name, to: base, icon: <LayoutGrid size={15} /> },
1549 { label: "Code", hint: name, to: `${base}/code`, icon: <Code2 size={15} /> },
1550 { label: "Issues", hint: name, to: `${base}/issues`, icon: <CircleDot size={15} /> },
1551 { label: "Pull requests", hint: name, to: `${base}/pulls`, icon: <GitPullRequest size={15} /> },
1552 { label: "Commits", hint: name, to: `${base}/commits`, icon: <History size={15} /> },
1553 );
1554 }
1555 commands.push(
1556 { label: "Explore", hint: "Public projects", to: "/explore", icon: <Compass size={15} /> },
1557 { label: "Search g1t", hint: "Repositories, code, issues, people", to: "/search", icon: <Search size={15} /> },
1558 { label: "Pricing", to: "/pricing", icon: <CreditCard size={15} /> },
1559 { label: "Documentation", to: "https://docs.g1t.sh/", icon: <BookOpen size={15} /> },
1560 { label: "Sign in", to: withNext("/login", here), icon: <LogIn size={15} /> },
1561 { label: signUpLabel, to: withNext("/register", here), icon: <Plus size={15} /> },
1562 );
1563 return commands;
1564}
1565
1566/**
1567 * The page while the next one loads: after a moment it dims, under the
1568 * bar below, so it is plainly on its way out rather than frozen, and the
1569 * next page fades up from there. Sending a form does not dim it: the
1570 * form's button says it is working. Spread on the element holding the page.
1571 */
1572export function useLeaving() {
1573 const navigation = useNavigation();
1574 const method = navigation.formMethod?.toUpperCase();
1575 const leaving = navigation.state === "loading" && (method == null || method === "GET");
1576 return {
1577 "aria-busy": leaving || undefined,
1578 className: `transition-opacity motion-reduce:transition-none ${leaving ? "opacity-60 delay-200 duration-300" : "duration-150"}`,
1579 };
1580}
1581
1582/**
1583 * A bar across the top of the page while the next one loads, as GitHub
1584 * has: it appears at once, creeps towards the end while waiting, then fills
1585 * and fades when the page arrives.
1586 */
1587export function Progress() {
1588 const navigation = useNavigation();
1589 const busy = navigation.state !== "idle";
1590 const [width, setWidth] = useState(0);
1591 const [visible, setVisible] = useState(false);
1592 useEffect(() => {
1593 if (busy) {
1594 setVisible(true);
1595 setWidth(12);
1596 // Slows as it goes, never quite arriving until the page does.
1597 const timer = setInterval(() => setWidth((now) => now + (90 - now) * 0.12), 200);
1598 return () => clearInterval(timer);
1599 }
1600 setWidth((now) => (now > 0 ? 100 : 0));
1601 const fade = setTimeout(() => setVisible(false), 250);
1602 const reset = setTimeout(() => setWidth(0), 550);
1603 return () => {
1604 clearTimeout(fade);
1605 clearTimeout(reset);
1606 };
1607 }, [busy]);
1608 return (
1609 <div
1610 aria-hidden="true"
1611 className={`pointer-events-none fixed inset-x-0 top-0 z-[60] h-[3px] transition-opacity duration-300 ${
1612 visible ? "opacity-100" : "opacity-0"
1613 }`}
1614 >
1615 <div
1616 className="h-full bg-accent shadow-[0_0_10px_var(--color-accent)] transition-[width] duration-200 ease-out"
1617 style={{ width: `${width}%` }}
1618 />
1619 </div>
1620 );
1621}
1622
1623/**
1624 * The app: a sidebar with the workspace, its repositories and the sections
1625 * of the one being looked at; a slim bar with search and the account; and
1626 * the page. A visitor who is not signed in gets the same frame, with
1627 * Explore and Search in place of the workspace, and signing in in place of
1628 * the account.
1629 */
1630export function AppShell({
1631 user,
1632 shell,
1633 missing = false,
1634 banner,
1635 children,
1636}: {
1637 user: User | null;
1638 shell: ShellData;
1639 /** The page is a 404 (see Sidebar). */
1640 missing?: boolean;
1641 banner?: ReactNode;
1642 children: ReactNode;
1643}) {
1644 const { pathname, search } = useLocation();
1645 const [drawer, setDrawer] = useState(false);
1646 const [palette, setPalette] = useState(false);
1647 const here = pathname + search;
1648 const signUpLabel = useSignUpCopy().primary;
1649 const commands = useMemo(() => commandsFor(user, shell, here, signUpLabel), [user, shell, here, signUpLabel]);
1650
1651 // A new page closes the drawer on small screens.
1652 useEffect(() => setDrawer(false), [pathname]);
1653 // Mission control's code, fetched while the browser is idle, so going
1654 // home never waits on it (routes/home.tsx).
1655 useEffect(() => {
1656 if (!user) return;
1657 const load = () => void import("./mission-control").catch(() => undefined);
1658 const idle = (window as { requestIdleCallback?: (callback: () => void) => number }).requestIdleCallback;
1659 if (idle) idle(load);
1660 else setTimeout(load, 1500);
1661 }, [user]);
1662 usePaletteShortcut(() => setPalette((open) => !open));
1663 const leaving = useLeaving();
1664
1665 return (
1666 // The phone's menu is a sheet: a dialog that holds focus, closes on
1667 // Escape or a tap outside, and gives focus back to the menu button.
1668 <Sheet open={drawer} onOpenChange={setDrawer}>
1669 <div className="min-h-screen">
1670 <Progress />
1671 <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">
1672 <Sidebar user={user} shell={shell} missing={missing} onFind={() => setPalette(true)} />
1673 </aside>
1674 <SheetContent side="left" showClose={false} aria-describedby={undefined} className="w-72 max-w-[85vw] sm:max-w-72 lg:hidden">
1675 <SheetTitle className="sr-only">Menu</SheetTitle>
1676 <Sidebar
1677 user={user}
1678 shell={shell}
1679 missing={missing}
1680 onFind={() => {
1681 setDrawer(false);
1682 setPalette(true);
1683 }}
1684 onClose={() => setDrawer(false)}
1685 />
1686 </SheetContent>
1687
1688 <div className="flex min-h-screen min-w-0 flex-col lg:pl-64">
1689 <header className="sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-line bg-bg/85 px-4 backdrop-blur sm:px-6">
1690 <SheetTrigger
1691 aria-label="Open menu"
1692 className="rounded-md p-1.5 text-muted hover:bg-raised hover:text-fg lg:hidden"
1693 >
1694 <Menu size={18} />
1695 </SheetTrigger>
1696 <Breadcrumbs pathname={pathname} missing={missing} repo={shell.repo} />
1697 <div className="ml-auto flex items-center gap-1.5">
1698 {/* Search lives in the sidebar ("Search or jump to"); with the sidebar folded away, this opens the same palette. */}
1699 <button
1700 type="button"
1701 aria-label="Search or jump to"
1702 onClick={() => setPalette(true)}
1703 className="flex size-9 items-center justify-center rounded-md text-muted transition-colors hover:bg-raised hover:text-fg lg:hidden"
1704 >
1705 <Search size={16} />
1706 </button>
1707 {/* All of g1t's public projects: not any one workspace's, so here, not in the sidebar. */}
1708 <NavLink
1709 to="/explore"
1710 prefetch="intent"
1711 aria-label="Explore"
1712 className={({ isActive }) =>
1713 `flex h-9 items-center gap-1.5 rounded-md px-2 text-sm transition-colors hover:bg-raised hover:text-fg sm:px-2.5 ${isActive ? "text-fg" : "text-muted"}`
1714 }
1715 >
1716 <Compass size={16} className="sm:hidden" />
1717 <span className="hidden sm:inline">Explore</span>
1718 </NavLink>
1719 <a
1720 href="https://docs.g1t.sh/"
1721 className="hidden rounded-md px-2.5 py-1.5 text-sm text-muted transition-colors hover:bg-raised hover:text-fg sm:block"
1722 >
1723 Docs
1724 </a>
1725 {user && (
1726 <>
1727 <AgentButton />
1728 <InboxBell counts={shell.inbox ?? null} />
1729 </>
1730 )}
1731 {!user ? (
1732 // The sidebar has these too, but on a phone it is folded away.
1733 <Link
1734 to={withNext("/login", here)}
1735 className="flex h-9 items-center rounded-md bg-fg px-3 text-sm font-medium text-bg transition-colors hover:bg-white lg:hidden"
1736 >
1737 Sign in
1738 </Link>
1739 ) : (
1740 <>
1741 {/* Room between what comes in (the inbox) and what you make. */}
1742 <span aria-hidden="true" className="mx-1 h-5 w-px bg-line" />
1743 <DropdownMenu>
1744 <Tooltip>
1745 <TooltipTrigger asChild>
1746 <DropdownMenuTrigger
1747 aria-label="Create new"
1748 className="flex h-9 items-center gap-1 rounded-md border border-line px-2 text-fg/90 outline-none transition-colors hover:border-line-strong hover:bg-raised hover:text-fg focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:bg-raised"
1749 >
1750 <Plus size={16} />
1751 <ChevronDown size={13} className="text-muted" />
1752 </DropdownMenuTrigger>
1753 </TooltipTrigger>
1754 <TooltipContent>Create new…</TooltipContent>
1755 </Tooltip>
1756 <DropdownMenuContent align="end" className="min-w-52">
1757 {shell.repo && (
1758 <>
1759 <DropdownMenuLabel className="truncate">In {shell.repo.name}</DropdownMenuLabel>
1760 <DropdownMenuItem asChild>
1761 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/issues/new`}>
1762 <CircleDot />
1763 New issue
1764 </Link>
1765 </DropdownMenuItem>
1766 {shell.repo.member && (
1767 <DropdownMenuItem asChild>
1768 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/plans`}>
1769 <ListTree />
1770 Plan work
1771 </Link>
1772 </DropdownMenuItem>
1773 )}
1774 <DropdownMenuSeparator />
1775 </>
1776 )}
1777 <DropdownMenuItem asChild>
1778 <Link to="/?agent=new">
1779 <Sparkles />
1780 Put an agent on it
1781 </Link>
1782 </DropdownMenuItem>
1783 <DropdownMenuItem asChild>
1784 <Link to="/new">
1785 <Box />
1786 New project
1787 </Link>
1788 </DropdownMenuItem>
1789 <DropdownMenuItem asChild>
1790 <Link to="/new/github">
1791 <GitBranch />
1792 Import from GitHub
1793 </Link>
1794 </DropdownMenuItem>
1795 <DropdownMenuSeparator />
1796 <DropdownMenuItem asChild>
1797 <Link to="/workspaces/new">
1798 <Users />
1799 New workspace
1800 </Link>
1801 </DropdownMenuItem>
1802 {/* A team in the workspace the sidebar is about. */}
1803 {shell.workspace && (
1804 <DropdownMenuItem asChild>
1805 <Link to={`/${shell.workspace.slug}/-/teams/new`}>
1806 <UsersRound />
1807 New team
1808 </Link>
1809 </DropdownMenuItem>
1810 )}
1811 </DropdownMenuContent>
1812 </DropdownMenu>
1813 </>
1814 )}
1815 </div>
1816 </header>
1817 {banner}
1818 <main id="content" tabIndex={-1} {...leaving} className={`min-w-0 grow outline-none ${leaving.className}`}>
1819 {children}
1820 </main>
1821 </div>
1822 <CommandPalette
1823 open={palette}
1824 onOpenChange={setPalette}
1825 commands={commands}
1826 repo={shell.repo ? `${shell.repo.namespace}/${shell.repo.name}` : null}
1827 />
1828 </div>
1829 </Sheet>
1830 );
1831}