flagon-io/g1t

public

Git for AI scale: a forge for thousands of agents working on the same code at once.

g1t/apps/sudo/app/lib/nav.ts

376 lines16,192 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales1/**
2 * sudo's navigation, and the roadmap for what g1t is building in house:
3 * its own CRM and back office, in place of bought ones. Each item is a
4 * real page. One marked `soon` renders a placeholder that says what it
5 * will do and why, so staff can see where sudo is going (routes.ts makes
6 * a route for each). No Workers or React imports, so it can be tested
7 * under Node.
8 */
9
10/** The icon a sidebar item shows; components/shell.tsx draws each one. */
11export type NavIcon =
12 | "overview"
13 | "workspaces"
14 | "enterprises"
15 | "reach-out"
16 | "people"
17 | "invoices"
18 | "prices"
19 | "credits"
20 | "usage"
21 | "stripe"
22 | "costs"
23 | "agents"
24 | "abuse"
25 | "inbox"
26 | "view-as"
27 | "announcements"
28 | "staff"
29 | "audit"
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look30 | "requests"
31 | "overages"
32 | "velocity"
33 | "invites"
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales34 // Sections
35 | "customers"
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look36 | "spend"
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales37 | "revenue"
38 | "platform"
39 | "support"
40 | "team";
41
42/** What a page that is not built yet says about itself. */
43export type Roadmap = {
44 /** What it will do and why, two to four sentences. */
45 summary: string[];
46 /** What it will have, one line each. */
47 plans: string[];
48 /** Something staff should know now, such as where to go meanwhile. */
49 meanwhile?: { text: string; to?: string; link?: string };
50};
51
52export type NavItem = {
53 label: string;
54 /** Where it lives. A `soon` item's page is the placeholder. */
55 to: string;
56 icon: NavIcon;
57 /** One line, shown on hover. */
58 about: string;
59 /** Other paths under which this item is the current one. */
60 also?: string[];
61 /** Not built yet: the page says what it will be. */
62 soon?: Roadmap;
63};
64
65/**
66 * A section of the sidebar: a row with an icon that opens to its pages,
67 * as GitLab and Vercel fold theirs. One with no title is top-level links.
68 */
69export type NavGroup = { title: string | null; icon?: NavIcon; items: NavItem[] };
70
71export const NAV: NavGroup[] = [
72 {
73 title: null,
74 items: [
75 { label: "Overview", to: "/", icon: "overview", about: "The business at a glance: this month, the last six, and who needs a word." },
76 { label: "Reach out", to: "/reach-out", icon: "reach-out", about: "Who is worth a word now, and who on the team has it." },
77 ],
78 },
79 {
80 title: "Customers",
81 icon: "customers",
82 items: [
83 { label: "Workspaces", to: "/workspaces", icon: "workspaces", about: "Every workspace, who owns it, and how it pays." },
84 { label: "Enterprises", to: "/enterprises", icon: "enterprises", about: "Customers paying for several workspaces with one bill." },
85 {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look86 label: "Invites",
87 to: "/invites",
88 icon: "invites",
89 about: "The waitlist, every invite, more invites for a person or workspace, and who invited whom.",
90 },
91 {
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales92 label: "People",
93 to: "/people",
94 icon: "people",
95 about: "Everyone with a g1t account, across the workspaces they belong to.",
96 soon: {
97 summary: [
98 "Every person with a g1t account, not just the workspaces they belong to. Support starts from a person far more often than from a workspace: someone writes in from an email address, and staff need to find them, see which workspaces they own or belong to, and what they did lately.",
99 "It gives sales a view of contacts as well as accounts: the owner who signs, the engineer who brought g1t in, and who to ask when a workspace goes quiet.",
100 ],
101 plans: [
102 "Search by username, email or name, across every account",
103 "A person's page: their workspaces and role in each, sign-ins, verified email, two-factor status",
104 "Contacts on a workspace: who is the buyer, who is technical, who to bill",
105 "Merge duplicate accounts, and resend or change a verification email, each recorded",
106 ],
107 meanwhile: { text: "Search a workspace by an owner's username or email on Workspaces.", to: "/workspaces", link: "Workspaces" },
108 },
109 },
110 ],
111 },
112 {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look113 title: "Spend",
114 icon: "spend",
115 items: [
116 {
117 label: "Requests",
118 to: "/requests",
119 icon: "requests",
120 about: "Owners asking for a higher limit or help with a month: answered within one business day.",
121 },
122 {
123 label: "Overages",
124 to: "/overages",
125 icon: "overages",
126 about: "Workspaces well past their typical month, what caused it, and goodwill credits.",
127 },
128 {
129 label: "Velocity",
130 to: "/velocity",
131 icon: "velocity",
132 about: "Who is spending fastest right now, against their usual hour, and any spikes.",
133 },
134 ],
135 },
136 {
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales137 title: "Revenue",
138 icon: "revenue",
139 items: [
140 {
141 label: "Invoices",
142 to: "/invoices",
143 icon: "invoices",
144 about: "Every invoice g1t has sent, to workspaces and enterprises.",
145 },
146 {
147 label: "Plans & prices",
148 to: "/prices",
149 icon: "prices",
150 about: "The price book: what each meter costs g1t and what it sells for.",
151 soon: {
152 summary: [
153 "The price book, edited in sudo instead of in code. Every metered unit (sandbox seconds, builds, app requests and CPU, app-months) has what it costs g1t and what g1t sells it for, and the price follows the cost with a markup.",
154 "Changing a markup or a plan's price is a decision finance makes and should be able to make safely: previewed against last month's usage, with a date it takes effect, and recorded with who made it and why.",
155 ],
156 plans: [
157 "Each meter's cost, markup and price, and where the cost came from (Cloudflare's list price or its bill)",
158 "Edit a markup or a plan's monthly price, with a preview of what last month would have charged",
159 "Schedule a change for the start of a month, so no one is charged mid-month on a new price",
160 "Every change in the history the public pricing page already shows",
161 ],
162 },
163 },
164 {
165 label: "Credits & refunds",
166 to: "/credits",
167 icon: "credits",
168 about: "Every credit and refund staff have issued, and why.",
169 soon: {
170 summary: [
171 "Every credit and refund staff have given, across all customers: how much, to whom, by whom and why. Goodwill is a cost, and finance needs to see what it adds up to each month.",
172 "It is also where refunds to a card will live. Today a credit goes to a workspace's balance; giving money back to the card it came from goes through Stripe, and should be done from here, recorded, with the same typed confirmation as a credit.",
173 ],
174 plans: [
175 "Every credit, filterable by staff member, workspace and month, with totals",
176 "Refund a payment to the card it came from, in full or in part",
177 "Per-role limits: support can credit up to a set amount; more needs finance",
178 "Reasons as a short list (outage, billing error, goodwill, trial) so they can be counted",
179 ],
180 meanwhile: { text: "Issue a credit from the workspace's page, under Billing.", to: "/workspaces", link: "Workspaces" },
181 },
182 },
183 {
184 label: "Usage explorer",
185 to: "/usage",
186 icon: "usage",
187 about: "What customers used, sliced by meter, model, repository and day.",
188 soon: {
189 summary: [
190 "What customers used, across every workspace, sliced any way: by meter, model, repository, task and day. It answers the questions that come up in a sales call or a cost review: who uses the most sandbox time, which model costs most, what a customer's agents spend per pull request.",
191 "Billing records every run and sandbox second with its cost and charge already. This puts it in front of the people who need it, without a query.",
192 ],
193 plans: [
194 "Charged, cost and margin over any range, for everyone or one customer",
195 "Group by meter, model, task, repository or workspace; compare two periods",
196 "The heaviest workspaces this month, and how fast each is growing",
197 "Export to CSV",
198 ],
199 },
200 },
201 ],
202 },
203 {
204 title: "Platform",
205 icon: "platform",
206 items: [
207 { label: "Stripe", to: "/stripe", icon: "stripe", about: "Billing's Stripe keys, webhook, and the events Stripe sent." },
208 {
209 label: "Cloudflare costs",
210 to: "/costs",
211 icon: "costs",
212 about: "What running g1t costs on Cloudflare, measured, against what it charges.",
213 soon: {
214 summary: [
215 "What running g1t actually costs on Cloudflare, as the keeper measures it from Cloudflare's bill, against what g1t charges for the same usage. Prices follow costs, so this is where staff see whether they still do.",
216 "When a cost moves, the keeper updates the price book; this page shows what it measured, when, and the margin each meter earns as a result.",
217 ],
218 plans: [
219 "Each meter's measured cost per unit, the list price, and when the keeper last checked",
220 "Margin by meter and in total, this month and the last six",
221 "Cloudflare's invoice against what g1t charged for the same period",
222 "An alert when a meter's margin drops below its markup",
223 ],
224 },
225 },
226 {
227 label: "Agents & models",
228 to: "/agents",
229 icon: "agents",
230 about: "The models agents run on, what each costs, and how runs are going.",
231 soon: {
232 summary: [
233 "The models g1t's agents run on, and how they are doing: runs, failures, tokens and cost per model, and which workspaces bring their own provider. It is where staff decide which models to offer and see what a change in a provider's price means.",
234 "Hosted models are open to some workspaces and not others; that list belongs here, edited and recorded, not in configuration.",
235 ],
236 plans: [
237 "Runs, failures and cost per model, per day",
238 "Who may use g1t's hosted models, and the free allowance's pool",
Prices are what g1t pays plus 20%, from the first second239 "Workspaces on their own provider, and the sandbox time their runs use",
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales240 "Stuck or long-running agents, with a way to stop one",
241 ],
242 },
243 },
244 {
245 label: "Abuse & fraud",
246 to: "/abuse",
247 icon: "abuse",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look248 about: "Sandboxes stopped for looking like mining, and disputes and declines.",
A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales249 },
250 ],
251 },
252 {
253 title: "Support",
254 icon: "support",
255 items: [
256 {
257 label: "Inbox",
258 to: "/inbox",
259 icon: "inbox",
260 about: "Customers' messages, beside everything about who sent them.",
261 soon: {
262 summary: [
263 "Customers' email and in-app messages in one queue, each beside everything sudo knows about who sent it: their workspaces, what they pay, their limit, their last invoice, and the notes sales kept. Support answers faster when nothing needs looking up.",
264 "Built in house so a conversation can become an action without leaving it: a credit, a billing link, a note on the workspace.",
265 ],
266 plans: [
267 "Assign, snooze and close conversations; see who is answering what",
268 "The sender's workspaces, plan, limit and recent invoices alongside",
269 "Saved replies, and links that open the right page in g1t",
270 "Response times by person and by week",
271 ],
272 },
273 },
274 {
275 label: "View as customer",
276 to: "/view-as",
277 icon: "view-as",
278 about: "See g1t as a customer sees it, audited and time-limited.",
279 soon: {
280 summary: [
281 "See g1t exactly as a customer sees it, to reproduce what they describe. Read-only by default, it is the most sensitive thing staff can do, so it is built to be safe first.",
282 "Every session will be audited and time-limited: it needs a reason, it ends on its own, the customer's own audit log says that g1t staff looked, and nothing can be changed or any secret read while viewing.",
283 ],
284 plans: [
285 "Start a session with a reason (a support conversation or a note); it ends after 30 minutes",
286 "Read-only: no pushes, no settings, no secrets, no billing changes",
287 "A banner on every page while it lasts, and a record in the customer's audit log",
288 "Only roles allowed to, and a list of every session for review",
289 ],
290 },
291 },
292 {
293 label: "Announcements",
294 to: "/announcements",
295 icon: "announcements",
296 about: "Banners and notices for customers: incidents, maintenance, changes.",
297 soon: {
298 summary: [
299 "Tell customers what they need to know, from one place: a banner for an incident or maintenance, a notice about a price change, an email to the owners of the workspaces a change affects.",
300 "Notices can go to everyone or to a slice (owners on an enterprise, workspaces near their limit), with a start and an end, and a record of who sent what.",
301 ],
302 plans: [
303 "Banners in g1t with a start, an end, and a severity",
304 "Email to owners of chosen workspaces, previewed before it goes",
305 "Price-change notices with the notice period the terms require",
306 "A history of everything announced",
307 ],
308 },
309 },
310 ],
311 },
312 {
313 title: "Team",
314 icon: "team",
315 items: [
316 {
317 label: "Staff & roles",
318 to: "/staff",
319 icon: "staff",
320 about: "Who is staff, and what each role may do.",
321 soon: {
322 summary: [
323 "Who is g1t staff and what each of them may do. Today everyone in STAFF_EMAILS may do everything; as the team grows, roles should match the work: sales can see accounts and keep notes but cannot credit, support can make billing links and small credits, finance can change terms and issue refunds.",
324 "Access still decides who gets in. Roles decide what they can do once there, and every refusal is recorded like every change.",
325 ],
326 plans: [
327 "Roles (sales, support, finance, admin) with the permissions each grants",
328 "Per-role limits on money: the most a credit can be without a second person",
329 "Assign roles by email, recorded, with the date each was given",
330 "A second person's approval for comped terms and large credits",
331 ],
332 },
333 },
334 {
335 label: "Audit log",
336 to: "/audit",
337 icon: "audit",
338 about: "Every change made in sudo, by whom, across every customer.",
339 },
340 ],
341 },
342];
343
344/** Whether a section holds the page at `pathname`, so it is drawn open. */
345export function holdsCurrent(group: NavGroup, pathname: string): boolean {
346 return group.items.some((item) => isCurrent(item, pathname));
347}
348
349/** Every item, in sidebar order. */
350export function navItems(nav: NavGroup[] = NAV): NavItem[] {
351 return nav.flatMap((group) => group.items);
352}
353
354/** The items not built yet, each with the placeholder page routes.ts makes. */
355export function soonItems(nav: NavGroup[] = NAV): (NavItem & { soon: Roadmap })[] {
356 return navItems(nav).filter((item): item is NavItem & { soon: Roadmap } => item.soon != null);
357}
358
359/** The item for a path, if one is its page. */
360export function soonFor(pathname: string, nav: NavGroup[] = NAV): (NavItem & { soon: Roadmap }) | null {
361 const path = pathname.replace(/\/+$/, "") || "/";
362 return soonItems(nav).find((item) => item.to === path) ?? null;
363}
364
365/**
366 * Whether `item` is the current page at `pathname`: its own path or one
367 * beneath it. `/` is current only on itself.
368 */
369export function isCurrent(item: Pick<NavItem, "to" | "also">, pathname: string): boolean {
370 const path = pathname.replace(/\/+$/, "") || "/";
371 return [item.to, ...(item.also ?? [])].some((prefix) => {
372 const base = prefix.split("?")[0];
373 if (base === "/") return path === "/";
374 return path === base || path.startsWith(`${base}/`);
375 });
376}