Skip to content

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

g1t.sh
2,234 linesCodeBlameRaw
1import { Activity, BarChart3, Building2, MessagesSquare, Bell, BookMarked, BookOpen, Bookmark, Blocks, Bot, Box, Check, ChevronDown, ChevronLeft, ChevronRight, CircleDot, GripVertical, CircleUserRound, Code2, Coins, Compass, CreditCard, Fingerprint, GanttChart, Gauge, GitBranch, GitPullRequest, Globe, History, KanbanSquare, Keyboard, KeyRound, Layers, LayoutDashboard, LayoutGrid, LifeBuoy, ListTree, Lock, LogOut, Mail, MonitorCog, MonitorDown, Network, Package, PlayCircle, Plug, Plus, Rocket, Search, ServerCog, Settings, Shapes, Shield, ShieldCheck, Scale, Smile, Sparkles, SlidersHorizontal, House, Ticket, TrendingUp, UserRoundKey, Users, UsersRound, Webhook, X } from "lucide-react";
2import { Fragment, type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react";
3import { Link, useFetcher, useLocation, useNavigation, useRouteLoaderData, useSubmit } from "react-router";
4
5import { type Abilities, type ChatSidebarEntry, type InboxCounts, type WorkspaceAgent, type Membership, type Spike, type User, hasCodeAccess, mayCreateTeams, shownUsername } from "@g1t/contracts";
6
7import { InMain } from "./landmark";
8import { CommandPalette, type PaletteCommand, PaletteKey, usePaletteShortcut } from "./command-palette";
9import { NotificationsBell } from "./inbox";
10import { desktopBridge, useDesktopApp, useTitleBarSearch } from "../lib/notify-client";
11import { SpendPill } from "./spend";
12import { PinButton } from "./pin-button";
13import { Hint } from "./ui/hint";
14import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible";
15import {
16 Sidebar,
17 SidebarGroup,
18 SidebarGroupAction,
19 SidebarGroupContent,
20 SidebarGroupLabel,
21 SidebarHeader,
22 SidebarMenu,
23 SidebarMenuBadge,
24 SidebarMenuButton,
25 SidebarMenuItem,
26 SidebarMobile,
27 SidebarProvider,
28 SidebarSeparator,
29 SidebarTrigger,
30} from "./ui/sidebar";
31import { StatusDot, useSiteStatus } from "./footer";
32import { Logo, MarkGlyph } from "./logo";
33import { SoonPill } from "./ui";
34import { Avatar } from "./ui/avatar";
35import { Skeleton } from "./ui/skeleton";
36import { Button } from "./ui/button";
37import { Separator } from "./ui/separator";
38import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "./ui/breadcrumb";
39import {
40 DropdownMenu,
41 DropdownMenuContent,
42 DropdownMenuGroup,
43 DropdownMenuItem,
44 DropdownMenuLabel,
45 DropdownMenuSeparator,
46 DropdownMenuTrigger,
47} from "./ui/dropdown-menu";
48import { type RoadmapItem, roadmapIn, roadmapItem } from "../lib/roadmap";
49import { type ModeKey, WORKSPACE_SETTINGS_GROUPS, type WorkspaceSettingsPage, homePagePath, modeOf, workspaceSettingsPage } from "../lib/workspace-nav";
50import { AgentsSidebar } from "./agents-mode";
51import { ChatSidebar } from "./chat/sidebar";
52import { FoliosSidebar } from "./folios/sidebar";
53import { Rail, ShortcutsDialog, WorkspaceSwitcher, sidebarKeyLabel } from "./rail";
54import { BottomBar, isConversation, useVisualViewport } from "./mobile";
55import { useChatSidebar } from "./chat/actions";
56import { unreadTotals } from "../lib/chat";
57import { SETTINGS_CAPABILITY, type ViewerAccess, seesSettings } from "../lib/access";
58import { projectPages } from "../lib/chrome";
59import { ACCOUNT_SETTINGS, type AccountSettingsPage, FIRST_SETTINGS_PAGE, accountSettingsPage } from "../lib/account-settings";
60import { type PinnableApp, sidebarCookie } from "../lib/apps";
61import { REASON_FILTERS, inboxReason, inboxView } from "../lib/inbox";
62import { GithubMark } from "./github";
63import { useInviteOnly } from "../lib/registration";
64import { STATUS_URL, statusTitle } from "../lib/status";
65import { type ShortcutProject, movedPin, recentWith } from "../lib/pins";
66import type { AccountMenuData } from "../routes/settings-menu-json";
67import { useLiveBadges } from "../lib/notify-client";
68import { OwnPresenceDot, OwnPresenceItems, StatusDialog } from "./presence";
69import { THEME_COMMANDS, ThemeMenuSwitch } from "./theme-switch";
70
71/**
72 * What the sidebar needs, worked out by the root loader. For a visitor who
73 * is not signed in there is no workspace, no projects and no usage: only
74 * the project being looked at, if they can see it.
75 */
76export type ShellData = {
77 /** The workspace the sidebar is about: the one being looked at, or their first. */
78 workspace: Membership | null;
79 /** All its projects, by name, for the palette: `name` is the slug in their address. */
80 repos: ShortcutProject[];
81 /** The person's pinned projects in it, in their order (lib/pins.ts). */
82 pinned?: ShortcutProject[];
83 /** What they opened there last, latest first, leaving out the pinned. */
84 recent?: ShortcutProject[];
85 /** Repositories shared with them in workspaces they do not belong to. */
86 shared?: { namespace: string; name: string; isPrivate: boolean }[];
87 /** The project being looked at, if any, whoever owns it. */
88 repo: {
89 namespace: string;
90 name: string;
91 member: boolean;
92 issues: number;
93 pulls: number;
94 } | null;
95 /** Where the workspace stands against its usage limit, if billing is on. */
96 limit: {
97 exposureMicros: number;
98 ceilingMicros: number | null;
99 state: "ok" | "warning" | "stopped";
100 comped: boolean;
101 } | null;
102 /** Whether g1t charges nothing for now, while it is being built out. */
103 free?: boolean;
104 /** What its agents have cost since the start of the month. */
105 /** This month's usage: charged, or at cost while g1t is free. */
106 monthUsageMicros: number | null;
107 /** Whether new compute is paused (a spend spike or a hold), and whether the viewer can answer it. */
108 compute?: { paused: string | null; spike: Spike | null; owner: boolean } | null;
109 /** What is unread in their notifications, for the rail and the bell. Absent for a visitor. */
110 inbox?: InboxCounts | null;
111 /**
112 * Chat, for the rail's badge: what is unread, and the
113 * starred and latest conversations. Null when chat did not answer in time.
114 */
115 chat?: { unread: number; mentions: number; starred?: ChatSidebarEntry[]; recent?: ChatSidebarEntry[] } | null;
116 /** The workspace's agents, g1t first, for the Agents sidebar; null when not known. */
117 agents?: ShellAgent[] | null;
118 /** The apps this person pinned to their rail in the workspace (lib/apps.ts). */
119 pins?: PinnableApp[];
120};
121
122/** An agent as the shell lists it. */
123export type ShellAgent = Pick<
124 WorkspaceAgent,
125 "id" | "handle" | "display_name" | "avatar" | "avatar_seed" | "role" | "status" | "title" | "builtin"
126> & {
127 look?: WorkspaceAgent["look"];
128 scope?: WorkspaceAgent["scope"];
129 /** The visible teams it is on (team memberships); absent when they couldn't be read. */
130 teams?: { slug: string; name: string }[];
131};
132
133/** Whether `pathname` is `to` or a page under it (`end`: only `to` itself), the query left aside. */
134function under(pathname: string, to: string, end = false): boolean {
135 const path = to.split("?")[0]!;
136 return pathname === path || (!end && pathname.startsWith(path.endsWith("/") ? path : `${path}/`));
137}
138
139/**
140 * Where a row is current and where it is on its way to. A row's page is
141 * current under its own address and any `also` prefix, unless the list
142 * says itself (`current`). Rows that differ by query alone (Notifications'
143 * views and reasons) are pending only when the page on its way is that
144 * row's, query and all.
145 */
146function useRowState(to: string, { end, also, current: lit }: { end?: boolean; also?: string | string[]; current?: boolean }) {
147 const { pathname } = useLocation();
148 const going = useNavigation().location;
149 const current = lit ?? (under(pathname, to, end) || [also ?? []].flat().some((prefix) => under(pathname, prefix)));
150 const pending =
151 going != null && !current && (lit === undefined ? under(going.pathname, to, end) : `${going.pathname}${going.search}` === to);
152 return { current, pending };
153}
154
155/**
156 * One row of a mode's sidebar: an icon, its words, how many it lists
157 * (`count`) and, for a row that opens a list of its own (`drill`), a
158 * chevron, always or on hover.
159 */
160function SidebarLink({
161 to,
162 icon,
163 end,
164 count,
165 also,
166 drill,
167 current: lit,
168 action,
169 bare = false,
170 children,
171}: {
172 to: string;
173 icon: ReactNode;
174 end?: boolean;
175 count?: number;
176 /** Other path prefixes under which this link is the current one. */
177 also?: string | string[];
178 /** It opens a list of its own: a chevron says so, always or on hover. */
179 drill?: boolean | "hover";
180 /** Whether it is the current row, when the list works that out itself. */
181 current?: boolean;
182 /** A small button at the row's end, beside the words (a pin). */
183 action?: ReactNode;
184 /** The row alone, for a list item that is drawn by the list (a pinned project, which drags). */
185 bare?: boolean;
186 children: ReactNode;
187}) {
188 const { current, pending } = useRowState(to, { end, also, current: lit });
189 const Item = bare ? Fragment : SidebarMenuItem;
190 return (
191 <Item>
192 <SidebarMenuButton asChild isActive={current} isPending={pending} className={action ? "pr-7" : undefined}>
193 <Link to={to} prefetch="intent" aria-current={current ? "page" : undefined}>
194 {icon}
195 <span className="min-w-0 grow truncate">{children}</span>
196 {count != null && count > 0 && <SidebarMenuBadge>{count}</SidebarMenuBadge>}
197 {drill && (
198 <ChevronRight
199 aria-hidden="true"
200 className={`-mr-0.5 size-3.5! shrink-0 text-faint transition-opacity ${drill === "hover" ? "opacity-0 group-hover/menu-button:opacity-100 group-focus-visible/menu-button:opacity-100" : ""}`}
201 />
202 )}
203 </Link>
204 </SidebarMenuButton>
205 {action}
206 </Item>
207 );
208}
209
210/**
211 * Something a project will have, shown where it will live so people can
212 * see where g1t is going. Not a link: nothing is behind it yet.
213 */
214function SidebarSoon({ icon, children, about }: { icon: ReactNode; children: ReactNode; about: string }) {
215 return (
216 <SidebarMenuItem>
217 <Hint label={about} side="right">
218 <SidebarMenuButton asChild variant="faint">
219 <div aria-disabled="true" className="cursor-default">
220 {icon}
221 <span className="min-w-0 grow truncate">{children}</span>
222 <span className="sr-only">{about}</span>
223 <SoonPill />
224 </div>
225 </SidebarMenuButton>
226 </Hint>
227 </SidebarMenuItem>
228 );
229}
230
231/**
232 * A page that is coming, as a link to its roadmap page: faint, with Soon,
233 * and marked current on any of its section's Soon pages.
234 */
235function SidebarSoonLink({
236 to,
237 also,
238 icon,
239 about,
240 current: lit,
241 children,
242}: {
243 to: string;
244 also?: string[];
245 icon: ReactNode;
246 about: string;
247 /** Whether it is the current row, when the list works that out itself. */
248 current?: boolean;
249 children: ReactNode;
250}) {
251 const { current, pending } = useRowState(to, { also, current: lit });
252 return (
253 <SidebarMenuItem>
254 <Hint label={about} side="right">
255 <SidebarMenuButton asChild variant="faint" isActive={current} isPending={pending}>
256 <Link to={to} prefetch="intent" aria-current={current ? "page" : undefined}>
257 {icon}
258 <span className="min-w-0 grow truncate">{children}</span>
259 <SoonPill />
260 </Link>
261 </SidebarMenuButton>
262 </Hint>
263 </SidebarMenuItem>
264 );
265}
266
267/** Icons for what spans projects. */
268const WORKSPACE_ICONS: Record<string, ReactNode> = {
269 board: <KanbanSquare size={15} />,
270 roadmap: <GanttChart size={15} />,
271 teams: <UsersRound size={15} />,
272 packages: <Package size={15} />,
273 fleet: <Bot size={15} />,
274};
275
276/** The Soon pages of a section, as paths, so its link is current on them. */
277function soonPaths(base: string, section: RoadmapItem["section"]): string[] {
278 return roadmapIn(section).map((item) => `${base}/soon/${item.key}`);
279}
280
281/** A titled group of rows: its name in small capitals, what it makes at the end, and its menu. */
282function NavGroup({
283 title,
284 action,
285 className,
286 children,
287}: {
288 title: string;
289 /** A small button at the label's end, in its row: what the group makes (a `SidebarGroupAction` with `relative top-auto right-auto`). */
290 action?: ReactNode;
291 className?: string;
292 children: ReactNode;
293}) {
294 return (
295 <SidebarGroup className={className}>
296 <div className="flex items-center justify-between gap-2 pr-1">
297 <SidebarGroupLabel asChild>
298 <h2>{title}</h2>
299 </SidebarGroupLabel>
300 {action}
301 </div>
302 <SidebarGroupContent>
303 <SidebarMenu>{children}</SidebarMenu>
304 </SidebarGroupContent>
305 </SidebarGroup>
306 );
307}
308
309/** Rows with no name over them: the first of a list, or a run between rules. */
310function NavRows({ className, children }: { className?: string; children: ReactNode }) {
311 return (
312 <SidebarGroup className={className}>
313 <SidebarGroupContent>
314 <SidebarMenu>{children}</SidebarMenu>
315 </SidebarGroupContent>
316 </SidebarGroup>
317 );
318}
319
320/** What a workspace is called where people read it: its display name, else its slug. */
321function displayName(membership: Membership): string {
322 return membership.name?.trim() || membership.slug;
323}
324
325/**
326 * The fine print, as one quiet row at the foot of the account menu and the
327 * visitor's panel: each link a full-height target, left-aligned. In the
328 * menu each is a menu item, so the arrow keys reach it.
329 */
330const LEGAL_LINKS: [string, string][] = [
331 ["Policies", "/policies"],
332 ["Privacy", "/policies/privacy"],
333 ["Security", "/security"],
334];
335const LEGAL_LINK = "flex h-7 items-center rounded px-1.5 text-xs text-faint outline-none transition-colors";
336
337function MenuLegalRow() {
338 return (
339 <div role="group" aria-label="Legal" className="flex items-center gap-0.5 px-0.5 pt-0.5">
340 {LEGAL_LINKS.map(([label, to], index) => (
341 <span key={to} className="flex items-center gap-0.5">
342 {index > 0 && (
343 <span aria-hidden="true" className="text-[0.625rem] text-line-strong">
344 ·
345 </span>
346 )}
347 <DropdownMenuItem asChild className={`${LEGAL_LINK} py-0 data-highlighted:bg-line data-highlighted:text-fg`}>
348 <Link to={to}>{label}</Link>
349 </DropdownMenuItem>
350 </span>
351 ))}
352 </div>
353 );
354}
355
356/** Status's row: the live dot and two or three words, fetched when the menu opens. */
357function StatusSummary({ open }: { open: boolean }) {
358 const status = useSiteStatus(open);
359 const words = statusTitle(status);
360 return (
361 <span className="ml-auto flex min-w-0 items-center gap-1.5 pl-2 text-xs text-faint">
362 {/* The words say it; the dot's own words for screen readers would repeat them. */}
363 <span aria-hidden="true" className="flex">
364 <StatusDot state={status?.overall.state ?? null} />
365 </span>
366 {words ? <span className="truncate">{words}</span> : <Skeleton className="h-3 w-20" />}
367 </span>
368 );
369}
370
371/** A menu row: an icon, words, and whatever sits at its end. */
372const MENU_ROW = "h-9 gap-2.5 px-2.5 text-[0.8125rem]";
373
374/**
375 * Your account, at the foot of the rail (or in the header, before you have
376 * a workspace): who you are and your status, your profile and settings,
377 * and help: the documentation, support, status and the keyboard's
378 * shortcuts; then signing out and the fine print.
379 */
380function AccountMenu({ user, side = "right" }: { user: User; side?: "right" | "bottom" }) {
381 const submit = useSubmit();
382 const [open, setOpen] = useState(false);
383 const [keys, setKeys] = useState(false);
384 // Inside the desktop app there is nothing to get.
385 const inApp = useDesktopApp();
386 // Your status's dialog: outside the menu, so the menu closes behind it.
387 const [editing, setEditing] = useState(false);
388 // Name, primary address and invites left: asked for once, as soon as the
389 // pointer or focus reaches the button, so they are there when it opens.
390 const details = useFetcher<AccountMenuData | null>({ key: "account-menu" });
391 const prefetch = () => {
392 if (details.state === "idle" && details.data === undefined) details.load("/settings/menu.json");
393 };
394 useEffect(() => {
395 if (open) prefetch();
396 // eslint-disable-next-line react-hooks/exhaustive-deps
397 }, [open]);
398 const me = details.data ?? null;
399 // Still on its way: shapes where the words will be, the same size.
400 const loading = details.data === undefined && details.state !== "idle";
401 // While anyone can sign up, listed once the data says there are invites to look back on.
402 const invitesListed = useInviteOnly() || me?.invites_page === true;
403 const profile = `/u/${user.username}`;
404 return (
405 <>
406 <DropdownMenu open={open} onOpenChange={setOpen}>
407 {/* The avatar alone, with a dot that says how others see you (components/presence.tsx). */}
408 <Hint label={side === "right" ? "Your account" : undefined} side="right">
409 <DropdownMenuTrigger
410 aria-label={`Account menu for ${shownUsername(user)}`}
411 onPointerEnter={prefetch}
412 onFocus={prefetch}
413 className={
414 side === "right"
415 ? // At the foot of the rail: a 40px rounded square, as the rail's icons are.
416 "relative flex size-10 items-center justify-center rounded-[10px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:bg-sidebar-accent"
417 : "relative flex rounded-full outline-none transition-transform hover:scale-[1.04] focus-visible:ring-2 focus-visible:ring-accent data-[state=open]:ring-2 data-[state=open]:ring-line-strong"
418 }
419 >
420 <Avatar name={user.username} image={user.avatar} size={side === "right" ? 40 : 28} square={side === "right"} />
421 <OwnPresenceDot ring={side === "right" ? "var(--color-rail)" : "var(--color-bg)"} className={side === "right" ? "absolute -right-1 -bottom-1" : "absolute -right-0.5 -bottom-0.5"} />
422 </DropdownMenuTrigger>
423 </Hint>
424 <DropdownMenuContent align="end" side={side} sideOffset={side === "right" ? 14 : 6} collisionPadding={8} className="w-70 p-1.5">
425 {/* Who is signed in, and a way to their profile. */}
426 <DropdownMenuItem asChild className="gap-3 px-2 py-2">
427 <Link to={profile} aria-label={`${me?.name ?? shownUsername(user)} (@${shownUsername(user)}), your profile`}>
428 <Avatar name={user.username} image={user.avatar} size={36} />
429 <span className="flex min-w-0 grow flex-col leading-tight" aria-busy={loading}>
430 {loading ? (
431 <Skeleton className="my-0.75 h-3.5 w-28" />
432 ) : (
433 <span className="truncate text-sm font-medium text-fg">{me?.name ?? shownUsername(user)}</span>
434 )}
435 <span className="truncate font-mono text-xs text-muted">@{shownUsername(user)}</span>
436 {loading ? (
437 <Skeleton className="mt-1 h-3 w-40" />
438 ) : (
439 me?.email && <span className="mt-0.5 truncate text-xs text-faint">{me.email}</span>
440 )}
441 </span>
442 </Link>
443 </DropdownMenuItem>
444 <DropdownMenuSeparator className="my-1.5" />
445 {/* Your status, away, and pausing notifications. */}
446 <DropdownMenuGroup>
447 <OwnPresenceItems className="min-h-9 py-1.5 text-[0.8125rem]" onEdit={() => setEditing(true)} />
448 </DropdownMenuGroup>
449 <DropdownMenuSeparator className="my-1.5" />
450 <DropdownMenuGroup>
451 <DropdownMenuItem asChild className={MENU_ROW}>
452 <Link to={profile}>
453 <CircleUserRound />
454 Your profile
455 </Link>
456 </DropdownMenuItem>
457 <DropdownMenuItem asChild className={MENU_ROW}>
458 <Link to={FIRST_SETTINGS_PAGE}>
459 <Settings />
460 Your settings
461 </Link>
462 </DropdownMenuItem>
463 {/* The app's own: starting with the computer, closing to the tray, the badge (apps/desktop). */}
464 {inApp && desktopBridge()?.openSettings && (
465 <DropdownMenuItem className={MENU_ROW} onSelect={() => desktopBridge()?.openSettings?.()}>
466 <MonitorCog />
467 Desktop app settings
468 </DropdownMenuItem>
469 )}
470 {invitesListed && (
471 <DropdownMenuItem asChild className={MENU_ROW}>
472 <Link to="/settings/invites">
473 <Ticket />
474 {ACCOUNT_SETTINGS.invites.title}
475 {loading && <Skeleton className="ml-auto h-4 w-12 rounded-full" />}
476 {me?.invites_left != null && (
477 <span className="ml-auto rounded-full bg-line px-1.5 text-[0.6875rem] tabular-nums text-muted">
478 {me.invites_left} left
479 </span>
480 )}
481 </Link>
482 </DropdownMenuItem>
483 )}
484 </DropdownMenuGroup>
485 <DropdownMenuSeparator className="my-1.5" />
486 {/* Auto, Light or Dark, switched in place (lib/theme.ts). */}
487 <ThemeMenuSwitch />
488 <DropdownMenuSeparator className="my-1.5" />
489 <DropdownMenuGroup>
490 <DropdownMenuItem asChild className={MENU_ROW}>
491 <a href="https://docs.g1t.sh/">
492 <BookOpen />
493 Documentation
494 </a>
495 </DropdownMenuItem>
496 <DropdownMenuItem asChild className={MENU_ROW}>
497 <Link to="/support">
498 <LifeBuoy />
499 Support
500 </Link>
501 </DropdownMenuItem>
502 <DropdownMenuItem asChild className={MENU_ROW}>
503 <a href={STATUS_URL}>
504 <Activity />
505 Status
506 <StatusSummary open={open} />
507 </a>
508 </DropdownMenuItem>
509 <DropdownMenuItem className={MENU_ROW} onSelect={() => setKeys(true)}>
510 <Keyboard />
511 Keyboard shortcuts
512 <PaletteKey className="ml-auto font-sans text-xs text-faint" />
513 </DropdownMenuItem>
514 {!inApp && (
515 <DropdownMenuItem asChild className={MENU_ROW}>
516 <Link to="/download">
517 <MonitorDown />
518 Get the desktop app
519 </Link>
520 </DropdownMenuItem>
521 )}
522 </DropdownMenuGroup>
523 <DropdownMenuSeparator className="my-1.5" />
524 {/* Submitted from here: the menu closes on select, and a button
525 that has left the page cannot submit a form. */}
526 <DropdownMenuItem className={MENU_ROW} onSelect={() => submit(null, { method: "post", action: "/logout" })}>
527 <LogOut />
528 Sign out
529 </DropdownMenuItem>
530 <DropdownMenuSeparator className="my-1.5" />
531 <MenuLegalRow />
532 </DropdownMenuContent>
533 </DropdownMenu>
534 <StatusDialog open={editing} onOpenChange={setEditing} />
535 <ShortcutsDialog open={keys} onOpenChange={setKeys} />
536 </>
537 );
538}
539
540/** A project's settings pages, which the project's menu drills into. */
541const REPO_SETTINGS_PAGE = /^\/([^/]+)\/([^/-][^/]*)\/settings(\/|$)/;
542
543/**
544 * The sidebar's lists are a stack, the way a phone pushes a screen: one
545 * drilled into slides in from the right over the full width, while the one
546 * it covers drifts a quarter of the way left and fades, both on one long
547 * ease-out, the fade quicker than the move so the two never blur together.
548 * Going back reverses it.
549 */
550const LAYER =
551 "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";
552/** One list, filling its layer. */
553const PANEL = "h-full overflow-y-auto px-1 pt-1 pb-4 [scrollbar-width:thin]";
554
555/** One list in the stack: what it is, and its rows. */
556type Level = { key: string; node: ReactNode };
557
558/** True once the page has hydrated, so what the server drew never animates in. */
559function useHydrated(): boolean {
560 const [hydrated, setHydrated] = useState(false);
561 useEffect(() => setHydrated(true), []);
562 return hydrated;
563}
564
565/**
566 * Drilling in and out of the sidebar's lists. `trail` is the way from the
567 * main list to the one shown, worked out from the address, so a link
568 * straight to a settings page opens the sidebar already drilled in, and
569 * leaving it comes back out. Lists deeper than the one shown stay in
570 * place, off to the right, so going back slides them away rather than
571 * dropping them. Moving to a list at the same depth (a workspace's settings
572 * to a project) fades the new one in where it is.
573 */
574function Drill({ trail }: { trail: Level[] }) {
575 const depth = trail.length - 1;
576 const hydrated = useHydrated();
577 const stack = useRef<Level[]>(trail);
578 const before = stack.current;
579 const within = trail.every((level, index) => before[index]?.key === level.key);
580 stack.current = within ? [...trail, ...before.slice(trail.length)] : trail;
581 const levels = stack.current;
582 // What was showing last time, to tell drilling in from moving across.
583 const shown = useRef({ depth, keys: levels.map((level) => level.key) });
584 useEffect(() => {
585 shown.current = { depth, keys: levels.map((level) => level.key) };
586 });
587 return (
588 <div className="relative min-h-0 grow overflow-hidden">
589 {levels.map((level, index) => {
590 const current = index === depth;
591 const place =
592 index < depth
593 ? "pointer-events-none -translate-x-1/4 opacity-0"
594 : current
595 ? "translate-x-0 opacity-100"
596 : "pointer-events-none translate-x-full opacity-0";
597 // A list that was not there before arrives: from the right when
598 // drilling in, in place when moving across.
599 const arriving = hydrated && current && !shown.current.keys.includes(level.key);
600 const enter = arriving
601 ? depth > shown.current.depth
602 ? "starting:translate-x-full starting:opacity-0"
603 : "starting:opacity-0"
604 : "";
605 return (
606 <div key={level.key} className={`${LAYER} ${place} ${enter}`} inert={!current} aria-hidden={!current || undefined}>
607 {level.node}
608 </div>
609 );
610 })}
611 </div>
612 );
613}
614
615/**
616 * The row at the top of a list drilled into: the list's name, which goes
617 * back out, and what it belongs to, faint at the end.
618 */
619function BackRow({ to, label, context }: { to: string; label: ReactNode; context?: ReactNode }) {
620 return (
621 <NavRows className="mt-1">
622 <SidebarMenuItem>
623 <SidebarMenuButton asChild className="gap-1.5 pl-1 font-medium text-fg">
624 <Link to={to} prefetch="intent">
625 <ChevronLeft className="text-faint transition-transform group-hover/menu-button:-translate-x-0.5 group-hover/menu-button:text-muted" />
626 <span className="min-w-0 shrink-0 truncate">{label}</span>
627 {context && <span className="ml-auto min-w-0 truncate pl-2 font-mono text-[0.6875rem] font-normal text-faint">{context}</span>}
628 </Link>
629 </SidebarMenuButton>
630 </SidebarMenuItem>
631 </NavRows>
632 );
633}
634
635/** A thin rule between groups of a list. */
636function Rule() {
637 return <SidebarSeparator className="my-1.5" />;
638}
639
640/** A quiet heading inside a group: Pinned, Recent. */
641function SidebarSubhead({ children }: { children: ReactNode }) {
642 return (
643 <SidebarGroupLabel asChild className="h-6 pt-0.5">
644 <h3>{children}</h3>
645 </SidebarGroupLabel>
646 );
647}
648
649/**
650 * The workspace's projects as the sidebar keeps them, however many there
651 * are: the person's pins in their order, what they opened last, and the
652 * way to all of them. Pins move by dragging, or with Alt and the arrow
653 * keys; the projects service keeps the order.
654 */
655function SidebarProjects({ slug, shell, current }: { slug: string; shell: ShellData; current: boolean }) {
656 const reorder = useFetcher({ key: `pins:${slug}` });
657 const saved = shell.pinned ?? [];
658 // While a new order is on its way, it shows as made.
659 const asked = reorder.formData?.get("intent") === "reorder" ? reorder.formData.getAll("slug").map(String) : null;
660 const pinned = asked
661 ? asked.map((name) => saved.find((project) => project.name === name)).filter((project): project is ShortcutProject => project != null)
662 : saved;
663 const active = shell.repo ? { namespace: shell.repo.namespace, name: shell.repo.name, isPrivate: false } : null;
664 const recent = recentWith(shell.recent ?? [], pinned, active, slug);
665 const [dragging, setDragging] = useState<number | null>(null);
666 const move = (from: number, by: number) => {
667 const next = movedPin(pinned, from, by);
668 if (!next) return;
669 const form = new FormData();
670 form.set("intent", "reorder");
671 for (const project of next) form.append("slug", project.name);
672 reorder.submit(form, { method: "post", action: `/${slug}/-/pins` });
673 };
674 // Each row pins or unpins in place: the pin shows on hover or focus, and
675 // stays shown on a pinned row's hover so it reads as "unpin".
676 const row = (project: ShortcutProject, isPinned: boolean) => (
677 <SidebarLink
678 to={`/${project.namespace}/${project.name}`}
679 icon={project.isPrivate ? <Lock /> : <Box />}
680 bare={isPinned}
681 action={
682 // At the row's end, where the row's other actions sit, and only on
683 // hover or keyboard focus: a pin clicked keeps the mouse's focus,
684 // and showing it on any focus left it lit on a row no one was over.
685 <PinButton
686 workspace={slug}
687 slug={project.name}
688 name={project.title ?? project.name}
689 pinned={isPinned}
690 small
691 className="absolute top-1/2 right-1 -translate-y-1/2 opacity-0 transition-opacity group-hover/menu-item:opacity-100 has-focus-visible:opacity-100 [@media(hover:none)]:opacity-100"
692 />
693 }
694 >
695 {project.title ?? project.name}
696 </SidebarLink>
697 );
698 return (
699 <SidebarGroup>
700 {/* The label and its button share a row, so the button stays level with the words at any text size. */}
701 <div className="flex items-center justify-between gap-2 pr-1">
702 <SidebarGroupLabel asChild>
703 <h2>Projects</h2>
704 </SidebarGroupLabel>
705 <Hint label="New project">
706 <SidebarGroupAction asChild className="relative top-auto right-auto">
707 <Link to="/new" aria-label="New project">
708 <Plus />
709 </Link>
710 </SidebarGroupAction>
711 </Hint>
712 </div>
713 <SidebarGroupContent>
714 {/* Only there once something is pinned: each row below has its own pin. */}
715 {pinned.length > 0 && (
716 <>
717 <SidebarSubhead>Pinned</SidebarSubhead>
718 <SidebarMenu aria-label="Pinned projects">
719 {pinned.map((project, index) => (
720 <SidebarMenuItem
721 key={project.name}
722 draggable={pinned.length > 1}
723 onDragStart={(event) => {
724 setDragging(index);
725 event.dataTransfer.effectAllowed = "move";
726 }}
727 onDragOver={(event) => {
728 if (dragging != null) event.preventDefault();
729 }}
730 onDrop={(event) => {
731 event.preventDefault();
732 if (dragging != null && dragging !== index) move(dragging, index - dragging);
733 setDragging(null);
734 }}
735 onDragEnd={() => setDragging(null)}
736 onKeyDown={(event) => {
737 if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
738 event.preventDefault();
739 move(index, event.key === "ArrowUp" ? -1 : 1);
740 }}
741 className={`group/pin ${dragging === index ? "opacity-50" : ""}`}
742 >
743 {row(project, true)}
744 {pinned.length > 1 && (
745 <Hint label="Drag, or Alt and an arrow key, to reorder" side="right">
746 <span className="absolute top-1/2 -left-2 -translate-y-1/2 cursor-grab text-faint opacity-0 transition-opacity group-hover/pin:opacity-100">
747 <GripVertical size={12} aria-hidden="true" />
748 </span>
749 </Hint>
750 )}
751 </SidebarMenuItem>
752 ))}
753 </SidebarMenu>
754 </>
755 )}
756 {recent.length > 0 && (
757 <>
758 <SidebarSubhead>Recent</SidebarSubhead>
759 <SidebarMenu aria-label="Recent projects">
760 {recent.map((project) => (
761 <Fragment key={`${project.namespace}/${project.name}`}>{row(project, false)}</Fragment>
762 ))}
763 </SidebarMenu>
764 </>
765 )}
766 <SidebarMenu className="pt-1">
767 <SidebarLink to={`/${slug}/-/projects`} icon={<LayoutGrid />} count={shell.repos.length} current={current}>
768 All projects
769 </SidebarLink>
770 </SidebarMenu>
771 </SidebarGroupContent>
772 </SidebarGroup>
773 );
774}
775
776/** Insights, coming: the workspace's own page says what it will be. */
777const INSIGHTS = roadmapItem("insights");
778
779/**
780 * What the repository menu needs. Known from the address before the page's
781 * data arrives, so the menu is right from the first frame; the counts fill
782 * in once it does.
783 */
784type MenuRepo = {
785 namespace: string;
786 name: string;
787 member: boolean;
788 /** Whether they see its settings; from the repository's page once it loads. */
789 settings?: boolean;
790 /** What they may do there, once the repository's page loads. */
791 can?: Abilities;
792 issues?: number;
793 pulls?: number;
794};
795
796function sameRepo(a: { namespace: string; name: string } | null, b: { namespace: string; name: string } | null) {
797 return (
798 a != null &&
799 b != null &&
800 a.namespace.toLowerCase() === b.namespace.toLowerCase() &&
801 a.name.toLowerCase() === b.name.toLowerCase()
802 );
803}
804
805/**
806 * A project's own list, drilled into while you are in it: everything about
807 * the project, running and its code, and nothing else, with the way back
808 * out to all of them.
809 */
810function RepoMenu({
811 repo,
812 isPrivate,
813 back,
814}: {
815 repo: MenuRepo;
816 isPrivate: boolean;
817 /** Where the way back leads: the workspace's projects, mission control, or Explore. */
818 back: { to: string; label: string };
819}) {
820 const base = `/${repo.namespace}/${repo.name}`;
821 // What a member sees, and what everyone who can see the project does
822 // (lib/chrome.ts).
823 const shows = new Set(projectPages(repo.member, repo.can));
824 const { current: atOverview, pending: toOverview } = useRowState(base, { end: true });
825 return (
826 <nav aria-label={`${repo.namespace}/${repo.name}`} className={PANEL}>
827 <BackRow to={back.to} label={back.label} />
828 <NavRows className="mt-1">
829 <SidebarMenuItem>
830 <Hint label="Overview" side="right">
831 <SidebarMenuButton asChild size="lg" isActive={atOverview} isPending={toOverview} className="gap-2 font-normal">
832 <Link to={base} prefetch="intent" aria-current={atOverview ? "page" : undefined}>
833 <span className="flex size-6 shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line [&>svg]:size-3.5">
834 {isPrivate ? <Lock /> : <Box />}
835 </span>
836 <span className="min-w-0 truncate font-mono text-[0.8125rem]">
837 <span className="text-faint">{repo.namespace}/</span>
838 <span className="font-semibold text-fg">{repo.name}</span>
839 </span>
840 </Link>
841 </SidebarMenuButton>
842 </Hint>
843 </SidebarMenuItem>
844 </NavRows>
845 {/* A project's pages, in the order people use them. A page with more
846 than one view shows them as tabs across its top. */}
847 <Rule />
848 <NavRows>
849 <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} />}>
850 Code
851 </SidebarLink>
852 {shows.has("issues") && (
853 <SidebarLink to={`${base}/issues`} also={[`${base}/plans`, `${base}/milestones`, `${base}/labels`, ...soonPaths(base, "Issues")]} icon={<CircleDot size={15} />} count={repo.issues}>
854 Issues
855 </SidebarLink>
856 )}
857 {shows.has("pulls") && (
858 <SidebarLink to={`${base}/pulls`} also={[`${base}/pull`, `${base}/queue`]} icon={<GitPullRequest size={15} />} count={repo.pulls}>
859 Pull requests
860 </SidebarLink>
861 )}
862 {shows.has("agents") && (
863 <SidebarLink to={`${base}/agents`} also={[`${base}/sessions`, `${base}/memory`, ...soonPaths(base, "Agents")]} icon={<Bot size={15} />}>
864 Agents
865 </SidebarLink>
866 )}
867 {shows.has("actions") && (
868 <SidebarLink to={`${base}/actions`} icon={<PlayCircle size={15} />}>
869 Workflows
870 </SidebarLink>
871 )}
872 </NavRows>
873 <Rule />
874 <NavRows>
875 {shows.has("deployments") ? (
876 <SidebarLink to={`${base}/deployments`} also={soonPaths(base, "Deployments")} icon={<Rocket size={15} />}>
877 Deployments
878 </SidebarLink>
879 ) : null}
880 {shows.has("observability") && (
881 <SidebarLink to={`${base}/observability`} also={soonPaths(base, "Observability")} icon={<Activity size={15} />}>
882 Observability
883 </SidebarLink>
884 )}
885 {shows.has("security") ? (
886 <SidebarLink to={`${base}/security`} also={soonPaths(base, "Security")} icon={<ShieldCheck size={15} />}>
887 Security
888 </SidebarLink>
889 ) : null}
890 <SidebarLink
891 to={`${base}/contributors`}
892 also={[`${base}/activity`, `${base}/stargazers`, ...soonPaths(base, "Insights")]}
893 icon={<BarChart3 size={15} />}
894 >
895 Insights
896 </SidebarLink>
897 </NavRows>
898 {(repo.settings ?? shows.has("settings")) && (
899 <>
900 <Rule />
901 <NavRows>
902 <SidebarLink to={`${base}/settings`} icon={<Settings size={15} />} drill>
903 Settings
904 </SidebarLink>
905 </NavRows>
906 </>
907 )}
908 </nav>
909 );
910}
911
912/**
913 * A project's settings, drilled into from its list: what is about running
914 * it, then its agents, then its code and who can reach it. The way back
915 * leads to the project.
916 */
917function RepoSettingsMenu({ repo }: { repo: MenuRepo }) {
918 const base = `/${repo.namespace}/${repo.name}`;
919 // Each page shows to the roles that can use it, once the role is known.
920 const shows = (page: string) => !repo.can || repo.can[SETTINGS_CAPABILITY[page] ?? "administer"];
921 const running = shows("deployments");
922 const agents = shows("agents") || shows("guardrails");
923 return (
924 <nav aria-label={`${repo.namespace}/${repo.name} settings`} className={PANEL}>
925 <BackRow to={base} label="Settings" context={`${repo.namespace}/${repo.name}`} />
926 {shows("") && (
927 <NavRows className="mt-2">
928 <SidebarLink to={`${base}/settings`} end icon={<Settings size={15} />}>
929 General
930 </SidebarLink>
931 </NavRows>
932 )}
933 {running && (
934 <>
935 {shows("") && <Rule />}
936 <NavRows className={shows("") ? undefined : "mt-2"}>
937 <SidebarLink to={`${base}/settings/deployments`} icon={<Rocket size={15} />}>
938 Deployments
939 </SidebarLink>
940 <SidebarLink to={`${base}/settings/domains`} icon={<Globe size={15} />}>
941 Domains
942 </SidebarLink>
943 </NavRows>
944 </>
945 )}
946 {agents && (
947 <>
948 <Rule />
949 <NavRows>
950 {shows("agents") && (
951 <SidebarLink to={`${base}/settings/agents`} icon={<Bot size={15} />}>
952 Agents
953 </SidebarLink>
954 )}
955 {shows("guardrails") && (
956 <SidebarLink to={`${base}/settings/guardrails`} icon={<ShieldCheck size={15} />}>
957 Guardrails
958 </SidebarLink>
959 )}
960 </NavRows>
961 </>
962 )}
963 <Rule />
964 <NavRows>
965 {shows("repository") && (
966 <SidebarLink to={`${base}/settings/repository`} icon={<BookMarked size={15} />}>
967 Repository
968 </SidebarLink>
969 )}
970 {shows("access") && (
971 <SidebarLink to={`${base}/settings/access`} icon={<Users size={15} />}>
972 Access
973 </SidebarLink>
974 )}
975 {shows("keys") && (
976 <SidebarLink to={`${base}/settings/keys`} icon={<KeyRound size={15} />}>
977 Deploy keys
978 </SidebarLink>
979 )}
980 {shows("branches") && (
981 <SidebarLink to={`${base}/settings/branches`} icon={<GitBranch size={15} />}>
982 Branches and merging
983 </SidebarLink>
984 )}
985 {shows("rules") && (
986 <SidebarLink to={`${base}/settings/rules`} icon={<Scale size={15} />}>
987 Rules
988 </SidebarLink>
989 )}
990 {shows("secrets") && (
991 <SidebarLink to={`${base}/settings/secrets`} icon={<Lock size={15} />}>
992 Secrets and variables
993 </SidebarLink>
994 )}
995 {shows("actions") && (
996 <SidebarLink to={`${base}/settings/actions`} icon={<PlayCircle size={15} />}>
997 Actions
998 </SidebarLink>
999 )}
1000 {shows("environments") && (
1001 <SidebarLink to={`${base}/settings/environments`} icon={<Layers size={15} />}>
1002 Environments
1003 </SidebarLink>
1004 )}
1005 {shows("runners") && (
1006 <SidebarLink to={`${base}/settings/runners`} icon={<ServerCog size={15} />}>
1007 Runners
1008 </SidebarLink>
1009 )}
1010 {shows("webhooks") && (
1011 <SidebarLink to={`${base}/settings/webhooks`} icon={<Webhook size={15} />}>
1012 Webhooks
1013 </SidebarLink>
1014 )}
1015 </NavRows>
1016 </nav>
1017 );
1018}
1019
1020/**
1021 * Whether the menus list Settings → Invites (invites to g1t): always while
1022 * sign-up takes an invite; once anyone can sign up, only for someone with
1023 * invites already made to look back on, which the account menu's data says.
1024 */
1025function useInvitesListed(): boolean {
1026 const inviteOnly = useInviteOnly();
1027 const details = useFetcher<AccountMenuData | null>({ key: "account-menu" });
1028 useEffect(() => {
1029 if (!inviteOnly && details.state === "idle" && details.data === undefined) details.load("/settings/menu.json");
1030 // eslint-disable-next-line react-hooks/exhaustive-deps
1031 }, [inviteOnly]);
1032 return inviteOnly || details.data?.invites_page === true;
1033}
1034
1035/** Your own settings, drilled into from Your settings: one page each. */
1036function AccountSettingsMenu({ username }: { username: string }) {
1037 const invites = useInvitesListed();
1038 const link = (page: AccountSettingsPage, icon: ReactNode) => (
1039 <SidebarLink to={`/settings/${page}`} icon={icon}>
1040 {ACCOUNT_SETTINGS[page].title}
1041 </SidebarLink>
1042 );
1043 return (
1044 <nav aria-label="Your settings" className={PANEL}>
1045 <BackRow to="/" label="Your settings" context={username} />
1046 <NavRows className="mt-2">
1047 {link("profile", <CircleUserRound size={15} />)}
1048 {link("emails", <Mail size={15} />)}
1049 {invites && link("invites", <Ticket size={15} />)}
1050 </NavRows>
1051 <Rule />
1052 <NavRows>
1053 {link("keys", <Fingerprint size={15} />)}
1054 {link("tokens", <KeyRound size={15} />)}
1055 </NavRows>
1056 <Rule />
1057 <NavRows>
1058 {link("integrations", <Blocks size={15} />)}
1059 {link("github", <GithubMark className="size-3.75" />)}
1060 {link("applications", <Plug size={15} />)}
1061 </NavRows>
1062 <Rule />
1063 <NavRows>
1064 {link("two-factor", <ShieldCheck size={15} />)}
1065 {link("security-log", <History size={15} />)}
1066 </NavRows>
1067 </nav>
1068 );
1069}
1070
1071/**
1072 * Code's sidebar: its Overview, the projects, what spans them and what is
1073 * coming; in a project, drilled into the project's own list, and its
1074 * settings one level further in. The address says which, so a link
1075 * straight to a project opens the sidebar already drilled in.
1076 */
1077function CodeSidebar({
1078 user,
1079 shell,
1080 missing = false,
1081}: {
1082 user: User;
1083 shell: ShellData;
1084 /** The page is a 404: the address names nothing the viewer can see. */
1085 missing?: boolean;
1086}) {
1087 const ws = shell.workspace;
1088 const { pathname } = useLocation();
1089 const going = useNavigation().location?.pathname;
1090 // Where the sidebar is drilled to follows the page being gone to, so it
1091 // moves as the link is followed, not once the page arrives.
1092 const target = going ?? pathname;
1093 // On a 404, the address is not a place: no list is drilled into from it,
1094 // except the project's own when the project is real and visible and only
1095 // something inside it is missing (a file, a commit, an issue).
1096 const lost = missing && going == null;
1097 const active = shell.repo;
1098 // In a repository, or on the way into one, its own list.
1099 const repoPath = /^\/([^/]+)\/([^/-][^/]*)(\/|$)/.exec(target);
1100 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", "notifications", "inbox", ".well-known"]);
1101 // An invitation to a repository is answered before its menu means anything.
1102 const inRepo =
1103 repoPath != null &&
1104 !reserved.has(repoPath[1]) &&
1105 repoPath[2] !== "-" &&
1106 !/^\/[^/]+\/[^/]+\/invitations\/?$/.test(target) &&
1107 (!lost || sameRepo(active, { namespace: repoPath[1]!, name: repoPath[2]! }));
1108 // A project's settings, one level further in.
1109 const inRepoSettings = inRepo && REPO_SETTINGS_PAGE.test(target);
1110 // The repository the menu is for: the one loaded if it is the one being
1111 // gone to, else what the address says, at once.
1112 const targetRepo = inRepo && repoPath ? { namespace: repoPath[1], name: repoPath[2] } : null;
1113 const guessed: MenuRepo | null = targetRepo
1114 ? sameRepo(active, targetRepo)
1115 ? active
1116 : {
1117 ...targetRepo,
1118 member: (user.workspaces ?? []).some((m) => m.slug === targetRepo.namespace.toLowerCase()),
1119 }
1120 : null;
1121 // The viewer's role there, from the repository's page once it has loaded.
1122 const page = useRouteLoaderData("routes/repo/layout") as
1123 | { repo?: { namespace: string; name: string }; access?: ViewerAccess }
1124 | undefined;
1125 const menuRepo: MenuRepo | null =
1126 guessed && page?.access && page.repo && sameRepo(page.repo, guessed)
1127 ? { ...guessed, member: page.access.insider, settings: seesSettings(page.access), can: page.access.can }
1128 : guessed;
1129
1130 // The way from Code's list to the one shown.
1131 const trail: Level[] = [{ key: "main", node: ws ? <CodeMenu shell={shell} slug={ws.slug} /> : null }];
1132 if (menuRepo) {
1133 const key = `repo:${menuRepo.namespace}/${menuRepo.name}`.toLowerCase();
1134 // Out of a project: to its workspace's projects when they are yours.
1135 const home = (user.workspaces ?? []).find((m) => m.slug === menuRepo.namespace.toLowerCase());
1136 const back = home ? { to: `/${home.slug}/-/projects`, label: "All projects" } : { to: ws ? `/${ws.slug}/-/overview` : "/explore", label: "Code" };
1137 trail.push({
1138 key,
1139 node: (
1140 <RepoMenu
1141 repo={menuRepo}
1142 isPrivate={[...shell.repos, ...(shell.shared ?? [])].some((repo) => sameRepo(repo, menuRepo) && repo.isPrivate)}
1143 back={back}
1144 />
1145 ),
1146 });
1147 if (inRepoSettings) trail.push({ key: `${key}:settings`, node: <RepoSettingsMenu repo={menuRepo} /> });
1148 }
1149
1150 return (
1151 <div className="flex h-full flex-col">
1152 <ModeHeader title="Code" />
1153 <Drill trail={trail} />
1154 </div>
1155 );
1156}
1157
1158/**
1159 * A mode's sidebar heading: its name, quiet, under the workspace's
1160 * switcher, with what it makes at the end.
1161 */
1162export function ModeHeader({ title, action }: { title: ReactNode; action?: ReactNode }) {
1163 return (
1164 <div className="flex h-8 shrink-0 items-center gap-1 pr-2 pl-3">
1165 <SidebarGroupLabel asChild className="min-w-0 grow truncate px-1">
1166 <h2>{title}</h2>
1167 </SidebarGroupLabel>
1168 {action}
1169 </div>
1170 );
1171}
1172
1173/**
1174 * Code's own list (beside the rail): only code. Its Overview (Mission
1175 * control's code panels), the projects, what spans them, and what is
1176 * coming. The workspace's people, money and settings are elsewhere;
1177 * agents, context and memory are Agents'.
1178 */
1179function CodeMenu({ shell, slug }: { shell: ShellData; slug: string }) {
1180 const { pathname } = useLocation();
1181 const going = useNavigation().location?.pathname;
1182 const path = going ?? pathname;
1183 const at = (page: string) => path === `/${slug}/-/${page}` || path.startsWith(`/${slug}/-/${page}/`);
1184 const shared = shell.shared ?? [];
1185 return (
1186 <nav aria-label="Code" className={PANEL}>
1187 <NavRows>
1188 <SidebarLink to={`/${slug}/-/overview`} icon={<LayoutDashboard size={15} />} current={at("overview")}>
1189 Overview
1190 </SidebarLink>
1191 </NavRows>
1192 <Rule />
1193 <SidebarProjects slug={slug} shell={shell} current={at("projects")} />
1194 <Rule />
1195 <NavRows>
1196 <SidebarLink to={`/${slug}/-/security`} icon={<ShieldCheck size={15} />} current={at("security") && !at("security/settings")}>
1197 Security
1198 </SidebarLink>
1199 <SidebarLink to={`/${slug}/-/packages`} icon={<Package size={15} />} current={at("packages")}>
1200 Packages
1201 </SidebarLink>
1202 {INSIGHTS && (
1203 <SidebarSoonLink to={`/${slug}/-/insights`} icon={<TrendingUp size={15} />} about={INSIGHTS.summary} current={at("insights")}>
1204 {INSIGHTS.title}
1205 </SidebarSoonLink>
1206 )}
1207 {roadmapIn("Workspace")
1208 .filter((item) => item.key !== "insights" && item.key !== "teams" && item.key !== "fleet")
1209 .map((item) => (
1210 <SidebarSoonLink key={item.key} to={`/${slug}/-/soon/${item.key}`} icon={WORKSPACE_ICONS[item.key] ?? <Sparkles size={15} />} about={item.summary}>
1211 {item.title === "Board" ? "Boards" : item.title}
1212 </SidebarSoonLink>
1213 ))}
1214 </NavRows>
1215 {shared.length > 0 && (
1216 <>
1217 <Rule />
1218 <NavGroup title="Shared with you">
1219 {shared.map((repo) => (
1220 <SidebarLink
1221 key={`${repo.namespace}/${repo.name}`}
1222 to={`/${repo.namespace}/${repo.name}`}
1223 icon={repo.isPrivate ? <Lock size={15} /> : <Box size={15} />}
1224 drill="hover"
1225 >
1226 <span className="font-mono text-faint">{repo.namespace}/</span>
1227 {repo.name}
1228 </SidebarLink>
1229 ))}
1230 </NavGroup>
1231 </>
1232 )}
1233 </nav>
1234 );
1235}
1236
1237/** The icon of each of Workspace mode's pages, by its key (lib/workspace-nav.ts). */
1238const WORKSPACE_PAGE_ICONS: Record<string, ReactNode> = {
1239 settings: <Settings size={15} />,
1240 members: <Users size={15} />,
1241 invitations: <Mail size={15} />,
1242 permissions: <ShieldCheck size={15} />,
1243 tokens: <KeyRound size={15} />,
1244 "personal-access-tokens": <UserRoundKey size={15} />,
1245 spend: <Coins size={15} />,
1246 usage: <BarChart3 size={15} />,
1247 gateway: <Network size={15} />,
1248 billing: <CreditCard size={15} />,
1249 runners: <ServerCog size={15} />,
1250 repositories: <BookMarked size={15} />,
1251 actions: <PlayCircle size={15} />,
1252 secrets: <Lock size={15} />,
1253 webhooks: <Webhook size={15} />,
1254 deployments: <Rocket size={15} />,
1255 projects: <Layers size={15} />,
1256 "agent-settings": <Bot size={15} />,
1257 "chat-settings": <MessagesSquare size={15} />,
1258 emoji: <Smile size={15} />,
1259 "artifact-settings": <Shapes size={15} />,
1260 "security-settings": <Shield size={15} />,
1261 guardrails: <Gauge size={15} />,
1262 rules: <Scale size={15} />,
1263 audit: <History size={15} />,
1264 integrations: <Plug size={15} />,
1265 applications: <Blocks size={15} />,
1266};
1267
1268/**
1269 * A group of Workspace mode's rows that folds: its name is the button, with
1270 * a chevron that turns when it is open. The group holding the current page
1271 * is always open, and its button does nothing. Every group starts open, so
1272 * the server and the browser draw the same list.
1273 */
1274function FoldingGroup({ title, current, children }: { title: string; current: boolean; children: ReactNode }) {
1275 const [open, setOpen] = useState(true);
1276 return (
1277 <Collapsible open={open || current} onOpenChange={setOpen}>
1278 <SidebarGroup>
1279 <CollapsibleTrigger
1280 disabled={current}
1281 aria-label={`${title}: ${open || current ? "fold" : "unfold"}`}
1282 className="flex h-7 w-full shrink-0 items-center justify-between rounded-md px-2 text-[0.6875rem] font-medium tracking-wide text-faint uppercase hover:text-muted focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-default disabled:text-faint data-[state=open]:[&_svg]:rotate-90"
1283 >
1284 <span>{title}</span>
1285 {!current && <ChevronRight size={12} aria-hidden="true" className="text-faint/70" />}
1286 </CollapsibleTrigger>
1287 <CollapsibleContent>
1288 <SidebarGroupContent>
1289 <SidebarMenu>{children}</SidebarMenu>
1290 </SidebarGroupContent>
1291 </CollapsibleContent>
1292 </SidebarGroup>
1293 </Collapsible>
1294 );
1295}
1296
1297/**
1298 * The Workspace mode's sidebar: the workspace's settings area, every page
1299 * one click away. Its overview, then the groups in lib/workspace-nav.ts
1300 * (General, Access, Money, Compute, Code, Agents, Chat, Artifacts,
1301 * Security, Integrations), each folding, the one you are in held open.
1302 * Pages only owners open are left out for members, and a group with none
1303 * left goes with them; a page that is coming is a Soon row, not a link.
1304 */
1305export function WorkspaceSidebar({ slug, owner }: { slug: string; owner: boolean }) {
1306 const { pathname } = useLocation();
1307 const going = useNavigation().location?.pathname;
1308 const path = going ?? pathname;
1309 const here = workspaceSettingsPage(path, slug);
1310 const overview = path === `/${slug}/-/workspace` || path.startsWith(`/${slug}/-/workspace/`);
1311 const shown = (page: WorkspaceSettingsPage) => owner || !page.owner;
1312 return (
1313 <div className="flex h-full flex-col">
1314 <ModeHeader title="Workspace" />
1315 <nav aria-label="Workspace" className={PANEL}>
1316 <NavRows>
1317 <SidebarLink to={`/${slug}/-/workspace`} icon={<LayoutGrid size={15} />} current={overview}>
1318 Overview
1319 </SidebarLink>
1320 </NavRows>
1321 {WORKSPACE_SETTINGS_GROUPS.filter((group) => group.pages.some(shown)).map((group) => (
1322 <Fragment key={group.key}>
1323 <Rule />
1324 <FoldingGroup title={group.title} current={here?.group === group.key}>
1325 {group.pages.filter(shown).map((page) =>
1326 page.soon ? (
1327 <SidebarSoon key={page.key} icon={WORKSPACE_PAGE_ICONS[page.key] ?? <Sparkles size={15} />} about={page.soon}>
1328 {page.label}
1329 </SidebarSoon>
1330 ) : (
1331 <SidebarLink
1332 key={page.key}
1333 to={`/${slug}/-/${page.path}`}
1334 icon={WORKSPACE_PAGE_ICONS[page.key] ?? <Settings size={15} />}
1335 current={here?.page === page.key}
1336 >
1337 {page.label}
1338 </SidebarLink>
1339 ),
1340 )}
1341 </FoldingGroup>
1342 </Fragment>
1343 ))}
1344 </nav>
1345 </div>
1346 );
1347}
1348
1349/**
1350 * People's sidebar: everyone in the workspace (its people; agents are
1351 * under Agents); its teams, which agents can be on; and the org chart. Who
1352 * belongs, and inviting people, is the workspace's: Workspace mode's
1353 * Access group.
1354 */
1355function PeopleSidebar({ slug }: { slug: string }) {
1356 const { pathname } = useLocation();
1357 const going = useNavigation().location?.pathname;
1358 const path = going ?? pathname;
1359 const at = (page: string) => path === `/${slug}/-/${page}` || path.startsWith(`/${slug}/-/${page}/`);
1360 return (
1361 <div className="flex h-full flex-col">
1362 <ModeHeader title="People" />
1363 <nav aria-label="People" className={PANEL}>
1364 <NavRows>
1365 <SidebarLink to={`/${slug}/-/people`} icon={<Users size={15} />} current={at("people")}>
1366 Everyone
1367 </SidebarLink>
1368 <SidebarLink to={`/${slug}/-/teams`} icon={<UsersRound size={15} />} current={at("teams")}>
1369 Teams
1370 </SidebarLink>
1371 <SidebarLink to={`/${slug}/-/org-chart`} icon={<Network size={15} />} current={at("org-chart")}>
1372 Org chart
1373 </SidebarLink>
1374 </NavRows>
1375 </nav>
1376 </div>
1377 );
1378}
1379
1380/**
1381 * Notifications' sidebar: what you have not finished with, what you saved
1382 * and what is done; then why you were told, which narrows any of them.
1383 */
1384function NotificationsSidebar({ counts }: { counts: InboxCounts | null }) {
1385 const { search } = useLocation();
1386 const params = new URLSearchParams(search);
1387 const view = inboxView(params.get("view"));
1388 const reason = inboxReason(params.get("reason"));
1389 const tab = params.get("tab");
1390 const address = (changes: Record<string, string | null>) => {
1391 const merged: Record<string, string | null> = { tab, view: view === "inbox" ? null : view, reason, ...changes };
1392 const next = new URLSearchParams();
1393 for (const [name, value] of Object.entries(merged)) if (value) next.set(name, value);
1394 const query = next.toString();
1395 return query ? `/notifications?${query}` : "/notifications";
1396 };
1397 const views = [
1398 { view: "inbox", label: "Everything", icon: <Bell size={15} />, count: counts?.unread },
1399 { view: "saved", label: "Saved", icon: <Bookmark size={15} /> },
1400 { view: "done", label: "Done", icon: <Check size={15} /> },
1401 ] as const;
1402 return (
1403 <div className="flex h-full flex-col">
1404 <ModeHeader title="Notifications" />
1405 <nav aria-label="Notifications" className={PANEL}>
1406 <NavRows>
1407 {views.map((entry) => (
1408 <SidebarLink
1409 key={entry.view}
1410 to={address({ view: entry.view === "inbox" ? null : entry.view, before: null })}
1411 icon={entry.icon}
1412 count={"count" in entry ? (entry.count ?? undefined) : undefined}
1413 current={view === entry.view}
1414 >
1415 {entry.label}
1416 </SidebarLink>
1417 ))}
1418 </NavRows>
1419 <Rule />
1420 <NavGroup title="Why you were told">
1421 {REASON_FILTERS.map((entry) => (
1422 <SidebarLink
1423 key={entry.reason ?? "any"}
1424 to={address({ reason: entry.reason, before: null })}
1425 icon={<span className="block size-3.75" />}
1426 current={reason === entry.reason}
1427 >
1428 {entry.reason == null ? "Any reason" : entry.label}
1429 </SidebarLink>
1430 ))}
1431 </NavGroup>
1432 </nav>
1433 </div>
1434 );
1435}
1436
1437/** Your own settings, beside the page: under the account menu, not any workspace's. */
1438export function AccountSidebar({ username }: { username: string }) {
1439 return (
1440 <div className="flex h-full flex-col">
1441 <ModeHeader title="Your account" />
1442 <div className="min-h-0 grow">
1443 <AccountSettingsMenu username={username} />
1444 </div>
1445 </div>
1446 );
1447}
1448
1449/** Words for the sections a path can end in. */
1450const SECTIONS: Record<string, string> = {
1451 issues: "Issues",
1452 milestones: "Milestones",
1453 labels: "Labels",
1454 pulls: "Pull requests",
1455 queue: "Merge queue",
1456 commits: "Commits",
1457 plans: "Outcomes",
1458 actions: "Workflows",
1459 soon: "Soon",
1460 deployments: "Deployments",
1461 repository: "Repository",
1462 access: "Access",
1463 invitations: "Invitation",
1464 repositories: "Repositories",
1465 branches: "Branches",
1466 tags: "Tags",
1467 compare: "Compare",
1468 code: "Files",
1469 secrets: "Secrets and variables",
1470 settings: "Settings",
1471 people: "People",
1472 "org-chart": "Org chart",
1473 members: "Members",
1474 permissions: "Permissions",
1475 projects: "Projects",
1476 teams: "Teams",
1477 tokens: "Access tokens",
1478 "personal-access-tokens": "Personal access tokens",
1479 spend: "Spend",
1480 receipts: "Receipts",
1481 usage: "Usage",
1482 gateway: "AI Gateway",
1483 billing: "Billing and plans",
1484 integrations: "Integrations",
1485 webhooks: "Webhooks",
1486 emoji: "Emoji",
1487 domains: "Domains",
1488 guardrails: "Guardrails",
1489 rules: "Rules",
1490 audit: "Audit log",
1491 tree: "Files",
1492 blob: "Files",
1493 agents: "Agents",
1494 context: "Context",
1495 memory: "Memory",
1496 security: "Security",
1497 packages: "Packages",
1498 runners: "Runners",
1499 environments: "Environments",
1500 workflows: "Workflows",
1501 observability: "Observability",
1502 insights: "Insights",
1503 sessions: "Sessions",
1504 chat: "Chat",
1505 artifacts: "Artifacts",
1506 home: "Home",
1507 apps: "Apps",
1508 customize: "Customize",
1509 "code-access": "Code access",
1510 overview: "Overview",
1511 workspace: "Workspace",
1512};
1513
1514/** Settings pages whose name differs from the section's of the same word. */
1515const SETTINGS_SECTIONS: Record<string, string> = { branches: "Branches and merging", actions: "Actions" };
1516
1517/** Where the page is, as a trail of links: workspace / repository / section. */
1518function Breadcrumbs({
1519 pathname,
1520 missing,
1521 repo,
1522 workspace,
1523}: {
1524 pathname: string;
1525 missing?: boolean;
1526 repo?: ShellData["repo"];
1527 /** The workspace you are in: the switcher names it, so the trail starts after it. */
1528 workspace: string | null;
1529}) {
1530 // A 404 names nothing from the address, unless the project is real and
1531 // visible and only something inside it is missing.
1532 const visibleRepo = /^\/([^/]+)\/([^/-][^/]*)(\/|$)/.exec(pathname);
1533 if (missing && !(visibleRepo && sameRepo(repo ?? null, { namespace: visibleRepo[1]!, name: visibleRepo[2]! }))) {
1534 return <Here>Not found</Here>;
1535 }
1536 const parts = pathname.split("/").filter(Boolean);
1537 const reserved = ["settings", "explore", "new", "search", "workspaces", "policies", "security", "support", "status", "invite", "notifications"];
1538 if (parts.length === 0) return <Here>Home</Here>;
1539 // Your settings: Settings / Emails.
1540 if (parts[0] === "settings") {
1541 const page = accountSettingsPage(pathname);
1542 return <Trail trail={[{ label: "Settings", to: FIRST_SETTINGS_PAGE }, ...(page ? [{ label: ACCOUNT_SETTINGS[page].title, to: `/settings/${page}` }] : [])]} />;
1543 }
1544 if (reserved.includes(parts[0]!)) {
1545 const words: Record<string, string> = {
1546 settings: "Account",
1547 explore: "Explore",
1548 new: "New project",
1549 search: "Search",
1550 workspaces: "New workspace",
1551 policies: "Policies",
1552 security: "Security",
1553 support: "Support",
1554 status: "Status",
1555 invite: "Invite",
1556 notifications: "Notifications",
1557 };
1558 return <Here>{words[parts[0]!]}</Here>;
1559 }
1560 // A person's profile, by their handle.
1561 if (parts[0] === "u" && parts[1]) return <ProfileCrumb username={parts[1]} />;
1562 const [owner, second, third, fourth] = parts;
1563 const ours = workspace != null && owner!.toLowerCase() === workspace.toLowerCase();
1564 const trail: Crumb[] = ours ? [] : [{ label: owner!, to: `/${owner}`, mono: true }];
1565 if (second === "-") {
1566 const page = `/${owner}/-/${third}`;
1567 if (third === "settings" && fourth === "chat") {
1568 // Chat settings is a page of its own, not one of General's.
1569 trail.push({ label: "Chat settings", to: `${page}/chat` });
1570 } else if (third) {
1571 // The workspace's settings pages each stand alone: General, Members, Permissions.
1572 trail.push({ label: third === "settings" ? "General" : (SECTIONS[third] ?? third), to: page });
1573 // Customize names its tab (Customize / Plugins), Agents its templates, and Members its invitations.
1574 const tabs: Record<string, string> =
1575 third === "customize"
1576 ? { skills: "Skills", connectors: "Connectors", plugins: "Plugins", marketplaces: "Marketplaces", requests: "Requests" }
1577 : third === "agents"
1578 ? { templates: "Templates" }
1579 : third === "members"
1580 ? { invitations: "Invitations" }
1581 : {};
1582 const tab = fourth ? tabs[fourth] : undefined;
1583 if (tab) trail.push({ label: tab, to: `${page}/${fourth}` });
1584 }
1585 } else if (second) {
1586 const repo = `/${owner}/${second}`;
1587 trail.push({ label: second, to: repo, mono: true });
1588 if (third === "pull" && fourth) trail.push({ label: `Pull request #${fourth}`, short: `#${fourth}`, to: `${repo}/pull/${fourth}` });
1589 else if (third === "issues" && fourth && fourth !== "new") trail.push({ label: `Issue #${fourth}`, short: `#${fourth}`, to: `${repo}/issues/${fourth}` });
1590 else if (third === "commit" && fourth) trail.push({ label: fourth.slice(0, 7), to: `${repo}/commit/${fourth}`, mono: true });
1591 else if (third && SECTIONS[third]) {
1592 trail.push({ label: SECTIONS[third]!, to: `${repo}/${third}` });
1593 // A settings page names which one: Settings / Secrets and variables.
1594 if (third === "settings" && fourth && SECTIONS[fourth]) {
1595 trail.push({ label: SETTINGS_SECTIONS[fourth] ?? SECTIONS[fourth]!, to: `${repo}/settings/${fourth}` });
1596 }
1597 }
1598 }
1599 if (trail.length === 0) trail.push({ label: "Overview", to: `/${owner}` });
1600 return <Trail trail={trail} />;
1601}
1602
1603/** A profile's place in the top bar: the person's avatar and @handle, from the page once it has loaded. */
1604function ProfileCrumb({ username }: { username: string }) {
1605 const page = useRouteLoaderData("routes/user") as { profile?: { username: string; displayUsername?: string | null; avatar: string | null } } | undefined;
1606 const profile = page?.profile?.username.toLowerCase() === username.toLowerCase() ? page.profile : null;
1607 return (
1608 <Breadcrumb className="min-w-0">
1609 <BreadcrumbList>
1610 <BreadcrumbItem>
1611 <BreadcrumbPage asChild className="flex items-center gap-2 hover:bg-raised">
1612 <Link to={`/u/${profile?.username ?? username}`}>
1613 <Avatar name={profile?.username ?? username} image={profile?.avatar ?? null} size={20} />
1614 <span className="truncate font-mono text-[0.8125rem]">@{profile ? shownUsername(profile) : username}</span>
1615 </Link>
1616 </BreadcrumbPage>
1617 </BreadcrumbItem>
1618 </BreadcrumbList>
1619 </Breadcrumb>
1620 );
1621}
1622
1623/** A page with no trail to it, such as Today or Search: its name alone. */
1624function Here({ children }: { children: ReactNode }) {
1625 return (
1626 <Breadcrumb className="min-w-0">
1627 <BreadcrumbList>
1628 <BreadcrumbItem>
1629 <BreadcrumbPage>{children}</BreadcrumbPage>
1630 </BreadcrumbItem>
1631 </BreadcrumbList>
1632 </Breadcrumb>
1633 );
1634}
1635
1636/** One link of the trail; `short` is what a phone shows when it is the page itself. */
1637type Crumb = { label: string; to: string; mono?: boolean; short?: string };
1638
1639/**
1640 * The trail of links. On a phone there is room for one: the page itself,
1641 * with a way back to where it sits; the whole trail from a wider screen up.
1642 */
1643function Trail({ trail }: { trail: Crumb[] }) {
1644 // Up on a phone, unless up is the workspace itself: its pages are the tabs.
1645 const up = trail.length > 1 && !/^\/[^/]+$/.test(trail[trail.length - 2]!.to) ? trail[trail.length - 2]! : null;
1646 return (
1647 <Breadcrumb className="flex min-w-0 items-center">
1648 {up && (
1649 <Button asChild variant="ghost" size="icon-bar" className="-ml-1 sm:hidden">
1650 <Link to={up.to} prefetch="intent" aria-label={`Back to ${up.label}`}>
1651 <ChevronLeft size={16} />
1652 </Link>
1653 </Button>
1654 )}
1655 <BreadcrumbList>
1656 {trail.map((crumb, index) => {
1657 const last = index === trail.length - 1;
1658 const label =
1659 last && crumb.short ? (
1660 <>
1661 <span className="sm:hidden">{crumb.short}</span>
1662 <span className="hidden sm:inline">{crumb.label}</span>
1663 </>
1664 ) : (
1665 crumb.label
1666 );
1667 const mono = crumb.mono ? "font-mono text-[0.8125rem]" : "";
1668 return (
1669 <Fragment key={index}>
1670 {index > 0 && <BreadcrumbSeparator className="max-sm:hidden" />}
1671 <BreadcrumbItem className={last ? "" : "max-sm:hidden"}>
1672 {last ? (
1673 // The page you are on is still a link: to its own top, as the trail always was.
1674 <BreadcrumbPage asChild className={`hover:bg-raised ${mono}`}>
1675 <Link to={crumb.to} prefetch="intent">
1676 {label}
1677 </Link>
1678 </BreadcrumbPage>
1679 ) : (
1680 <BreadcrumbLink asChild className={mono}>
1681 <Link to={crumb.to} prefetch="intent">
1682 {label}
1683 </Link>
1684 </BreadcrumbLink>
1685 )}
1686 </BreadcrumbItem>
1687 </Fragment>
1688 );
1689 })}
1690 </BreadcrumbList>
1691 </Breadcrumb>
1692 );
1693}
1694
1695type Command = PaletteCommand;
1696
1697/** Everything the palette can jump to, from what the sidebar already knows. */
1698function commandsFor(user: User, shell: ShellData): Command[] {
1699 const ws = shell.workspace;
1700 const commands: Command[] = [
1701 ...(ws
1702 ? [
1703 { label: "Home", to: homePagePath(ws.slug), icon: <House size={15} /> },
1704 { label: "Chat", to: `/${ws.slug}/-/chat`, icon: <MessagesSquare size={15} /> },
1705 { label: "Agents", to: `/${ws.slug}/-/agents`, icon: <Sparkles size={15} /> },
1706 ...(hasCodeAccess(ws) ? [{ label: "Code overview", to: `/${ws.slug}/-/overview`, icon: <Code2 size={15} /> }] : []),
1707 { label: "Artifacts", to: `/${ws.slug}/-/artifacts`, icon: <Shapes size={15} /> },
1708 { label: "Apps", hint: "Everything installed that you can use", to: `/${ws.slug}/-/apps`, icon: <LayoutGrid size={15} /> },
1709 { label: "Customize", hint: "Skills, connectors and plugins", to: `/${ws.slug}/-/customize`, icon: <SlidersHorizontal size={15} /> },
1710 { label: "Agent templates", hint: "Starting points for a new agent", to: `/${ws.slug}/-/agents/templates`, icon: <Bot size={15} /> },
1711 { label: "Workspace", hint: "Billing, policies, settings", to: `/${ws.slug}/-/workspace`, icon: <Building2 size={15} /> },
1712 ]
1713 : []),
1714 { label: "Explore repositories", to: "/explore", icon: <Compass size={15} /> },
1715 { label: "Search g1t", hint: "Repositories, code, issues, people", to: "/search", icon: <Search size={15} /> },
1716 { label: "Notifications", hint: "What needs you", to: "/notifications", icon: <Bell size={15} /> },
1717 { label: "New project", to: "/new", icon: <Plus size={15} /> },
1718 { label: "Your settings", to: FIRST_SETTINGS_PAGE, icon: <Settings size={15} /> },
1719 ...(Object.keys(ACCOUNT_SETTINGS) as AccountSettingsPage[])
1720 .filter((page) => page !== "profile")
1721 .map((page) => ({ label: ACCOUNT_SETTINGS[page].title, hint: "Your settings", to: `/settings/${page}`, icon: <Settings size={15} /> })),
1722 ...THEME_COMMANDS,
1723 ];
1724 const repo = shell.repo;
1725 if (repo) {
1726 const base = `/${repo.namespace}/${repo.name}`;
1727 const name = `${repo.namespace}/${repo.name}`;
1728 commands.unshift(
1729 { label: "Overview", hint: name, to: base, icon: <LayoutGrid size={15} /> },
1730 { label: "Code", hint: name, to: `${base}/code`, icon: <Code2 size={15} /> },
1731 { label: "Issues", hint: name, to: `${base}/issues`, icon: <CircleDot size={15} /> },
1732 { label: "New issue", hint: name, to: `${base}/issues/new`, icon: <Plus size={15} /> },
1733 ...(repo.member
1734 ? [{ label: `Put an agent on ${repo.name}`, hint: name, to: `${base}/issues/new?agent=1`, icon: <Sparkles size={15} /> }]
1735 : []),
1736 { label: "Pull requests", hint: name, to: `${base}/pulls`, icon: <GitPullRequest size={15} /> },
1737 { label: "Commits", hint: name, to: `${base}/commits`, icon: <History size={15} /> },
1738 ...(repo.member
1739 ? [
1740 { label: "Plan work", hint: name, to: `${base}/plans`, icon: <ListTree size={15} /> },
1741 { label: "Deployments", hint: name, to: `${base}/deployments`, icon: <Rocket size={15} /> },
1742 { label: "Secrets and variables", hint: name, to: `${base}/settings/secrets`, icon: <Lock size={15} /> },
1743 { label: "Project settings", hint: name, to: `${base}/settings`, icon: <Settings size={15} /> },
1744 { label: "Repository settings", hint: name, to: `${base}/settings/repository`, icon: <Settings size={15} /> },
1745 ]
1746 : []),
1747 );
1748 }
1749 for (const membership of user.workspaces ?? []) {
1750 commands.push(
1751 { label: displayName(membership), hint: `Workspace · ${membership.slug}`, to: `/${membership.slug}`, icon: <Avatar name={membership.slug} image={membership.avatar} size={15} square /> },
1752 { label: "All projects", hint: membership.slug, to: `/${membership.slug}/-/projects`, icon: <LayoutGrid size={15} /> },
1753 { label: "People", hint: membership.slug, to: `/${membership.slug}/-/people`, icon: <Users size={15} /> },
1754 { label: "Spend", hint: `${membership.slug} · Budgets and receipts`, to: `/${membership.slug}/-/spend`, icon: <Coins size={15} /> },
1755 { label: "Usage", hint: membership.slug, to: `/${membership.slug}/-/usage`, icon: <BarChart3 size={15} /> },
1756 { label: "AI Gateway", hint: `${membership.slug} · Usage`, to: `/${membership.slug}/-/gateway`, icon: <Network size={15} /> },
1757 { label: "Billing and plans", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/billing`, icon: <CreditCard size={15} /> },
1758 { label: "Access tokens", hint: `${membership.slug} · Settings`, to: `/${membership.slug}/-/tokens`, icon: <KeyRound size={15} /> },
1759 { label: "Integrations", hint: membership.slug, to: `/${membership.slug}/-/integrations`, icon: <Plug size={15} /> },
1760 { label: "Members", hint: `${membership.slug} · Access`, to: `/${membership.slug}/-/members`, icon: <Users size={15} /> },
1761 ...(membership.role === "owner"
1762 ? [
1763 { label: "Invitations", hint: `${membership.slug} · Access`, to: `/${membership.slug}/-/members/invitations`, icon: <Mail size={15} /> },
1764 { label: "Permissions", hint: `${membership.slug} · Access`, to: `/${membership.slug}/-/permissions`, icon: <ShieldCheck size={15} /> },
1765 ]
1766 : []),
1767 );
1768 }
1769 for (const listed of shell.repos) {
1770 commands.push({
1771 label: listed.title ?? listed.name,
1772 hint: `${listed.namespace} · Project`,
1773 to: `/${listed.namespace}/${listed.name}`,
1774 icon: <Box size={15} />,
1775 });
1776 }
1777 // "Put an agent on …": one per project, after the projects themselves.
1778 for (const listed of shell.repos) {
1779 if (repo && listed.namespace === repo.namespace && listed.name === repo.name) continue;
1780 commands.push({
1781 label: `Put an agent on ${listed.title ?? listed.name}`,
1782 hint: `${listed.namespace}/${listed.name}`,
1783 to: `/${listed.namespace}/${listed.name}/issues/new?agent=1`,
1784 icon: <Sparkles size={15} />,
1785 });
1786 }
1787 return commands;
1788}
1789
1790/**
1791 * The page while the next one loads: after a moment it dims, under the
1792 * bar below, so it is plainly on its way out rather than frozen, and the
1793 * next page fades up from there. Sending a form does not dim it: the
1794 * form's button says it is working. Spread on the element holding the page.
1795 */
1796export function useLeaving() {
1797 const navigation = useNavigation();
1798 const method = navigation.formMethod?.toUpperCase();
1799 const leaving = navigation.state === "loading" && (method == null || method === "GET");
1800 return {
1801 "aria-busy": leaving || undefined,
1802 className: `transition-opacity motion-reduce:transition-none ${leaving ? "opacity-60 delay-200 duration-300" : "duration-150"}`,
1803 };
1804}
1805
1806/**
1807 * A bar across the top of the page while the next one loads, as GitHub
1808 * has: it appears at once, creeps towards the end while waiting, then fills
1809 * and fades when the page arrives.
1810 */
1811export function Progress() {
1812 const navigation = useNavigation();
1813 const busy = navigation.state !== "idle";
1814 const [width, setWidth] = useState(0);
1815 const [visible, setVisible] = useState(false);
1816 useEffect(() => {
1817 if (busy) {
1818 setVisible(true);
1819 setWidth(12);
1820 // Slows as it goes, never quite arriving until the page does.
1821 const timer = setInterval(() => setWidth((now) => now + (90 - now) * 0.12), 200);
1822 return () => clearInterval(timer);
1823 }
1824 setWidth((now) => (now > 0 ? 100 : 0));
1825 const fade = setTimeout(() => setVisible(false), 250);
1826 const reset = setTimeout(() => setWidth(0), 550);
1827 return () => {
1828 clearTimeout(fade);
1829 clearTimeout(reset);
1830 };
1831 }, [busy]);
1832 return (
1833 <div
1834 aria-hidden="true"
1835 className={`pointer-events-none fixed inset-x-0 top-0 z-60 h-0.75 transition-opacity duration-300 ${
1836 visible ? "opacity-100" : "opacity-0"
1837 }`}
1838 >
1839 <div
1840 className="h-full bg-accent shadow-[0_0_10px_var(--color-accent)] transition-[width] duration-200 ease-out"
1841 style={{ width: `${width}%` }}
1842 />
1843 </div>
1844 );
1845}
1846
1847/**
1848 * The top bar's way to g1t: the direct message with the workspace's
1849 * orchestrator, opened or made. The one tinted control in the bar: the
1850 * lavender pixel 1 bare beside its words, on a wash of the accent.
1851 */
1852function AskG1tButton({ slug }: { slug: string }) {
1853 return (
1854 <Hint label="Ask g1t">
1855 <Button asChild variant="soft" size="bar" className="gap-2 max-md:ring-0 lg:px-3">
1856 <Link to={`/${slug}/-/chat?agent=g1t`} aria-label="Ask g1t">
1857 <MarkGlyph className="h-3.5" />
1858 <span className="max-lg:hidden">Ask g1t</span>
1859 </Link>
1860 </Button>
1861 </Hint>
1862 );
1863}
1864
1865/**
1866 * Which sidebar sits beside the page: each mode's own, or none. Home and
1867 * Apps are pages at full width, and so are g1t's public pages, such as a
1868 * profile, which are no workspace's. Without a workspace, only your own
1869 * settings and Notifications have one.
1870 */
1871function sidebarFor(mode: ModeKey, workspace: boolean): Panel | null {
1872 if (!workspace) return mode === "account" || mode === "notifications" ? mode : null;
1873 if (mode === "home" || mode === "apps" || mode === "site") return null;
1874 return mode;
1875}
1876
1877/** The sidebars that sit beside the page, one per mode that has one. */
1878type Panel = "chat" | "artifacts" | "agents" | "code" | "notifications" | "people" | "workspace" | "account";
1879
1880/** Each sidebar's name, for the button that opens it on a phone. */
1881const MODE_MENU: Record<Panel, string> = {
1882 chat: "Chat",
1883 artifacts: "Artifacts",
1884 agents: "Agents",
1885 code: "Code",
1886 notifications: "Notifications",
1887 people: "People",
1888 workspace: "Workspace",
1889 account: "Your account",
1890};
1891
1892/** Whether a key press happened in something you type into, where Ctrl B is the editor's. */
1893function typing(target: EventTarget | null): boolean {
1894 if (!(target instanceof HTMLElement)) return false;
1895 return target.isContentEditable || target.closest("input, textarea, select, [contenteditable=''], [contenteditable='true'], [role='textbox']") != null;
1896}
1897
1898/** Ctrl B (⌘B on a Mac) shows or hides the sidebar, except while typing. */
1899function useSidebarShortcut(toggle: () => void) {
1900 useEffect(() => {
1901 const onKey = (event: KeyboardEvent) => {
1902 if (event.key.toLowerCase() !== "b" || event.altKey || event.shiftKey || !(event.ctrlKey || event.metaKey)) return;
1903 if (event.defaultPrevented || typing(event.target)) return;
1904 event.preventDefault();
1905 toggle();
1906 };
1907 window.addEventListener("keydown", onKey);
1908 return () => window.removeEventListener("keydown", onKey);
1909 }, [toggle]);
1910}
1911
1912/**
1913 * Search or jump to: the command palette. On a computer it looks like the
1914 * field it opens, with its shortcut; on a phone, a magnifier.
1915 */
1916function SearchButton({ onClick, place }: { onClick: () => void; place: "bar" | "sidebar" }) {
1917 const field = (
1918 <Button
1919 variant="outline"
1920 size="sm"
1921 aria-label="Search or jump to"
1922 onClick={onClick}
1923 className={
1924 place === "sidebar"
1925 ? "w-full justify-start bg-bg font-normal text-faint hover:bg-bg hover:text-muted"
1926 : "mr-1 w-[min(18rem,26vw)] justify-start bg-surface font-normal text-faint hover:bg-surface hover:text-muted max-md:hidden"
1927 }
1928 >
1929 <Search size={15} />
1930 <span className="grow truncate text-left">Search or jump to</span>
1931 <PaletteKey className="px-1.5 text-[0.625rem] leading-4 text-muted" />
1932 </Button>
1933 );
1934 if (place === "sidebar") return field;
1935 return (
1936 <>
1937 <Button variant="ghost" size="icon-bar" aria-label="Search or jump to" onClick={onClick} className="md:hidden">
1938 <Search size={18} />
1939 </Button>
1940 {field}
1941 </>
1942 );
1943}
1944
1945/** The sidebar's shortcut, for the hint on its toggle. */
1946function useSidebarKey(): string {
1947 return sidebarKeyLabel(typeof navigator === "undefined" ? null : navigator.platform);
1948}
1949
1950/**
1951 * The app: three surfaces that never blur together. The rail, a narrow
1952 * column of icons down the window's left edge; the mode's sidebar, flat
1953 * against it with a hairline between, which folds away with Ctrl B and is
1954 * a drawer below 1024px; and the page, flat against the sidebar and
1955 * filling the rest of the window, with its top bar across the top and a
1956 * line under it: the sidebar's toggle, where you are, search, Ask g1t and
1957 * Create new. On a phone the rail is a bar along the bottom and the page
1958 * fills the window above it, flat as well. Only for someone signed in; without a workspace yet, there
1959 * is no rail. The rail and the sidebar are drawn from the sidebar kit
1960 * (components/ui/sidebar.tsx): one provider holds whether the sidebar is
1961 * open on a computer and whether the drawer is.
1962 */
1963export function AppShell({
1964 user,
1965 shell,
1966 missing = false,
1967 banner,
1968 sidebarClosed = false,
1969 children,
1970}: {
1971 user: User;
1972 shell: ShellData;
1973 /** The page is a 404 (see CodeSidebar). */
1974 missing?: boolean;
1975 banner?: ReactNode;
1976 /** Whether the person folded the sidebar away, as their cookie says. */
1977 sidebarClosed?: boolean;
1978 children: ReactNode;
1979}) {
1980 const { pathname } = useLocation();
1981 const [drawer, setDrawer] = useState(false);
1982 const [closed, setClosed] = useState(sidebarClosed);
1983 const [palette, setPalette] = useState(false);
1984 const commands = useMemo(() => commandsFor(user, shell), [user, shell]);
1985
1986 // A new page closes the drawer.
1987 useEffect(() => setDrawer(false), [pathname]);
1988 usePaletteShortcut(() => setPalette((open) => !open));
1989 // In the desktop app, search is in the middle of its title bar, as in Slack, and not in the top bar too.
1990 const titleSearch = useTitleBarSearch(`Search ${shell.workspace?.name ?? shell.workspace?.slug ?? "g1t"}`, () => setPalette(true));
1991 const leaving = useLeaving();
1992 useVisualViewport();
1993 const going = useNavigation().location?.pathname;
1994 const ws = shell.workspace;
1995 const mode = modeOf(going ?? pathname, ws?.slug ?? null);
1996 const panel = sidebarFor(mode, ws != null);
1997 const code = ws ? hasCodeAccess(ws) : false;
1998 const { sidebar: chatSidebar } = useChatSidebar();
1999 // Notify: the feed socket's live counts (lib/notify-client.ts) once it has them; the page's until then.
2000 const live = useLiveBadges(ws?.slug);
2001 const chatUnread = chatSidebar
2002 ? unreadTotals(chatSidebar.entries)
2003 : live?.chat != null
2004 ? { unread: live.chat, mentions: live.mentions ?? 0 }
2005 : (shell.chat ?? { unread: 0, mentions: 0 });
2006 const notificationsUnread = live?.inbox ?? shell.inbox?.unread ?? 0;
2007 const unread = { notifications: notificationsUnread, chat: chatUnread.unread, mentions: chatUnread.mentions };
2008
2009 // Folding the sidebar away on a computer is remembered, so the next page is drawn the same from the server.
2010 const toggleSidebar = useCallback(() => {
2011 if (!window.matchMedia("(min-width: 1024px)").matches) {
2012 setDrawer((open) => !open);
2013 return;
2014 }
2015 setClosed((was) => {
2016 document.cookie = sidebarCookie(!was, window.location.protocol === "https:");
2017 return !was;
2018 });
2019 }, []);
2020 useSidebarShortcut(useCallback(() => {
2021 if (panel) toggleSidebar();
2022 }, [panel, toggleSidebar]));
2023
2024 const inline = panel != null && !closed;
2025 const sidebarNode = () => {
2026 if (!panel) return null;
2027 if (!ws) return panel === "notifications" ? <NotificationsSidebar counts={shell.inbox ?? null} /> : <AccountSidebar username={user.username} />;
2028 switch (panel) {
2029 case "code":
2030 return <CodeSidebar user={user} shell={shell} missing={missing} />;
2031 case "chat":
2032 return <ChatSidebar slug={ws.slug} />;
2033 case "artifacts":
2034 return <FoliosSidebar slug={ws.slug} />;
2035 case "agents":
2036 return <AgentsSidebar slug={ws.slug} shellAgents={shell.agents ?? null} code={code} owner={ws.role === "owner"} />;
2037 case "notifications":
2038 return <NotificationsSidebar counts={shell.inbox ?? null} />;
2039 case "people":
2040 return <PeopleSidebar slug={ws.slug} />;
2041 case "workspace":
2042 return <WorkspaceSidebar slug={ws.slug} owner={ws.role === "owner"} />;
2043 case "account":
2044 return <AccountSidebar username={user.username} />;
2045 }
2046 };
2047 const sidebarKey = useSidebarKey();
2048 // Search or jump to sits at the top of the sidebar, except in Chat and
2049 // Artifacts, whose sidebars search their own lists: there it stays in the bar.
2050 const sidebarSearch = panel != null && panel !== "chat" && panel !== "artifacts";
2051 // The sidebar's head: the workspace and its switcher, the way to fold the
2052 // sidebar or close the drawer, and search, which opens the palette.
2053 const sidebarTop = (inDrawer: boolean) => (
2054 <SidebarHeader className="gap-1 px-2 pt-0 pb-2">
2055 <div className="flex h-14 shrink-0 items-center gap-1">
2056 {ws ? (
2057 <WorkspaceSwitcher user={user} workspace={ws} />
2058 ) : (
2059 <Link to="/" aria-label="g1t" className="mr-auto flex h-9 items-center rounded-md px-2">
2060 <Logo className="text-[1.125rem]" />
2061 </Link>
2062 )}
2063 {inDrawer ? (
2064 <Button type="button" aria-label="Close menu" onClick={() => setDrawer(false)} variant="ghost" size="icon-sm" className="text-faint">
2065 <X size={16} />
2066 </Button>
2067 ) : (
2068 <SidebarTrigger hint={`Hide the sidebar (${sidebarKey})`} className="text-faint" />
2069 )}
2070 </div>
2071 {sidebarSearch && <SearchButton place="sidebar" onClick={() => setPalette(true)} />}
2072 </SidebarHeader>
2073 );
2074
2075 // On a phone (below 768px): the bottom bar, and a conversation full screen.
2076 const conversation = isConversation(going ?? pathname);
2077 // Where the page panel starts: 8px past the rail (56px), or 8px past the sidebar (56 + 240px) when it is open.
2078 // The page starts where the rail (3.5rem) and, open, the sidebar (15rem) end.
2079 const pad = ws ? (inline ? "md:pl-14 lg:pl-[18.5rem]" : "md:pl-14") : inline ? "lg:pl-[15rem]" : "";
2080
2081 return (
2082 <SidebarProvider open={!closed} onOpenChange={(open) => setClosed(!open)} openMobile={drawer} onOpenMobileChange={setDrawer} toggleSidebar={toggleSidebar}>
2083 <Progress />
2084 {ws && (
2085 <div className="fixed top-(--frame-top) bottom-0 left-0 z-40 hidden md:block">
2086 <Rail workspace={ws} pins={shell.pins ?? []} unread={unread} account={<AccountMenu user={user} />} />
2087 </div>
2088 )}
2089 {panel && (
2090 <Sidebar
2091 role="complementary"
2092 aria-label={`${MODE_MENU[panel]} sidebar`}
2093 className={`fixed top-(--frame-top) bottom-0 z-40 max-lg:hidden ${ws ? "left-14" : "left-0"}`}
2094 >
2095 {sidebarTop(false)}
2096 <div className="min-h-0 grow">{sidebarNode()}</div>
2097 </Sidebar>
2098 )}
2099 {/* The drawer is a sheet: a dialog that holds focus, closes on Escape or
2100 a tap outside, and gives focus back to the button that opened it. */}
2101 {panel && (
2102 <SidebarMobile title={`${MODE_MENU[panel]} menu`} className="pb-[env(safe-area-inset-bottom)] max-md:[&_nav_a]:min-h-10">
2103 {sidebarTop(true)}
2104 <div className="min-h-0 grow">{sidebarNode()}</div>
2105 </SidebarMobile>
2106 )}
2107
2108 <div className={`min-h-dvh pt-(--frame-top) pb-(--tabbar-h) ${pad}`}>
2109 {/* The top bar always has its line, so a page's own header (data-page-head: a conversation's, a project's,
2110 a sticky one under an open artifact) sits under it as its own band. */}
2111 <div className="flex min-h-[calc(100dvh-var(--frame-top)-var(--tabbar-h))] min-w-0 flex-col bg-bg">
2112 <header
2113 className={`sticky top-(--frame-top) z-30 flex h-14 items-center gap-1 border-b border-line bg-bg pr-2 pl-2 sm:pr-3 ${inline ? "lg:pl-3.5" : ""} ${conversation ? "max-md:hidden" : ""}`}
2114 >
2115 {panel && (
2116 <SidebarTrigger
2117 hint={`Show the sidebar (${sidebarKey})`}
2118 aria-label={drawer ? "Hide the sidebar" : "Show the sidebar"}
2119 aria-expanded={drawer}
2120 className={`max-md:size-11 ${inline ? "lg:hidden" : ""}`}
2121 />
2122 )}
2123 {ws && (
2124 <span className={`flex min-w-0 shrink items-center gap-1.5 ${inline ? "lg:hidden" : ""}`}>
2125 <WorkspaceSwitcher user={user} workspace={ws} compact />
2126 <span aria-hidden="true" className="text-line-strong">
2127 /
2128 </span>
2129 </span>
2130 )}
2131 <Breadcrumbs pathname={pathname} missing={missing} repo={shell.repo} workspace={ws?.slug ?? null} />
2132 {/* Search, then what's yours (spend, Ask g1t), then the bell and Create new: one height, one rhythm. */}
2133 <div className="ml-auto flex shrink-0 items-center gap-1 md:gap-1.5">
2134 {/* With the sidebar open, search is at its top. */}
2135 {!titleSearch && (
2136 <span className={`flex ${inline && sidebarSearch ? "lg:hidden" : ""}`}>
2137 <SearchButton place="bar" onClick={() => setPalette(true)} />
2138 </span>
2139 )}
2140 {/* Your spend this month, or the workspace's for owners and billing managers; on a phone it is on Spend. */}
2141 {ws && (
2142 <span className="flex max-md:hidden">
2143 <SpendPill slug={ws.slug} mayWorkspace={ws.role === "owner" || !!ws.org_roles?.includes("billing_manager")} />
2144 </span>
2145 )}
2146 {ws && <AskG1tButton slug={ws.slug} />}
2147 <Separator orientation="vertical" className="mx-1 data-[orientation=vertical]:h-5 max-md:hidden" />
2148 {/* On a phone, Notifications is in the bottom bar. */}
2149 <span className="flex max-md:hidden">
2150 <NotificationsBell counts={shell.inbox ? { ...shell.inbox, unread: notificationsUnread } : null} />
2151 </span>
2152 <CreateMenu shell={shell} />
2153 {/* Without a workspace there is no rail: the account is here. */}
2154 {!ws && <AccountMenu user={user} side="bottom" />}
2155 </div>
2156 </header>
2157 {banner}
2158 <main id="content" tabIndex={-1} {...leaving} className={`min-w-0 grow outline-none ${leaving.className}`}>
2159 <InMain.Provider value={true}>{children}</InMain.Provider>
2160 </main>
2161 </div>
2162 </div>
2163 {ws && <BottomBar user={user} workspace={ws} pins={shell.pins ?? []} unread={unread} onReselect={panel ? () => setDrawer(true) : undefined} />}
2164 <CommandPalette open={palette} onOpenChange={setPalette} commands={commands} repo={shell.repo ? `${shell.repo.namespace}/${shell.repo.name}` : null} />
2165 </SidebarProvider>
2166 );
2167}
2168
2169/** Create new: a project, an issue in the one you are in, a workspace or a team. */
2170function CreateMenu({ shell }: { shell: ShellData }) {
2171 return (
2172 <DropdownMenu>
2173 <Hint label="Create new">
2174 <DropdownMenuTrigger asChild>
2175 <Button variant="ghost" size="bar" aria-label="Create new" className="gap-0.5 px-1.5 text-fg/90">
2176 <Plus size={17} className="max-md:size-5" />
2177 <ChevronDown size={12} className="text-faint max-md:hidden" />
2178 </Button>
2179 </DropdownMenuTrigger>
2180 </Hint>
2181 <DropdownMenuContent align="end" className="min-w-52">
2182 {shell.repo && (
2183 <>
2184 <DropdownMenuLabel className="truncate">In {shell.repo.name}</DropdownMenuLabel>
2185 <DropdownMenuItem asChild>
2186 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/issues/new`}>
2187 <CircleDot />
2188 New issue
2189 </Link>
2190 </DropdownMenuItem>
2191 {shell.repo.member && (
2192 <DropdownMenuItem asChild>
2193 <Link to={`/${shell.repo.namespace}/${shell.repo.name}/plans`}>
2194 <ListTree />
2195 Plan work
2196 </Link>
2197 </DropdownMenuItem>
2198 )}
2199 <DropdownMenuSeparator />
2200 </>
2201 )}
2202 <DropdownMenuItem asChild>
2203 <Link to="/new">
2204 <Box />
2205 New project
2206 </Link>
2207 </DropdownMenuItem>
2208 <DropdownMenuItem asChild>
2209 <Link to="/new/github">
2210 <GitBranch />
2211 Import from GitHub
2212 </Link>
2213 </DropdownMenuItem>
2214 {/* A team in the workspace you are in, for whoever it lets create one. A new workspace is made from the workspace switcher in the rail. */}
2215 {shell.workspace && <DropdownMenuSeparator />}
2216 {shell.workspace &&
2217 (mayCreateTeams(shell.workspace.team_creation, shell.workspace.role) ? (
2218 <DropdownMenuItem asChild>
2219 <Link to={`/${shell.workspace.slug}/-/teams/new`}>
2220 <UsersRound />
2221 New team
2222 </Link>
2223 </DropdownMenuItem>
2224 ) : (
2225 <DropdownMenuItem disabled>
2226 <UsersRound />
2227 New team
2228 <span className="ml-auto pl-3 text-xs text-faint">Owners only</span>
2229 </DropdownMenuItem>
2230 ))}
2231 </DropdownMenuContent>
2232 </DropdownMenu>
2233 );
2234}