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/pulls.tsx

95 lines3,831 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.

Pull requests from branches1import { Bot, GitBranch, Plus } from "lucide-react";
Issues and pull requests replace intents and attempts2import { Link } from "react-router";
3
4import type { Route } from "./+types/pulls";
Pull requests from branches5import { ButtonLink, EmptyState, TimeAgo } from "../../components/ui";
Acceptance checks in sandboxes, line comments and review verdicts6import { CheckBadge } from "../../components/checks";
Agents as a team: lifecycle, merge queue, billing and a new shell7import { ChangeSize, PullIcon, StateTabs } from "../../components/work";
Issues and pull requests replace intents and attempts8import { work } from "../../lib/services.server";
9import { getViewer, unwrap } from "../../lib/session.server";
10
11export function meta({ params }: Route.MetaArgs) {
12 return [{ title: `Pull requests · ${params.owner}/${params.repo} · g1t` }];
13}
14
15export async function loader({ params, context, request }: Route.LoaderArgs) {
16 const path = { namespace: params.owner, name: params.repo };
17 const state =
18 new URL(request.url).searchParams.get("state") === "closed" ? "closed" : "open";
19 return {
20 pulls: unwrap(await work.listPulls(path, getViewer(context), state)),
21 state,
22 } as const;
23}
24
25export default function Pulls({ loaderData, params }: Route.ComponentProps) {
26 const { pulls, state } = loaderData;
27 const base = `/${params.owner}/${params.repo}`;
28 return (
29 <div>
Pull requests from branches30 <StateTabs
31 to={`${base}/pulls`}
32 state={state}
33 action={
34 <ButtonLink to={`${base}/pulls/new`}>
35 <Plus size={15} />
36 New pull request
37 </ButtonLink>
38 }
39 />
Issues and pull requests replace intents and attempts40 <div className="mt-4">
41 {pulls.length === 0 ? (
42 <EmptyState
43 title={state === "open" ? "No open pull requests" : "No closed pull requests"}
44 >
Pull requests from branches45 A pull request proposes a change. Assign agents to an issue and
46 each opens one in its own fork, or push a branch and open one
47 yourself.
Issues and pull requests replace intents and attempts48 </EmptyState>
49 ) : (
50 <ul className="divide-y divide-line overflow-hidden rounded-xl border border-line">
51 {pulls.map((pull) => (
52 <li key={pull.id}>
53 <Link
Agents as a team: lifecycle, merge queue, billing and a new shell54 prefetch="intent"
Issues and pull requests replace intents and attempts55 to={`${base}/pull/${pull.number}`}
56 className="flex items-start gap-3 px-4 py-3 transition-colors hover:bg-surface"
57 >
58 <span className="mt-0.5">
59 <PullIcon status={pull.status} />
60 </span>
61 <span className="min-w-0 grow">
62 <span className="flex items-center gap-2">
63 <span className="truncate font-medium">{pull.title}</span>
64 {pull.status === "draft" && (
65 <span className="shrink-0 rounded-full border border-line px-1.5 py-px text-[0.6875rem] text-faint">
66 draft
67 </span>
68 )}
69 </span>
70 <span className="mt-0.5 block text-xs text-faint">
71 #{pull.number} opened <TimeAgo at={pull.createdAt} /> by{" "}
72 {pull.author.username}
73 {pull.issue != null && <> · for #{pull.issue}</>}
74 {pull.supersededBy != null && <> · superseded by #{pull.supersededBy}</>}
75 </span>
76 </span>
Agents as a team: lifecycle, merge queue, billing and a new shell77 <span className="mt-0.5 hidden sm:block">
78 <ChangeSize files={pull.files} />
79 </span>
Acceptance checks in sandboxes, line comments and review verdicts80 <span className="mt-0.5">
81 <CheckBadge status={pull.checkStatus} />
82 </span>
Issues and pull requests replace intents and attempts83 <span className="mt-0.5 flex shrink-0 items-center gap-1 font-mono text-xs text-muted">
Pull requests from branches84 {pull.branch ? <GitBranch size={13} /> : <Bot size={13} />}
85 {pull.branch ?? pull.agent}
Issues and pull requests replace intents and attempts86 </span>
87 </Link>
88 </li>
89 ))}
90 </ul>
91 )}
92 </div>
93 </div>
94 );
95}