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