Skip to content
305 linesCodeBlameRaw

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.

Agents as a team: lifecycle, merge queue, billing and a new shell1import { env } from "cloudflare:workers";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar2import { GitPullRequest, MessageSquare, Milestone as MilestoneIcon, Plus, Sparkles, Tag } from "lucide-react";
Merge branch 'worktree-agent-af9f0f386d52b6a73'3import { useEffect, useRef } from "react";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar4import { Form, Link, useLocation, useRouteLoaderData } from "react-router";
Issues and pull requests replace intents and attempts5
6import type { Route } from "./+types/issues";
Social cards for every page: og.g1t.sh7import { page } from "../../lib/meta";
Merge branch 'worktree-agent-a985c01f43538af01'8import { ButtonLink, ComputeNote, EmptyState, ErrorText, SubmitButton, TimeAgo } from "../../components/ui";
Workspace names and icons, and a component kit for every control9import { Checkbox } from "../../components/ui/checkbox";
Agents as a team: lifecycle, merge queue, billing and a new shell10import {
11 Assignee,
12 AssigneeStack,
13 IssueIcon,
14 StateTabs,
15} from "../../components/work";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar16import { FilterMenu, LabelChip, Swatch } from "../../components/labels";
17import { colorsOf, listFilters, withFilter } from "../../lib/labels";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look18import { computeNoteFor } from "../../lib/compute.server";
19import { isWaitingMessage } from "../../lib/compute";
Issues and pull requests replace intents and attempts20import { work } from "../../lib/services.server";
Agents as a team: lifecycle, merge queue, billing and a new shell21import { assertSameOrigin, getViewer, requireUser, unwrap } from "../../lib/session.server";
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look22import { accessTo, refusal } from "../../lib/access.server";
Agents as a team: lifecycle, merge queue, billing and a new shell23
24/** As many sandboxes as one request may start. */
25const MAX_ASSIGNED_AT_ONCE = 10;
Issues and pull requests replace intents and attempts26
Social cards for every page: og.g1t.sh27export function meta({ params, ...args }: Route.MetaArgs) {
28 return page(args, { title: `Issues · ${params.owner}/${params.repo} · g1t` });
Issues and pull requests replace intents and attempts29}
30
31export async function loader({ params, context, request }: Route.LoaderArgs) {
32 const viewer = getViewer(context);
33 const path = { namespace: params.owner, name: params.repo };
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar34 // `?label=bug&milestone=3`, or `label:bug milestone:3` written in `q`.
35 const { state, label, milestone } = listFilters(new URL(request.url).searchParams);
Fast pages, required checks on the branch, self-hosted runners, honest incidents36 // Assigning agents needs Write: Read cannot spend compute. All at once:
37 // only the plan's note waits for the viewer's role.
38 const access = accessTo(context, params);
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar39 const [{ can }, issues, labels, milestones, agentsEnabled, computeNote] = await Promise.all([
Fast pages, required checks on the branch, self-hosted runners, honest incidents40 access,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar41 work.listIssues(path, viewer, { state, label: label || undefined, milestone: milestone ?? undefined }),
Issues and pull requests replace intents and attempts42 work.listLabels(path, viewer),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar43 work.listMilestones(path, viewer, "open"),
g1t's agents only for listed workspaces, whatever the state of billing44 env.RUNNER.enabled(viewer, path),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look45 // Before a member assigns: whether the workspace's plan lets agents start.
Fast pages, required checks on the branch, self-hosted runners, honest incidents46 access.then(({ can }) => (can.run ? computeNoteFor(params.owner, "agent") : null)),
Issues and pull requests replace intents and attempts47 ]);
Agents as a team: lifecycle, merge queue, billing and a new shell48 return {
49 issues: unwrap(issues),
50 labels: unwrap(labels),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar51 milestones: milestones.ok ? milestones.value : [],
Agents as a team: lifecycle, merge queue, billing and a new shell52 state,
53 label,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar54 milestone,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look55 agentsEnabled: agentsEnabled && can.run,
56 computeNote,
Agents as a team: lifecycle, merge queue, billing and a new shell57 } as const;
58}
59
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent60/** Assigns each selected issue to g1t, one run of its own each. */
Agents as a team: lifecycle, merge queue, billing and a new shell61export async function action({ request, params, context }: Route.ActionArgs) {
62 assertSameOrigin(request);
63 const user = requireUser(context, request);
64 const path = { namespace: params.owner, name: params.repo };
65 const numbers = (await request.formData())
66 .getAll("issue")
67 .map(Number)
68 .filter((number) => Number.isInteger(number) && number > 0);
69 if (numbers.length === 0) return { error: "Select the issues to assign first." };
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look70 const denied = await refusal(context, params, "run");
71 if (denied) return { error: denied };
Agents as a team: lifecycle, merge queue, billing and a new shell72 if (numbers.length > MAX_ASSIGNED_AT_ONCE) {
73 return { error: `Assign at most ${MAX_ASSIGNED_AT_ONCE} issues at a time.` };
74 }
75 const results = await Promise.all(
76 numbers.map((number) => env.RUNNER.run(user, path, number)),
77 );
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look78 // Over the workspace's agents-at-once cap, the rest wait in the queue.
79 const waiting = results.filter((result) => !result.ok && isWaitingMessage(result.error.message)).length;
80 const refused = results.find((result) => !result.ok && !isWaitingMessage(result.error.message));
Agents as a team: lifecycle, merge queue, billing and a new shell81 const started = results.filter((result) => result.ok).length;
82 return {
83 started,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look84 waiting,
Agents as a team: lifecycle, merge queue, billing and a new shell85 error:
86 refused && !refused.ok
87 ? `${started} of ${numbers.length} assigned. ${refused.error.message}`
88 : null,
89 };
Issues and pull requests replace intents and attempts90}
91
Agents as a team: lifecycle, merge queue, billing and a new shell92export default function Issues({ loaderData, actionData, params }: Route.ComponentProps) {
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar93 const { issues, labels, milestones, state, label, milestone, agentsEnabled } = loaderData;
Issues and pull requests replace intents and attempts94 const repo = `/${params.owner}/${params.repo}`;
95 const base = `${repo}/issues`;
Agents as a team: lifecycle, merge queue, billing and a new shell96 const assignable = agentsEnabled && state === "open" && issues.length > 0;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar97 const current = new URLSearchParams(useLocation().search);
98 const colors = colorsOf(labels);
99 const milestoneTitle = milestones.find((m) => m.number === milestone)?.title ?? (milestone ? `#${milestone}` : null);
100 const filtered = [label, milestone].some(Boolean);
101 // The tabs keep the filters; each filter keeps the state and the other.
102 const kept = new URLSearchParams(current);
103 kept.delete("state");
104 kept.delete("q");
Merge branch 'worktree-agent-a985c01f43538af01'105
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look106 // An archived repository's issues are locked: no new ones.
107 const layout = useRouteLoaderData("routes/repo/layout") as { repo?: { archivedAt?: string | null } } | undefined;
108 const archived = Boolean(layout?.repo?.archivedAt);
Merge branch 'worktree-agent-af9f0f386d52b6a73'109 // Handed over: the ticks are cleared. Refused: they stay, to try again.
110 const form = useRef<HTMLFormElement>(null);
111 useEffect(() => {
112 if (actionData && !actionData.error) form.current?.reset();
113 }, [actionData]);
Issues and pull requests replace intents and attempts114 return (
115 <div>
116 <StateTabs
117 to={base}
118 state={state}
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar119 query={kept.toString()}
Issues and pull requests replace intents and attempts120 action={
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look121 archived ? undefined : (
122 <ButtonLink to={`${base}/new`}>
123 <Plus size={15} />
124 New issue
125 </ButtonLink>
126 )
Issues and pull requests replace intents and attempts127 }
128 />
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar129 <div className="mt-3 flex flex-wrap items-center gap-2">
130 <FilterMenu
131 label="Label"
132 active={label || undefined}
133 clearTo={label ? withFilter(base, current, "label", null) : undefined}
134 searchPlaceholder="Filter labels"
135 emptyText="No label matches."
136 options={labels.map((each) => ({
137 key: each.name,
138 to: withFilter(base, current, "label", each.name),
139 keywords: `${each.name} ${each.description}`,
140 selected: each.name === label,
141 label: (
142 <>
143 <Swatch color={each.color} />
144 <span className="truncate">{each.name}</span>
145 </>
146 ),
147 }))}
148 />
149 <FilterMenu
150 label="Milestone"
151 active={milestoneTitle ?? undefined}
152 clearTo={milestone ? withFilter(base, current, "milestone", null) : undefined}
153 searchPlaceholder="Filter milestones"
154 emptyText="No open milestone matches."
155 options={milestones.map((each) => ({
156 key: String(each.number),
157 to: withFilter(base, current, "milestone", String(each.number)),
158 keywords: `${each.title} ${each.number}`,
159 selected: each.number === milestone,
160 label: <span className="truncate">{each.title}</span>,
161 }))}
162 />
163 {filtered && (
164 <Link to={state === "closed" ? `${base}?state=closed` : base} className="text-xs text-muted hover:text-fg">
165 Clear filters
166 </Link>
167 )}
168 <span className="ml-auto flex items-center gap-1">
169 <Link
170 to={`${repo}/labels`}
171 className="inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted transition-colors hover:bg-surface hover:text-fg"
172 >
173 <Tag size={14} />
174 Labels
175 </Link>
176 </span>
Issues and pull requests replace intents and attempts177 </div>
Merge branch 'worktree-agent-af9f0f386d52b6a73'178 <Form ref={form} method="post" className="mt-4">
Agents as a team: lifecycle, merge queue, billing and a new shell179 {assignable && (
180 <div className="mb-3 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-2.5">
181 <Sparkles size={15} className="shrink-0 text-accent" />
182 <p className="min-w-0 grow text-sm text-muted">
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent183 Tick the issues to hand over. g1t takes each one in a run of its own,
Agents as a team: lifecycle, merge queue, billing and a new shell184 and they all work at once.
185 </p>
Merge branch 'worktree-agent-a985c01f43538af01'186 <SubmitButton variant="accent" pending="Starting sandboxes…">
187 Assign to g1t
188 </SubmitButton>
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look189 {loaderData.computeNote && (
190 <div className="basis-full">
191 <ComputeNote note={loaderData.computeNote} />
192 </div>
193 )}
Agents as a team: lifecycle, merge queue, billing and a new shell194 </div>
195 )}
196 {actionData?.error ? (
197 <div className="mb-3">
198 <ErrorText>{actionData.error}</ErrorText>
199 </div>
200 ) : (
201 actionData?.started != null && (
202 <p className="mb-3 text-sm text-muted">
203 {actionData.started}{" "}
204 {actionData.started === 1 ? "agent is" : "agents are"} starting. Each
205 issue shows its pull request as it appears.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look206 {actionData.waiting
207 ? ` ${actionData.waiting} more ${actionData.waiting === 1 ? "waits" : "wait"} for a free slot and start by themselves.`
208 : ""}
Agents as a team: lifecycle, merge queue, billing and a new shell209 </p>
210 )
211 )}
Issues and pull requests replace intents and attempts212 {issues.length === 0 ? (
213 <EmptyState
214 title={
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar215 filtered
216 ? `No ${state} issues match these filters`
Issues and pull requests replace intents and attempts217 : state === "open"
218 ? "No open issues"
219 : "No closed issues"
220 }
221 >
222 An issue says what should change: a bug, a feature, a question.
223 Agents and people open pull requests against it.
224 </EmptyState>
225 ) : (
226 <ul className="divide-y divide-line overflow-hidden rounded-xl border border-line">
227 {issues.map((issue) => (
Agents as a team: lifecycle, merge queue, billing and a new shell228 <li key={issue.id} className="flex items-start transition-colors hover:bg-surface">
229 {assignable && (
Workspace names and icons, and a component kit for every control230 <Checkbox
Agents as a team: lifecycle, merge queue, billing and a new shell231 name="issue"
Workspace names and icons, and a component kit for every control232 value={String(issue.number)}
Agents as a team: lifecycle, merge queue, billing and a new shell233 // Already being worked on: nothing more to hand over.
234 disabled={issue.agent != null || issue.queued}
235 aria-label={`Select issue #${issue.number}`}
Workspace names and icons, and a component kit for every control236 className="mt-4 ml-4 disabled:opacity-30"
Agents as a team: lifecycle, merge queue, billing and a new shell237 />
238 )}
Issues and pull requests replace intents and attempts239 <Link
Agents as a team: lifecycle, merge queue, billing and a new shell240 prefetch="intent"
Issues and pull requests replace intents and attempts241 to={`${base}/${issue.number}`}
Agents as a team: lifecycle, merge queue, billing and a new shell242 className="flex min-w-0 grow items-start gap-3 px-4 py-3"
Issues and pull requests replace intents and attempts243 >
244 <span className="mt-0.5">
245 <IssueIcon issue={issue} />
246 </span>
247 <span className="min-w-0 grow">
248 <span className="flex flex-wrap items-center gap-x-2 gap-y-1">
249 <span className="font-medium">{issue.title}</span>
250 {issue.labels.map((name) => (
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar251 <LabelChip key={name} name={name} color={colors[name]} />
Issues and pull requests replace intents and attempts252 ))}
Agents as a team: lifecycle, merge queue, billing and a new shell253 {issue.state === "open" && issue.agent && (
254 <Assignee agent={issue.agent} />
255 )}
256 {issue.state === "open" && issue.queued && !issue.agent && (
257 <span className="rounded-full border border-line px-2 py-px text-xs text-muted">
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent258 queued for g1t
Agents as a team: lifecycle, merge queue, billing and a new shell259 {issue.blockedBy.length > 0 &&
260 `, after ${issue.blockedBy.map((number) => `#${number}`).join(", ")}`}
261 </span>
262 )}
Issues and pull requests replace intents and attempts263 </span>
264 <span className="mt-0.5 block text-xs text-faint">
265 #{issue.number} opened <TimeAgo at={issue.createdAt} /> by{" "}
266 {issue.author.username}
g1t is the stored author of what it opens; the person who asked is requested_by and keeps the author's rights267 {issue.requestedBy && <> for {issue.requestedBy.username}</>}
Issues and pull requests replace intents and attempts268 {issue.resolvedBy != null && (
269 <span className="text-merged"> · resolved by #{issue.resolvedBy}</span>
270 )}
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar271 {issue.milestone && (
272 <span className="inline-flex items-center gap-1">
273 {" "}
274 · <MilestoneIcon size={11} className="inline" /> {issue.milestone.title}
275 </span>
276 )}
Issues and pull requests replace intents and attempts277 </span>
278 </span>
279 <span className="mt-0.5 flex shrink-0 items-center gap-3 text-xs text-muted">
Agents as a team: lifecycle, merge queue, billing and a new shell280 <AssigneeStack people={issue.assignees} />
Issues and pull requests replace intents and attempts281 {issue.pullCount > 0 && (
282 <span
283 className="flex items-center gap-1"
284 title={`${issue.pullCount} pull ${issue.pullCount === 1 ? "request" : "requests"}`}
285 >
286 <GitPullRequest size={13} />
287 {issue.pullCount}
288 </span>
289 )}
290 {issue.commentCount > 0 && (
291 <span className="flex items-center gap-1">
292 <MessageSquare size={13} />
293 {issue.commentCount}
294 </span>
295 )}
296 </span>
297 </Link>
298 </li>
299 ))}
300 </ul>
301 )}
Agents as a team: lifecycle, merge queue, billing and a new shell302 </Form>
Issues and pull requests replace intents and attempts303 </div>
304 );
305}

This file's history is long; its oldest lines are credited to the oldest commit read.