Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 1 | import { ArrowRight, Box, ShieldCheck, Sparkles, Users } from "lucide-react"; |
| 2 | import type { ReactNode } from "react"; | |
| 3 | import { Link, data } from "react-router"; | |
| 4 | ||
| 5 | import type { Route } from "./+types/workspace-overview"; | |
| 6 | import { Avatar, Pill } from "../../components/ui"; | |
| 7 | import { UsageCard } from "../../components/usage-card"; | |
| 8 | import { identity, workspaceAgents } from "../../lib/services.server"; | |
| 9 | import { getViewer, roleIn } from "../../lib/session.server"; | |
| 10 | import { usageFor } from "../../lib/workspace-usage.server"; | |
| 11 | import { workspaceProjects } from "../../lib/workspace-projects.server"; | |
| 12 | import { page } from "../../lib/meta"; | |
| 13 | ||
| 14 | export function meta({ params, ...args }: Route.MetaArgs) { | |
| 15 | return page(args, { title: `Workspace · ${params.owner} · g1t` }); | |
| 16 | } | |
| 17 | ||
| 18 | /** Most members listed before "and N more". */ | |
| 19 | const MAX_FACES = 10; | |
| 20 | ||
| 21 | /** | |
| 22 | * The workspace at a glance, for every member: who is in it, its projects | |
| 23 | * and agents, and the month's usage against its plan. Each part is left out | |
| 24 | * when its service does not answer. | |
| 25 | */ | |
| 26 | export async function loader({ params, context }: Route.LoaderArgs) { | |
| 27 | const viewer = getViewer(context); | |
| 28 | const slug = params.owner.toLowerCase(); | |
| 29 | const role = roleIn(viewer, slug); | |
| 30 | if (!role) throw data(null, { status: 404 }); | |
| 31 | const [members, usage, projects, agents] = await Promise.all([ | |
| 32 | identity.listMembers(slug, viewer).catch(() => null), | |
| 33 | usageFor(slug, viewer), | |
| 34 | workspaceProjects(slug, viewer).catch(() => null), | |
| 35 | workspaceAgents.list(slug, viewer!).catch(() => null), | |
| 36 | ]); | |
| 37 | return { | |
| 38 | slug, | |
| 39 | role, | |
| 40 | members: members?.ok ? members.value : null, | |
| 41 | usage, | |
| 42 | projects: projects?.ok ? projects.value.length : null, | |
| 43 | agents: agents?.ok ? agents.value.filter((agent) => !agent.archived_at).length : null, | |
| 44 | }; | |
| 45 | } | |
| 46 | ||
| 47 | function Tile({ icon, label, value, to, action }: { icon: ReactNode; label: string; value: string; to: string; action: string }) { | |
| 48 | return ( | |
| 49 | <Link to={to} className="group rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong"> | |
| 50 | <p className="flex items-center gap-1.5 text-xs text-muted"> | |
| 51 | {icon} | |
| 52 | {label} | |
| 53 | </p> | |
| 54 | <p className="mt-1.5 text-2xl font-semibold tracking-tight tabular-nums">{value}</p> | |
| 55 | <p className="mt-0.5 flex items-center gap-1 text-xs text-faint group-hover:text-muted"> | |
| 56 | {action} <ArrowRight size={11} /> | |
| 57 | </p> | |
| 58 | </Link> | |
| 59 | ); | |
| 60 | } | |
| 61 | ||
| 62 | export default function WorkspaceOverview({ loaderData }: Route.ComponentProps) { | |
| 63 | const { slug, role, members, usage, projects, agents } = loaderData; | |
| 64 | return ( | |
| 65 | <div className="space-y-8"> | |
| 66 | <div className="grid grid-cols-1 gap-3 sm:grid-cols-3"> | |
| 67 | <Tile icon={<Users size={12} />} label="Members" value={members ? String(members.length) : "—"} to={`/${slug}/-/people`} action={role === "owner" ? "Manage people" : "See everyone"} /> | |
| 68 | <Tile icon={<Sparkles size={12} />} label="Agents" value={agents == null ? "—" : String(agents)} to={`/${slug}/-/agents`} action="Open Agents" /> | |
| 69 | <Tile icon={<Box size={12} />} label="Projects" value={projects == null ? "—" : String(projects)} to={`/${slug}/-/projects`} action="Open Code" /> | |
| 70 | </div> | |
| 71 | <div className="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]"> | |
| 72 | <div className="space-y-6"> | |
| 73 | {usage ? ( | |
| 74 | <UsageCard slug={slug} glance={usage} owner={role === "owner"} /> | |
| 75 | ) : ( | |
| 76 | <section className="rounded-xl border border-line bg-surface p-5"> | |
| 77 | <h2 className="font-medium">Usage</h2> | |
| 78 | <p className="mt-1.5 text-sm text-muted">This month's usage isn't available right now.</p> | |
| 79 | <Link to={`/${slug}/-/usage`} className="mt-3 inline-flex items-center gap-1 text-sm text-accent hover:underline"> | |
| 80 | Open Usage <ArrowRight size={13} /> | |
| 81 | </Link> | |
| 82 | </section> | |
| 83 | )} | |
| 84 | <section className="rounded-xl border border-line bg-surface p-5"> | |
| 85 | <h2 className="flex items-center gap-2 font-medium"> | |
| 86 | <ShieldCheck size={15} className="text-faint" /> | |
| 87 | Policies | |
| 88 | </h2> | |
| 89 | <p className="mt-1.5 text-sm text-muted"> | |
| 90 | What agents may reach, run and spend, the rules every repository follows, and how the workspace's security is set up. | |
| 91 | </p> | |
| 92 | <div className="mt-3 flex flex-wrap gap-x-4 gap-y-1 text-sm"> | |
| 93 | <Link to={`/${slug}/-/guardrails`} className="text-accent hover:underline"> | |
| 94 | Guardrails | |
| 95 | </Link> | |
| 96 | <Link to={`/${slug}/-/rules`} className="text-accent hover:underline"> | |
| 97 | Rules | |
| 98 | </Link> | |
| 99 | <Link to={`/${slug}/-/security/settings`} className="text-accent hover:underline"> | |
| 100 | Security settings | |
| 101 | </Link> | |
| 102 | <Link to={`/${slug}/-/audit`} className="text-accent hover:underline"> | |
| 103 | Audit log | |
| 104 | </Link> | |
| 105 | </div> | |
| 106 | </section> | |
| 107 | </div> | |
| 108 | <section className="self-start rounded-xl border border-line bg-surface p-5"> | |
| 109 | <div className="flex items-center justify-between"> | |
| 110 | <h2 className="font-medium">Members</h2> | |
| 111 | <Link to={`/${slug}/-/people`} className="text-xs text-muted hover:text-fg"> | |
| 112 | {role === "owner" ? "Manage" : "See all"} | |
| 113 | </Link> | |
| 114 | </div> | |
| 115 | {members ? ( | |
| 116 | <> | |
| 117 | <ul className="mt-3 space-y-2"> | |
| 118 | {members.slice(0, MAX_FACES).map((member) => ( | |
| 119 | <li key={member.username} className="flex items-center gap-2.5 text-sm"> | |
| 120 | <Avatar name={member.username} image={member.avatar} size={24} /> | |
| 121 | <Link to={`/u/${member.username}`} className="min-w-0 grow truncate hover:text-accent"> | |
| 122 | {member.name?.trim() || member.username} | |
| 123 | {member.name?.trim() && <span className="ml-1.5 font-mono text-xs text-faint">{member.username}</span>} | |
| 124 | </Link> | |
| 125 | {member.role === "owner" && <Pill>owner</Pill>} | |
| 126 | </li> | |
| 127 | ))} | |
| 128 | </ul> | |
| 129 | {members.length > MAX_FACES && <p className="mt-2 text-xs text-faint">and {members.length - MAX_FACES} more</p>} | |
| 130 | </> | |
| 131 | ) : ( | |
| 132 | <p className="mt-3 text-sm text-muted">The member list isn't available right now.</p> | |
| 133 | )} | |
| 134 | </section> | |
| 135 | </div> | |
| 136 | </div> | |
| 137 | ); | |
| 138 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.