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.

656 linesCodeBlameRaw
1import { Bot, ExternalLink, GitCommitHorizontal, GitMerge } from "lucide-react";
2import { Form, Link, redirect } from "react-router";
3
4import { AGENT_MODES, type Pull, PROVIDERS, workOwner } from "@g1t/contracts";
5
6import type { Route } from "./+types/issue";
7import { excerpt, page } from "../../lib/meta";
8import { Markdown } from "../../components/markdown";
9import {
10 CopyLine,
11 EmptyState,
12 ErrorText,
13 Input,
14 SubmitButton,
15 TimeAgo,
16} from "../../components/ui";
17import { Avatar } from "../../components/ui/avatar";
18import { Card } from "../../components/ui/card";
19import { CheckBadge } from "../../components/checks";
20import { LabelChip, LabelsBox, MilestoneBox } from "../../components/labels";
21import {
22 Assignee,
23 ChangeSize,
24 CommentForm,
25 CommentList,
26 PeoplePicker,
27 IssueState,
28 PersonLink,
29 PullIcon,
30 plainText,
31} from "../../components/work";
32import { notFound } from "../../lib/not-found.server";
33import { openedBy } from "../../lib/opened-by";
34import { agentSessions, identity, inbox, integrations, work } from "../../lib/services.server";
35import { assertSameOrigin, getViewer, requireUser, roleIn } from "../../lib/session.server";
36import { accessTo, refusal, repoFor } from "../../lib/access.server";
37import { SubscriptionBox } from "../../components/notifications";
38import { useRefreshWhile } from "../../lib/refresh";
39import { DetailsDisclosure, detailsSummary } from "../../components/details-disclosure";
40import { repoPages } from "../../lib/repo-live";
41import { useRepoLive } from "../../lib/use-repo-live";
42import { DecisionList, IntegrationFailure, IssueWorkPanel, StartSessionDialog } from "../../components/coordination";
43import { parseBlockedBy, resolutionOf } from "../../lib/coordination";
44
45
46export function meta({ loaderData, params, ...args }: Route.MetaArgs) {
47 const issue = loaderData?.issue;
48 const title = issue ? `${issue.title} · Issue #${issue.number} · ` : "";
49 const state = issue?.state === "open" ? "Open" : issue?.reason === "not_planned" ? "Closed as not planned" : "Closed";
50 const body = excerpt(issue?.body);
51 return page(args, {
52 title: `${title}${params.owner}/${params.repo} · g1t`,
53 description: issue
54 ? `${state} issue #${issue.number} on ${params.owner}/${params.repo}, opened by ${issue.author.username}${issue.requestedBy ? ` for ${issue.requestedBy.username}` : ""}.${body ? ` ${body}` : ""}`
55 : null,
56 // The card shows the title and the state.
57 version: issue ? [issue.title, issue.state, issue.reason] : undefined,
58 type: "article",
59 });
60}
61
62export async function loader({ params, context }: Route.LoaderArgs) {
63 const viewer = getViewer(context);
64 const path = { namespace: params.owner, name: params.repo };
65 const number = Number(params.number);
66 const access = accessTo(context, params);
67 const [{ can }, found, labels, milestones, members, links, subscription, teams, coordination, ended, sessionTrees, agentSetup] = await Promise.all([
68 access,
69 work.getIssue(path, number, viewer),
70 work.listLabels(path, viewer),
71 // Open ones to choose from, and the one it is in, with its progress.
72 work.listMilestones(path, viewer),
73 // A member picks assignees from the workspace's people.
74 roleIn(viewer, params.owner) ? identity.listMembers(params.owner, viewer) : null,
75 // What it is tied to outside g1t. Shown only once the issue is known visible.
76 integrations.links(path, number).catch(() => []),
77 // Whether the viewer hears of it, for the sidebar's Notifications.
78 viewer
79 ? repoFor(context, params).then((repo) =>
80 repo.ok ? inbox.subscription(viewer, { repoId: repo.value.id, number }).catch(() => null) : null,
81 )
82 : null,
83 // The teams a member can mention, for the comment box.
84 roleIn(viewer, params.owner) ? identity.listTeams(viewer, params.owner).catch(() => null) : null,
85 // Who is on it, its sessions, what it waits on and its decisions
86 // (services/work/src/coordination): the Work panel.
87 work.getWork(path, number, viewer).catch(() => null),
88 // Its claims that ended, shown muted under the active ones.
89 Promise.all(
90 (["released", "expired", "handed_off"] as const).map((state) =>
91 work.listClaims(path, viewer, { state, issue: number }).catch(() => null),
92 ),
93 ),
94 // Every session tied to it in any way, with their subagents, for the Work panel's trees.
95 work.listWorkSessions(path, viewer, { issue: number, subagents: true }).catch(() => null),
96 // Whether a member can start a session on the workspace's Anthropic account.
97 roleIn(viewer, params.owner) ? agentSessions.setup(params.owner, viewer).catch(() => null) : null,
98 ]);
99 if (!found.ok) {
100 // Issues and pull requests share numbers; this one may be a pull request.
101 const pull = await work.getPull(path, number, viewer);
102 if (pull.ok) throw redirect(`/${params.owner}/${params.repo}/pull/${number}`);
103 throw notFound("issue");
104 }
105 const { issue } = found.value;
106 return {
107 ...found.value,
108 viewer,
109 labels: labels.ok ? labels.value : [],
110 milestones: milestones.ok ? milestones.value : [],
111 links,
112 subscription,
113 coordination: coordination?.ok ? coordination.value : null,
114 sessionTrees: sessionTrees?.ok ? sessionTrees.value : null,
115 // Only when it can start: the button is not shown otherwise.
116 agentSetup: agentSetup?.ok && agentSetup.value.available ? agentSetup.value : null,
117 endedClaims: ended
118 .flatMap((claims) => (claims?.ok ? claims.value : []))
119 .sort((a, b) => Date.parse(b.endedAt ?? b.createdAt) - Date.parse(a.endedAt ?? a.createdAt)),
120 members: members?.ok ? members.value.map((member) => member.username) : [],
121 handles: teams?.ok ? teams.value.map((team) => `@${team.workspace}/${team.slug}`) : [],
122 // The author can close and reopen their own issue, and whoever g1t's
123 // agent filed one for, that one; Triage and up, anyone's.
124 canManage: viewer != null && (viewer.id === workOwner(issue).id || can.triage),
125 // Maintain and up edit and delete anyone's comments; everyone, their own.
126 canModerate: can.manage_settings,
127 can,
128 };
129}
130
131export async function action({ request, params, context }: Route.ActionArgs) {
132 assertSameOrigin(request);
133 const user = requireUser(context, request);
134 const form = await request.formData();
135 const path = { namespace: params.owner, name: params.repo };
136 const number = Number(params.number);
137 // What each form needs; closing your own issue is checked by work.
138 // Labels: its author may use the repository's on their own issue, and
139 // work says so; anyone else, and every milestone, needs Triage.
140 // What it is blocked by: its author or Triage, which work checks too.
141 const needed = form.get("action") === "assign" || form.get("action") === "milestone" ? "triage" : null;
142 const refused = needed ? await refusal(context, params, needed) : null;
143 if (refused) return { error: refused, action: String(form.get("action")) };
144
145 switch (form.get("action")) {
146 case "open-pull": {
147 const result = await work.openPull(user, path, {
148 issue: number,
149 agent: String(form.get("agent") ?? ""),
150 runtime: "external",
151 });
152 if (!result.ok) return { error: result.error.message };
153 throw redirect(`/${params.owner}/${params.repo}/pull/${result.value.number}`);
154 }
155 // A session on the workspace's Anthropic account, which the
156 // integrations service checks the person may start; then its page.
157 case "start-session": {
158 const mode = AGENT_MODES.find((one) => one.mode === form.get("mode"))?.mode ?? "implement";
159 const instruction = String(form.get("instruction") ?? "").trim();
160 const result = await agentSessions
161 .start(user, path, { issue: number, mode, instruction: instruction || undefined, handoff: false })
162 .catch(() => null);
163 if (!result) return { error: "The session could not be started. Try again in a moment.", action: "start-session" };
164 if (!result.ok) return { error: result.error.message, action: "start-session" };
165 const started = result.value;
166 const to = sitePath(started.sessionUrl, request.url) ?? (started.session ? `/${params.owner}/${params.repo}/work/sessions/${started.session.id}` : null);
167 if (!to) return { error: "No session was started.", action: "start-session" };
168 throw redirect(to);
169 }
170 case "comment": {
171 const result = await work.addComment(user, path, number, {
172 body: String(form.get("body") ?? ""),
173 });
174 return result.ok ? null : { error: result.error.message };
175 }
176 case "assign": {
177 const result = await work.updateIssue(user, path, number, {
178 assignees: [
179 ...form.getAll("assignee").map(String),
180 ...String(form.get("others") ?? "").split(/[\s,]+/),
181 ],
182 });
183 return result.ok ? null : { error: result.error.message };
184 }
185 case "labels": {
186 const result = await work.setLabels(user, path, number, form.getAll("label").map(String));
187 return result.ok ? null : { error: result.error.message, action: "labels" };
188 }
189 case "blocked-by": {
190 const blockedBy = parseBlockedBy(String(form.get("blocked_by") ?? ""));
191 if (!blockedBy) return { error: "List issue numbers, such as #12, #14.", action: "blocked-by" };
192 const result = await work.updateIssue(user, path, number, { blocked_by: blockedBy });
193 return result.ok ? null : { error: result.error.message, action: "blocked-by" };
194 }
195 case "milestone": {
196 const result = await work.updateIssue(user, path, number, { milestone: Number(form.get("milestone")) || 0 });
197 return result.ok ? null : { error: result.error.message, action: "milestone" };
198 }
199 case "reopen": {
200 const result = await work.reopenIssue(user, path, number);
201 return result.ok ? null : { error: result.error.message };
202 }
203 // A comment's own text, changed or taken away: its author's to do, or
204 // a maintainer's, which work checks.
205 case "edit-comment":
206 case "delete-comment": {
207 const action = String(form.get("action"));
208 const id = String(form.get("comment") ?? "");
209 const result =
210 action === "edit-comment"
211 ? await work.editComment(user, path, id, String(form.get("body") ?? ""))
212 : await work.deleteComment(user, path, id);
213 return result.ok ? null : { error: result.error.message, action, comment: id };
214 }
215 default: {
216 const result = await work.closeIssue(
217 user,
218 path,
219 number,
220 form.get("action") === "close-not-planned" ? "not_planned" : "completed",
221 );
222 return result.ok ? null : { error: result.error.message };
223 }
224 }
225}
226
227/** The path of a page of this site an address names, to redirect to; null for none or another site's. */
228function sitePath(url: string | null | undefined, here: string): string | null {
229 if (!url) return null;
230 try {
231 const parsed = new URL(url, here);
232 const own = parsed.origin === new URL(here).origin || parsed.hostname === "g1t.sh";
233 return own ? parsed.pathname + parsed.search : null;
234 } catch {
235 return null;
236 }
237}
238
239/** What became of a pull request, in a few words. */
240function outcome(pull: Pull): string {
241 if (pull.status === "merged") return `Merged by ${pull.mergedBy ?? "someone"}`;
242 if (pull.supersededBy != null) return `Closed · #${pull.supersededBy} was merged instead`;
243 if (pull.status === "closed") return "Closed without merging";
244 if (pull.status === "draft") return "Draft · in progress";
245 return "Ready for review";
246}
247
248function PullRow({ pull, base }: { pull: Pull; base: string }) {
249 const merged = pull.status === "merged";
250 const opener = openedBy(pull);
251 return (
252 <li>
253 <Link
254 to={`${base}/pull/${pull.number}`}
255 className={`block rounded-xl border p-4 transition-colors ${
256 merged
257 ? "border-merged/40 bg-merged/5 hover:border-merged/70"
258 : "border-line bg-surface hover:border-line-strong"
259 } ${pull.status === "closed" ? "opacity-70" : ""}`}
260 >
261 <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
262 <PullIcon status={pull.status} />
263 <span className="font-medium">
264 {pull.title} <span className="font-normal text-faint">#{pull.number}</span>
265 </span>
266 {pull.status === "draft" && (
267 <span className="size-1.5 animate-pulse rounded-full bg-accent" />
268 )}
269 <span className="ml-auto flex items-center gap-3 text-xs text-faint">
270 <ChangeSize files={pull.files} />
271 <CheckBadge status={pull.checkStatus} />
272 <span className="flex items-center gap-1 font-mono">
273 <GitCommitHorizontal size={13} />
274 {pull.headCommit?.slice(0, 7) ?? "no commits"}
275 </span>
276 <TimeAgo at={pull.updatedAt} />
277 </span>
278 </div>
279 <p className="mt-1.5 flex flex-wrap items-center gap-x-2 text-xs text-muted">
280 <span className={merged ? "font-medium text-merged" : ""}>{outcome(pull)}</span>
281 <span className="text-faint">·</span>
282 <span className="flex items-center gap-1 font-mono">
283 <Bot size={12} />
284 {pull.agent}
285 </span>
286 {opener.requestedBy ? (
287 <span className="text-faint">· requested by {opener.requestedBy}</span>
288 ) : (
289 <>
290 {pull.runtime === "hosted" && <span className="text-faint">on g1t</span>}
291 <span className="text-faint">· opened by {opener.name}</span>
292 </>
293 )}
294 </p>
295 {pull.body && (
296 <p className="mt-2 line-clamp-2 text-sm text-muted">{plainText(pull.body)}</p>
297 )}
298 </Link>
299 </li>
300 );
301}
302
303export default function IssuePage({ loaderData, actionData, params }: Route.ComponentProps) {
304 const { issue, pulls, comments, viewer, labels, members, canManage, can, coordination } = loaderData;
305 // Follow pull requests at work without a manual reload.
306 const running = pulls.some(
307 (pull) =>
308 pull.status === "draft" ||
309 pull.checkStatus === "queued" ||
310 pull.checkStatus === "running",
311 );
312 useRefreshWhile(running);
313 // Claims lapse and sessions go idle with no event to say so: looked at again now and then.
314 useRefreshWhile((coordination?.claims.length ?? 0) > 0 || (coordination?.sessions.some((session) => session.state !== "ended") ?? false), 30_000);
315 const now = Date.now();
316 // Comments, changes and its pull requests, as they happen; one reading at its end follows them.
317 useRepoLive({ match: repoPages.issue(issue.number, pulls.map((pull) => pull.number)), followBottom: true });
318
319 const base = `/${params.owner}/${params.repo}`;
320 const open = issue.state === "open";
321 const reference = `${params.owner}/${params.repo}#${issue.number}`;
322 const resolver = pulls.find((pull) => pull.number === issue.resolvedBy);
323 // The merged pull request first, then the ones still in play, then the rest.
324 const rank = { merged: 0, open: 1, draft: 2, closed: 3 } as const;
325 const ordered = [...pulls].sort(
326 (a, b) => rank[a.status] - rank[b.status] || a.number - b.number,
327 );
328 // Its decisions as a story, oldest first; the failure that still stands, with what answered it.
329 const decisions = coordination ? [...coordination.decisions].reverse() : [];
330 const failure = coordination?.lastIntegrationFailure ?? null;
331 const resolution = failure ? resolutionOf(coordination!.decisions, failure) : null;
332
333 return (
334 // On a phone: the title, then the sidebar as a Details disclosure, then
335 // the issue; beside it from lg up.
336 <div className="grid gap-x-8 gap-y-5 lg:grid-cols-[1fr_19rem] lg:grid-rows-[auto_1fr] lg:gap-y-0">
337 <header className="min-w-0 lg:col-start-1">
338 <h2 className="text-xl font-semibold tracking-tight text-balance wrap-break-word sm:text-2xl">
339 {issue.title} <span className="font-normal text-faint">#{issue.number}</span>
340 </h2>
341 <div className="mt-3 flex flex-wrap items-center gap-x-3 gap-y-2 text-sm text-muted">
342 <IssueState issue={issue} />
343 <span className="flex items-center gap-2">
344 <Avatar name={issue.author.username} size={18} />
345 <span>
346 <PersonLink name={issue.author.username} className="font-medium text-fg hover:underline" /> opened this{" "}
347 {issue.requestedBy && (
348 <>
349 for{" "}
350 <PersonLink name={issue.requestedBy.username} className="font-medium text-fg-soft hover:underline" />{" "}
351 </>
352 )}
353 <TimeAgo at={issue.createdAt} />
354 </span>
355 </span>
356 {issue.labels.map((name) => (
357 <LabelChip key={name} name={name} color={labels.find((label) => label.name === name)?.color} />
358 ))}
359 {open && issue.agent && <Assignee agent={issue.agent} />}
360 </div>
361 </header>
362
363 <div className="min-w-0 max-lg:order-1 lg:col-start-1">
364
365 {issue.resolvedBy != null && (
366 <Link
367 to={`${base}/pull/${issue.resolvedBy}`}
368 className="flex lg:mt-5 items-center gap-3 rounded-xl border border-merged/40 bg-merged/5 px-4 py-3 text-sm transition-colors hover:border-merged/70"
369 >
370 <GitMerge size={18} className="shrink-0 text-merged" />
371 <span>
372 Resolved by{" "}
373 <span className="font-medium">
374 {resolver?.title ?? "pull request"} #{issue.resolvedBy}
375 </span>
376 {resolver?.mergedBy && (
377 <span className="text-muted">
378 , merged by {resolver.mergedBy}{" "}
379 {resolver.mergedAt && <TimeAgo at={resolver.mergedAt} />}
380 </span>
381 )}
382 </span>
383 </Link>
384 )}
385
386 {issue.body && (
387 <div className={`${issue.resolvedBy != null ? "mt-5" : "lg:mt-5"} rounded-xl border border-line bg-surface p-4 sm:p-5`}>
388 <Markdown source={issue.body} repo={{ namespace: params.owner, name: params.repo }} />
389 </div>
390 )}
391
392 <div className="mt-10 flex items-baseline justify-between">
393 <h3 className="font-semibold tracking-tight">Pull requests</h3>
394 <p className="text-sm text-muted">
395 {pulls.length === 0
396 ? "None yet"
397 : `${pulls.length} for this issue${
398 pulls.some((pull) => pull.status === "merged") ? "" : ", none merged"
399 }`}
400 </p>
401 </div>
402 <div className="mt-3">
403 {pulls.length === 0 ? (
404 <EmptyState title="Nobody has worked on this yet">
405 Point your own agent at{" "}
406 <code className="font-mono">{reference}</code>.
407 </EmptyState>
408 ) : (
409 <ol className="space-y-3">
410 {ordered.map((pull) => (
411 <PullRow key={pull.id} pull={pull} base={base} />
412 ))}
413 </ol>
414 )}
415 </div>
416
417 {failure && (
418 <IntegrationFailure className="mt-4" failure={failure} base={base} fixed={resolution?.passed ?? resolution?.fix} />
419 )}
420
421 {decisions.length > 0 && (
422 <>
423 <div className="mt-10 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
424 <h3 className="font-semibold tracking-tight">Decisions</h3>
425 <p className="text-sm text-muted">Why the work is the way it is, and how sure that is</p>
426 </div>
427 <div className="mt-3">
428 <DecisionList decisions={decisions} base={base} />
429 </div>
430 </>
431 )}
432
433 <h3 className="mt-10 font-semibold tracking-tight">Discussion</h3>
434 <div className="mt-3">
435 <div className="space-y-4">
436 <CommentList
437 comments={comments}
438 base={base}
439 viewerId={viewer?.id ?? null}
440 canModerate={loaderData.canModerate}
441 failed={actionData && "comment" in actionData ? { comment: String(actionData.comment), error: actionData.error } : null}
442 />
443 <CommentForm author={viewer?.username ?? null} resetKey={comments.length} handles={loaderData.handles} />
444 {canManage && (
445 <Form method="post" className="flex flex-wrap justify-end gap-2">
446 {open ? (
447 <>
448 <SubmitButton variant="outline" name="action" value="close-not-planned" pending="Closing…">
449 Close as not planned
450 </SubmitButton>
451 <SubmitButton variant="outline" name="action" value="close-completed" pending="Closing…">
452 Close issue
453 </SubmitButton>
454 </>
455 ) : (
456 <SubmitButton variant="outline" name="action" value="reopen" pending="Reopening…">
457 Reopen issue
458 </SubmitButton>
459 )}
460 </Form>
461 )}
462 </div>
463 </div>
464 <div className="mt-2">
465 {/* A refused comment edit says so under the comment. */}
466 {!(actionData && ("comment" in actionData || ("action" in actionData && (actionData.action === "blocked-by" || actionData.action === "start-session")))) && (
467 <ErrorText>{actionData?.error}</ErrorText>
468 )}
469 </div>
470 </div>
471
472 <DetailsDisclosure
473 className="lg:col-start-2 lg:row-span-2 lg:row-start-1"
474 summary={detailsSummary([
475 [coordination?.claims.length ?? 0, "claim", "claims"],
476 [issue.assignees.length, "assignee", "assignees"],
477 [issue.labels.length, "label", "labels"],
478 [issue.milestone ? 1 : 0, "milestone", "milestones"],
479 ])}
480 >
481 {coordination && (
482 <IssueWorkPanel
483 work={coordination}
484 ended={loaderData.endedClaims}
485 base={base}
486 now={now}
487 canEdit={canManage}
488 error={actionData && "action" in actionData && actionData.action === "blocked-by" ? actionData.error : null}
489 sessions={loaderData.sessionTrees}
490 start={
491 loaderData.agentSetup && open ? (
492 <StartSessionDialog
493 setup={loaderData.agentSetup}
494 error={actionData && "action" in actionData && actionData.action === "start-session" ? actionData.error : null}
495 />
496 ) : undefined
497 }
498 />
499 )}
500 {loaderData.links.length > 0 && (
501 <section>
502 <h3 className="text-sm font-medium">From outside g1t</h3>
503 <ul className="mt-2 space-y-1.5 text-sm">
504 {loaderData.links.map((link) => (
505 <li key={`${link.connectionId}-${link.key}`}>
506 <a
507 href={link.url}
508 target="_blank"
509 rel="noreferrer"
510 className="group flex items-center gap-2 rounded-lg border border-line px-2.5 py-2 transition-colors hover:border-line-strong"
511 >
512 <span className="min-w-0 grow">
513 <span className="block truncate font-medium">
514 {PROVIDERS[link.provider].label} <span className="font-mono text-muted">{link.key}</span>
515 </span>
516 <span className="block text-xs text-faint">
517 {link.count > 1 ? `Seen ${link.count} times, last ` : "Linked "}
518 <TimeAgo at={link.count > 1 ? link.lastSeen : link.firstSeen} />
519 </span>
520 </span>
521 <ExternalLink size={13} className="shrink-0 text-faint group-hover:text-fg" />
522 </a>
523 </li>
524 ))}
525 </ul>
526 </section>
527 )}
528 <section>
529 <h3 className="text-sm font-medium">Assignees</h3>
530 <ul className="mt-2 space-y-1.5 text-sm">
531 {issue.assignees.map((name) => (
532 <li key={name} className="flex items-center gap-2 px-1">
533 <Avatar name={name} size={20} />
534 <span className="grow truncate font-mono text-xs">
535 <PersonLink name={name} className="hover:underline" />
536 </span>
537 </li>
538 ))}
539 </ul>
540 {!coordination && issue.blockedBy.length > 0 && (
541 <p className="mt-3 text-xs text-muted">
542 Depends on{" "}
543 {issue.blockedBy.map((number, index) => (
544 <span key={number}>
545 {index > 0 && ", "}
546 <Link
547 to={`${base}/issues/${number}`}
548 className="font-medium text-fg hover:underline"
549 >
550 #{number}
551 </Link>
552 </span>
553 ))}
554 {open ? ", which has to merge first." : "."}
555 </p>
556 )}
557
558 {viewer && can.triage && open && (
559 <div className="mt-3 space-y-2">
560 {!issue.assignees.includes(viewer.username) && (
561 <Form method="post">
562 <input type="hidden" name="action" value="assign" />
563 {issue.assignees.map((name) => (
564 <input key={name} type="hidden" name="assignee" value={name} />
565 ))}
566 <input type="hidden" name="assignee" value={viewer.username} />
567 <div className="*:w-full">
568 <SubmitButton variant="outline" name="who" value="self" pending="Assigning…">
569 Assign yourself
570 </SubmitButton>
571 </div>
572 </Form>
573 )}
574 <details className="group">
575 <summary className="cursor-pointer text-xs text-faint hover:text-fg">
576 Assign people
577 </summary>
578 <Form method="post" className="mt-2 space-y-2" key={issue.assignees.join()}>
579 <input type="hidden" name="action" value="assign" />
580 <PeoplePicker name="assignee" members={members} chosen={issue.assignees} />
581 <SubmitButton variant="outline" name="who" value="picked" pending="Saving…">
582 Save assignees
583 </SubmitButton>
584 </Form>
585 </details>
586 </div>
587 )}
588 </section>
589
590 {/* Another way to start the work: not once a pull request is doing it. */}
591 {open && !pulls.some((pull) => pull.status === "open" || pull.status === "draft") && (
592 <Card asChild className="p-4">
593 <section>
594 <h3 className="text-sm font-medium">Bring your own agent</h3>
595 <p className="mt-1 text-xs text-muted">
596 With g1t connected to your agent, ask it to work on this issue.
597 </p>
598 <div className="mt-3">
599 <CopyLine text={reference} />
600 </div>
601 {viewer ? (
602 <Form method="post" className="mt-4 space-y-2 border-t border-line pt-4">
603 <input type="hidden" name="action" value="open-pull" />
604 <p className="text-xs text-muted">
605 Or open a draft pull request yourself and get a fork to push to.
606 </p>
607 <Input name="agent" placeholder="Who is working, e.g. claude-code" maxLength={60} />
608 <div className="*:w-full">
609 <SubmitButton match={{ action: "open-pull" }} pending="Opening…">
610 Open pull request
611 </SubmitButton>
612 </div>
613 <p className="text-xs text-muted">
614 Already pushed a branch?{" "}
615 <Link
616 to={`${base}/pulls/new?issue=${issue.number}`}
617 className="text-fg underline underline-offset-4"
618 >
619 Open a pull request from it
620 </Link>
621 .
622 </p>
623 </Form>
624 ) : (
625 <p className="mt-4 border-t border-line pt-4 text-sm text-muted">
626 <Link to="/login" className="text-fg underline underline-offset-4">
627 Sign in
628 </Link>{" "}
629 to open a pull request.
630 </p>
631 )}
632 </section>
633 </Card>
634 )}
635
636 <LabelsBox
637 labels={labels}
638 chosen={issue.labels}
639 canEdit={loaderData.canManage}
640 canCreate={can.manage_labels}
641 manageUrl={can.manage_labels ? `${base}/labels` : undefined}
642 />
643 <MilestoneBox
644 milestones={loaderData.milestones}
645 current={issue.milestone}
646 canEdit={can.triage}
647 base={base}
648 />
649
650 {viewer && (
651 <SubscriptionBox action={`${base}/notifications`} number={issue.number} kind="issue" subscription={loaderData.subscription} />
652 )}
653 </DetailsDisclosure>
654 </div>
655 );
656}