flagon-io/g1t

public

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/apps/web/app/routes/repo/layout.tsx

172 lines6,400 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.

Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put1import { Box, Lock } from "lucide-react";
2import { Link, NavLink, Outlet, useLocation, useRouteLoaderData } from "react-router";
Projects: what a workspace builds and runs, first on every page3
4import type { Project } from "@g1t/contracts";
Initial g1t: services, event bus, intents and attempts5
6import type { Route } from "./+types/layout";
Social cards for every page: og.g1t.sh7import { page } from "../../lib/meta";
A flat project menu with Code first, views as tabs, and Stripe for every owner8import { type Tab as PageTab, tabsFor } from "../../lib/project-nav";
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put9import { Pill } from "../../components/ui";
10import { notFound } from "../../lib/not-found.server";
Agents and memory, checks and conflicts, profiles, slug renames, custom domains11import { redirectIfRenamed } from "../../lib/renamed.server";
Projects: what a workspace builds and runs, first on every page12import { projects, repos, work } from "../../lib/services.server";
Agents as a team: lifecycle, merge queue, billing and a new shell13import { getViewer, roleIn, unwrap } from "../../lib/session.server";
Initial g1t: services, event bus, intents and attempts14
Social cards for every page: og.g1t.sh15export function meta({ loaderData: loaded, params, ...args }: Route.MetaArgs) {
16 return page(args, { title: `${loaded?.project?.name ?? params.repo} · ${params.owner} · g1t` });
Initial g1t: services, event bus, intents and attempts17}
18
Agents and memory, checks and conflicts, profiles, slug renames, custom domains19export async function loader({ params, context, request }: Route.LoaderArgs) {
Initial g1t: services, event bus, intents and attempts20 const viewer = getViewer(context);
21 const path = { namespace: params.owner, name: params.repo };
Projects: what a workspace builds and runs, first on every page22 const [repo, counts, found] = await Promise.all([
Rust repos service with shipping; pull requests kept in the model23 repos.get(path, viewer),
Issues and pull requests replace intents and attempts24 work.counts(path, viewer),
Projects: what a workspace builds and runs, first on every page25 projects.get(params.owner, params.repo, viewer),
Initial g1t: services, event bus, intents and attempts26 ]);
Agents and memory, checks and conflicts, profiles, slug renames, custom domains27 if (!repo.ok && !found.ok) {
28 // Under a workspace's old name, after a rename: the project is at the new one.
29 await redirectIfRenamed(request, params.owner);
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put30 throw notFound("project");
Agents and memory, checks and conflicts, profiles, slug renames, custom domains31 }
Projects: what a workspace builds and runs, first on every page32 let project: Project | null = found.ok ? found.value : null;
33 // A repository made a moment ago, before its project: make it now.
34 if (!project && repo.ok && !repo.value.forkOf) {
35 const own = await projects.byRepo(repo.value.id);
36 project = own.find((p) => p.slug === params.repo.toLowerCase()) ?? own[0] ?? null;
37 }
Initial g1t: services, event bus, intents and attempts38 return {
39 repo: unwrap(repo),
Projects: what a workspace builds and runs, first on every page40 project,
Issues and pull requests replace intents and attempts41 open: counts.ok ? counts.value : { issues: 0, pulls: 0 },
Agents as a team: lifecycle, merge queue, billing and a new shell42 member: roleIn(viewer, params.owner) != null,
Initial g1t: services, event bus, intents and attempts43 };
44}
45
Projects: what a workspace builds and runs, first on every page46/** The project the page is in, for the pages under it. */
47export function useProject() {
48 return useRouteLoaderData<typeof loader>("routes/repo/layout");
49}
50
Search across all of g1t, Explore, and a command palette51/** A repository's topics, each a way into Explore. */
52function Topics({ topics }: { topics: string[] | undefined }) {
53 if (!topics?.length) return null;
54 return (
55 <div className="mt-2 flex flex-wrap gap-1.5">
56 {topics.map((topic) => (
57 <Link
58 key={topic}
59 to={`/explore?topic=${encodeURIComponent(topic)}`}
60 className="rounded-full bg-accent/10 px-2 py-px text-xs text-accent ring-1 ring-accent/30 transition-colors hover:bg-accent/20"
61 >
62 {topic}
63 </Link>
64 ))}
65 </div>
66 );
67}
68
Projects: what a workspace builds and runs, first on every page69function Header({ project, isPrivate, namespace, name, description, large }: {
70 project: Project | null;
71 isPrivate: boolean;
72 namespace: string;
73 name: string;
74 description: string | null;
75 large?: boolean;
76}) {
77 const base = `/${namespace}/${name}`;
78 return (
79 <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
80 <span
81 className={`flex shrink-0 items-center justify-center rounded-md bg-raised text-muted ring-1 ring-line ${large ? "size-8" : "size-6"}`}
82 >
83 {isPrivate ? <Lock size={large ? 15 : 13} /> : <Box size={large ? 15 : 13} />}
84 </span>
85 <h1 className={large ? "text-lg" : "text-[0.9375rem]"}>
86 <Link to={`/${namespace}`} className="font-mono text-muted hover:text-fg">
87 {namespace}
88 </Link>
89 <span className="mx-1.5 text-faint">/</span>
90 <Link to={base} className="font-semibold hover:underline">
91 {project?.name ?? name}
92 </Link>
93 </h1>
94 <Pill>{isPrivate ? "private" : "public"}</Pill>
95 {description && <p className="min-w-0 truncate text-sm text-muted">{description}</p>}
96 </div>
97 );
98}
99
A flat project menu with Code first, views as tabs, and Stripe for every owner100/**
101 * The views of the page the project is on, as tabs across its top: Files,
102 * Commits and what is coming under Code, and so on. Soon tabs open their
103 * roadmap page, under the same tabs.
104 */
105function PageTabs({ base, tabs }: { base: string; tabs: PageTab[] }) {
106 const { pathname } = useLocation();
107 const rest = pathname.slice(base.length + 1);
108 const current = (tab: PageTab) =>
109 [tab.path, ...(tab.also ?? [])].some((path) => rest === path || rest.startsWith(`${path}/`));
110 return (
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put111 <nav aria-label="Views" className="relative -mb-px flex gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
A flat project menu with Code first, views as tabs, and Stripe for every owner112 {tabs.map((tab) => (
113 <NavLink
114 key={tab.path}
115 to={`${base}/${tab.path}`}
116 title={tab.about}
117 prefetch="intent"
118 className={`flex shrink-0 items-center gap-1.5 border-b-2 px-3 pt-1 pb-2.5 text-sm transition-colors ${
119 current(tab)
120 ? "border-accent font-medium text-fg"
121 : tab.soon
122 ? "border-transparent text-faint hover:text-muted"
123 : "border-transparent text-muted hover:text-fg"
124 }`}
125 >
126 {tab.label}
Observability gets its own page; tabs never overflow127 {/* Soon, said quietly: a dot, with the word for screen readers. */}
A flat project menu with Code first, views as tabs, and Stripe for every owner128 {tab.soon && (
Observability gets its own page; tabs never overflow129 <>
130 <span aria-hidden="true" className="size-1.5 rounded-full bg-accent/70" />
131 <span className="sr-only">(soon)</span>
132 </>
A flat project menu with Code first, views as tabs, and Stripe for every owner133 )}
134 </NavLink>
135 ))}
136 </nav>
137 );
138}
139
Projects: what a workspace builds and runs, first on every page140export default function ProjectLayout({ loaderData }: Route.ComponentProps) {
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put141 const { repo, project, member } = loaderData;
Initial g1t: services, event bus, intents and attempts142 const base = `/${repo.namespace}/${repo.name}`;
Projects: what a workspace builds and runs, first on every page143 const description = project?.description ?? repo.description;
A flat project menu with Code first, views as tabs, and Stripe for every owner144 const { pathname } = useLocation();
145 const tabs = tabsFor(pathname.slice(base.length + 1), member);
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put146 // Everyone, signed in or not, finds the project's pages in the sidebar;
147 // the page shows its name, and the views of the page it is on as tabs.
Initial g1t: services, event bus, intents and attempts148 return (
API and MCP server, Rust identity service, registration, site redesign149 <>
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put150 <div className="border-b border-line">
151 <div className={`mx-auto max-w-6xl px-4 sm:px-6 ${tabs ? "pt-3" : "py-3"}`}>
Projects: what a workspace builds and runs, first on every page152 <Header
153 project={project}
154 isPrivate={repo.isPrivate}
155 namespace={repo.namespace}
156 name={repo.name}
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put157 description={description}
Projects: what a workspace builds and runs, first on every page158 />
Search across all of g1t, Explore, and a command palette159 <Topics topics={repo.topics} />
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put160 {tabs && (
161 <div className="mt-3">
162 <PageTabs base={base} tabs={tabs} />
163 </div>
164 )}
API and MCP server, Rust identity service, registration, site redesign165 </div>
166 </div>
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put167 <div className="mx-auto max-w-6xl px-4 py-6 sm:px-6">
API and MCP server, Rust identity service, registration, site redesign168 <Outlet />
169 </div>
170 </>
Initial g1t: services, event bus, intents and attempts171 );
172}