g1t/apps/web/app/components/lifecycle.tsx
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 shell | 1 | import { Check, Hand } from "lucide-react"; |
| 2 | ||
| 3 | import type { Lifecycle, Stage } from "@g1t/contracts"; | |
| 4 | ||
| 5 | const STEPS = ["Change", "Checks", "Review", "Up to date", "Landing"]; | |
| 6 | ||
| 7 | /** Which step a stage is at. A revision is the change being made again. */ | |
| 8 | const STEP_OF: Record<Exclude<Stage, "needs_you">, number> = { | |
| 9 | working: 0, | |
| 10 | revising: 0, | |
| 11 | checking: 1, | |
| 12 | reviewing: 2, | |
| 13 | catching_up: 3, | |
| 14 | ready: 4, | |
| 15 | queued: 4, | |
| 16 | }; | |
| 17 | ||
| 18 | /** A word or two for a stage, for lists. */ | |
| 19 | export const STAGE_LABEL: Record<Stage, string> = { | |
| 20 | working: "Making the change", | |
| 21 | checking: "Running checks", | |
| 22 | reviewing: "In review", | |
| 23 | revising: "Revising", | |
| 24 | catching_up: "Catching up", | |
| 25 | queued: "In the merge queue", | |
| 26 | ready: "Ready to merge", | |
| 27 | needs_you: "Needs you", | |
| 28 | }; | |
| 29 | ||
| 30 | /** Five dots showing how far along a pull request is. */ | |
| 31 | export function StageDots({ stage }: { stage: Stage }) { | |
| 32 | if (stage === "needs_you") return null; | |
| 33 | const current = STEP_OF[stage]; | |
| 34 | return ( | |
| 35 | <span className="flex items-center gap-1" aria-hidden="true"> | |
| 36 | {STEPS.map((step, index) => ( | |
| 37 | <span | |
| 38 | key={step} | |
| 39 | className={`size-1.5 rounded-full ${ | |
| 40 | index < current || stage === "ready" | |
| 41 | ? "bg-accent" | |
| 42 | : index === current | |
| 43 | ? "animate-pulse bg-accent" | |
| 44 | : "bg-line-strong" | |
| 45 | }`} | |
| 46 | /> | |
| 47 | ))} | |
| 48 | </span> | |
| 49 | ); | |
| 50 | } | |
| 51 | ||
| 52 | const TITLE: Record<Stage, string> = { | |
| 53 | working: "g1t is seeing this through", | |
| 54 | checking: "g1t is seeing this through", | |
| 55 | reviewing: "g1t is seeing this through", | |
| 56 | revising: "g1t is seeing this through", | |
| 57 | catching_up: "g1t is seeing this through", | |
| 58 | queued: "In the merge queue", | |
| 59 | ready: "Ready to merge", | |
| 60 | needs_you: "Needs you", | |
| 61 | }; | |
| 62 | ||
| 63 | /** | |
| 64 | * Where a pull request made by a g1t agent stands between "assigned" and | |
| 65 | * "ready to merge", and what is happening to it right now. | |
| 66 | */ | |
| 67 | export function LifecyclePanel({ lifecycle }: { lifecycle: Lifecycle }) { | |
| 68 | const { stage, detail, revisions } = lifecycle; | |
| 69 | if (stage === "needs_you") { | |
| 70 | return ( | |
| 71 | <div className="mt-4 rounded-xl border border-warn/40 bg-warn/5 px-4 py-3 text-sm"> | |
| 72 | <p className="flex items-center gap-2.5 font-medium"> | |
| 73 | <Hand size={16} className="shrink-0 text-warn" /> | |
| 74 | {TITLE[stage]} | |
| 75 | </p> | |
| 76 | <p className="mt-1 text-muted">{detail}</p> | |
| 77 | </div> | |
| 78 | ); | |
| 79 | } | |
| 80 | const current = STEP_OF[stage]; | |
| 81 | const ready = stage === "ready"; | |
| 82 | return ( | |
| 83 | <div | |
| 84 | className={`mt-4 rounded-xl border px-4 py-3 text-sm ${ | |
| 85 | ready ? "border-accent/40 bg-accent/5" : "border-line bg-surface" | |
| 86 | }`} | |
| 87 | > | |
| 88 | <div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1"> | |
| 89 | <p className="font-medium">{TITLE[stage]}</p> | |
| 90 | {revisions > 0 && ( | |
| 91 | <p className="text-xs text-faint"> | |
| 92 | Revised {revisions === 1 ? "once" : `${revisions} times`} | |
| 93 | </p> | |
| 94 | )} | |
| 95 | </div> | |
| 96 | <ol className="mt-3 flex flex-wrap items-center gap-x-2 gap-y-2 text-xs"> | |
| 97 | {STEPS.map((step, index) => { | |
| 98 | const done = index < current || ready; | |
| 99 | const active = index === current && !ready; | |
| 100 | return ( | |
| 101 | <li key={step} className="flex items-center gap-2"> | |
| 102 | {index > 0 && ( | |
| 103 | <span | |
| 104 | aria-hidden="true" | |
| 105 | className={`h-px w-4 sm:w-6 ${done || active ? "bg-accent-dim" : "bg-line"}`} | |
| 106 | /> | |
| 107 | )} | |
| 108 | <span | |
| 109 | className={`flex items-center gap-1.5 ${ | |
| 110 | done ? "text-fg" : active ? "font-medium text-accent" : "text-faint" | |
| 111 | }`} | |
| 112 | > | |
| 113 | {done ? ( | |
| 114 | <Check size={13} className="text-accent" /> | |
| 115 | ) : ( | |
| 116 | <span | |
| 117 | className={`size-1.5 rounded-full ${ | |
| 118 | active ? "animate-pulse bg-accent" : "bg-line-strong" | |
| 119 | }`} | |
| 120 | /> | |
| 121 | )} | |
| 122 | {step} | |
| 123 | </span> | |
| 124 | </li> | |
| 125 | ); | |
| 126 | })} | |
| 127 | </ol> | |
| 128 | <p className="mt-3 text-muted">{detail}</p> | |
| 129 | </div> | |
| 130 | ); | |
| 131 | } |