A pull request's status, checks and reviewers.
Handle leads without an email domain #482
northwind/leads · agent/fix-missing-domain → main
- +42−7in 3 files
- Grace Liu approved
- Grace LiuRequiredApproved
- Priya NairCommented
1 of 4 checks failedChecks
1 thing blocks merging
- The lint check failed.
import { Command, UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Effect, Schema } from "effect"import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { PullRequestCard, PullRequestCheck } from "./ui/uicontext/components/kit/PullRequest.ts"import { sx } from "./ui/uicontext/components/Sx.ts"// A pull request an agent opened: one check failed, so it can't merge yet. Re-run the check; once it// passes, Merge is on. Two Commands stand in for the code host.const styles = stylex.create({ column: { inlineSize: "min(100%, 40rem)" } })const Message = UiSchema.TaggedEnum({ RequestedRerun: { check: Schema.String }, CompletedRerun: { check: Schema.String }, RequestedMerge: {}, CompletedMerge: {},})const Rerun = Command.make("Example.Rerun", { args: { check: Schema.String } }, ({ check }) => Effect.sleep("1500 millis").pipe(Effect.as(Message.CompletedRerun({ check }))))const Merge = Command.make("Example.Merge", {}, () => Effect.sleep("1200 millis").pipe(Effect.as(Message.CompletedMerge())))export const AgentPullRequest = Html.component({ name: "AgentPullRequest", model: Schema.Struct({ checks: Schema.Array(PullRequestCheck), merged: Schema.Boolean, outcome: Schema.NullOr(Outcome), }), message: Message,}).make({ init: () => ({ checks: [ { name: "unit tests", status: "passed" as const, required: true }, { name: "lint", status: "failed" as const, required: true, description: "2 problems in src/leads/domain.ts", href: "#lint" }, { name: "type check", status: "passed" as const, required: true }, { name: "preview deploy", status: "skipped" as const, description: "Only for changes to the web app" }, ], merged: false, outcome: null, }), update: { RequestedRerun: ($, { check }) => $.evolve({ outcome: { _tag: "Pending", request: `rerun:${check}` }, checks: (cs) => cs.map((c) => (c.name === check ? { name: c.name, status: "pending" as const, required: true, description: "Running…" } : c)), }).run(Rerun.make({ check })), CompletedRerun: ($, { check }) => $.evolve({ outcome: { _tag: "Accepted", request: `rerun:${check}` }, checks: (cs) => cs.map((c) => (c.name === check ? { name: c.name, status: "passed" as const, required: true } : c)), }), RequestedMerge: ($) => $.evolve({ outcome: { _tag: "Pending", request: "merge" } }).run(Merge.make()), CompletedMerge: ($) => $.evolve({ merged: true, outcome: { _tag: "Accepted", request: "merge" } }), }, view: (h, model) => h.div.attrs(sx(styles.column)).children( PullRequestCard(h, { props: { id: "482", agentId: "pr-demo", title: "Handle leads without an email domain", number: "#482", href: "#pr-482", repository: "northwind/leads", head: "agent/fix-missing-domain", base: "main", state: model.merged ? "merged" : "open", ...(model.merged ? { reason: "Merged into main just now." } : {}), diff: { additions: 42, deletions: 7, files: 3 }, checks: model.checks, review: { state: "approved", text: "Grace Liu approved" }, reviewers: [ { name: "Grace Liu", state: "approved", required: true }, { name: "Priya Nair", state: "commented" }, ], requiredApprovals: 1, mergeable: "clean", mergeLabel: "Squash and merge", attribution: "Opened by the agent for Ada Lovelace", owner: { label: "Session: leads without a domain", href: "#session" }, can: ["merge", "rerun"], outcome: model.outcome, }, onEmit: { RequestedRerun: ({ check }) => Message.RequestedRerun({ check }), RequestedMerge: () => Message.RequestedMerge(), RequestedReview: () => undefined, }, }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/pull-requestUsage
import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { PullRequestCard, type PullRequestCheck } from "./ui/uicontext/components/kit/PullRequest.ts"const Message = UiSchema.TaggedEnum({ RequestedMerge: {} })// the app owns the pull request; the card asks to merge and shows the answer through `outcome`export const PullRequest = (h: Html.H<typeof Message.Type>, checks: ReadonlyArray<PullRequestCheck>, outcome: Outcome | null) => PullRequestCard(h, { props: { id: "482", title: "Handle leads without an email domain", number: "#482", head: "agent/fix-missing-domain", base: "main", state: "open", checks, requiredApprovals: 1, reviewers: [{ name: "Grace Liu", state: "approved" }], can: ["merge"], outcome, }, onEmit: { RequestedMerge: () => Message.RequestedMerge(), RequestedReview: () => undefined, RequestedRerun: () => undefined }, })Examples
What blocks a merge
The merge box lists what stands in the way, from mergeable, checks, reviewers and requiredApprovals; Merge stays off until nothing does.
Move invoices to the new ledger #490
northwind/billing · ledger-v2 → main
- +1,204−388in 31 files
- Theo RobinsonChanges requested
- Maya ChenRequiredPending
1 of 3 checks failedChecks
5 things block merging
- It conflicts with main. Resolve the conflicts to merge.
- The unit tests check failed.
- 1 check is still running.
- Theo Robinson requested changes.
- Needs approval from Maya Chen.
Retry webhook deliveries with backoff #487
northwind/hooks · retry-backoff → main
- Grace LiuApproved
1 check passedChecks
Ready to merge
main moved while this was merging. Update the branch and try again.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { PullRequestCard } from "./ui/uicontext/components/kit/PullRequest.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"// Why it can't merge, most serious first: conflicts, failed and running checks, requested changes// and missing approvals. A refused merge says what the code host answered.const styles = stylex.create({ column: { display: "flex", flexDirection: "column", gap: space.lg, inlineSize: "min(100%, 40rem)" } })export const BlockedPullRequests = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.column)).children( PullRequestCard(h, { key: "conflicts", props: { id: "490", agentId: "pr-blocked", title: "Move invoices to the new ledger", number: "#490", repository: "northwind/billing", head: "ledger-v2", base: "main", state: "open", diff: { additions: 1204, deletions: 388, files: 31 }, checks: [ { name: "unit tests", status: "failed", required: true, description: "3 of 412 failed" }, { name: "integration", status: "pending", required: true }, { name: "lint", status: "passed", required: true }, ], reviewers: [ { name: "Theo Robinson", state: "changes" }, { name: "Maya Chen", state: "pending", required: true }, ], requiredApprovals: 2, mergeable: "conflicts", can: ["merge", "rerun"], }, }), PullRequestCard(h, { key: "refused", props: { id: "487", agentId: "pr-refused-merge", title: "Retry webhook deliveries with backoff", number: "#487", repository: "northwind/hooks", head: "retry-backoff", base: "main", state: "open", checks: [{ name: "unit tests", status: "passed" }], reviewers: [{ name: "Grace Liu", state: "approved" }], requiredApprovals: 1, mergeable: "clean", can: ["merge"], outcome: { _tag: "Refused", request: "merge", reason: "main moved while this was merging. Update the branch and try again." }, }, }), )Draft, merged, closed and refused
state follows the pull request on the code host; reason says why it closed, how it merged, or why the agent couldn't open it.
Add a CSV export to the reports page #493
northwind/reports · agent/csv-export → main
- +86−4in 4 files
- No review yet
1 check passedChecks
Fix the timezone in weekly digests
northwind/digest · agent/digest-tz → main
Add the company size to new contacts #479
northwind/leads · agent/company-size → main
Merged into main by Grace Liu on Nov 28.
- +118−12in 6 files
- Grace Liu approved
Cache the pricing table #471
northwind/billing
Closed by Theo Robinson: the pricing service caches it now.
Bump the payment library
northwind/payments
This repository isn't granted to the agent. An admin can grant it in Settings.
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { PullRequestCard } from "./ui/uicontext/components/kit/PullRequest.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { space } from "./ui/uicontext/components/tokens.stylex.ts"// A pull request's life: a draft waiting to be marked ready, one being opened, merged, closed, and// one the agent wasn't allowed to open.const styles = stylex.create({ column: { display: "flex", flexDirection: "column", gap: space.lg, inlineSize: "min(100%, 40rem)" } })export const PullRequestStates = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.column)).children( PullRequestCard(h, { key: "draft", props: { id: "493", agentId: "pr-draft", title: "Add a CSV export to the reports page", number: "#493", repository: "northwind/reports", head: "agent/csv-export", base: "main", state: "draft", diff: { additions: 86, deletions: 4, files: 4 }, checks: [{ name: "unit tests", status: "passed" }], review: { state: "none" }, attribution: "Opened by the agent for Maya Chen", reviewLabel: "Mark ready for review", can: ["review"], }, }), PullRequestCard(h, { key: "pending", props: { id: "new", agentId: "pr-opening", title: "Fix the timezone in weekly digests", repository: "northwind/digest", head: "agent/digest-tz", base: "main", state: "pending", can: [] }, }), PullRequestCard(h, { key: "merged", props: { id: "479", agentId: "pr-merged", title: "Add the company size to new contacts", number: "#479", repository: "northwind/leads", head: "agent/company-size", base: "main", state: "merged", reason: "Merged into main by Grace Liu on Nov 28.", diff: { additions: 118, deletions: 12, files: 6 }, review: { state: "approved", text: "Grace Liu approved" }, can: [], }, }), PullRequestCard(h, { key: "closed", props: { id: "471", agentId: "pr-closed", title: "Cache the pricing table", number: "#471", repository: "northwind/billing", state: "closed", reason: "Closed by Theo Robinson: the pricing service caches it now.", can: [], }, }), PullRequestCard(h, { key: "refused", props: { id: "x", agentId: "pr-refused", title: "Bump the payment library", repository: "northwind/payments", state: "refused", reason: "This repository isn't granted to the agent. An admin can grant it in Settings.", can: [], }, }), )API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | The pull request's id in the app, sent back with RequestedReview |
titlerequired | string | — | The pull request's title |
number | string | — | "#482" |
href | string | — | Where the pull request opens on the code host |
repository | string | — | "acme/web" |
head | string | — | The branch with the changes: "fix/login-redirect" |
base | string | — | The branch it merges into: "main" |
staterequired | "pending" | "draft" | "open" | "merged" | "closed" | "refused" | — | The pull request's lifecycle on the code host, not a run: pending (being opened), draft, open, merged, closed, or refused (the agent wasn't allowed to open it; see reason) |
reason | string | — | Why it was refused or closed: "This repository isn't granted to the agent." |
diff | { additions, deletions, files } | — | How many lines were added and removed, in how many files |
checks | PullRequestCheck[] | — | The checks run on it, each passed, failed, pending or skipped |
review | { state, text } | — | Where review stands, with an optional line such as "Ada approved" |
reviewers | { name, state, required }[] | — | Each reviewer and where their review stands |
requiredApprovals | number | — | Approving reviews the base branch requires |
mergeable | "clean" | "conflicts" | "behind" | "checking" | — | Whether the branch merges cleanly into the base: checking while the host works it out |
mergeLabel | string | "Merge" | "Merge", "Squash and merge"; "Merge" by default |
attribution | string | — | Whose name it is under and who asked: "Opened by the agent as Ada Lovelace" |
owner | { label, href } | — | The session or run that owns it |
note | string | — | A verdict or note: "The auto-reviewer would approve" |
canrequired | ("review" | "merge" | "rerun")[] | — | What the person may do: "review" asks for a review, "merge" merges, "rerun" re-runs a failed check |
reviewLabel | string | — | "Ask the agent to review", "Request review" |
outcome | Outcome | null | — | The app's answer to the last request: "review", "merge", or "rerun:<check name>" |
agentId | string | pr:<id> | This card's id for agents, unique on the page; pr:<id> by default |
Events
| Event | Payload | Description |
|---|---|---|
RequestedReview | { id: string } | Ask for a review of this pull request; answer through outcome with request "review" |
RequestedMerge | { id: string } | Merge it into the base; answer through outcome with request "merge" |
RequestedRerun | { id: string; check: string } | Run a failed check again; answer through outcome with request rerun:<check> |
Agent actions
| Action | Description |
|---|---|
ClickedReview | Ask for a review of the pull request |
ClickedMergeasks first | Merge the pull request into its base; only when nothing blocks it |
ClickedRerun | Run a failed check again, by its name |
Accessibility
- The card is an article named by its title, a heading. Its state and each check's status are written in words, not shown by color alone.
- Request review is a real button, disabled when a review can't be asked for, and a refusal shows its reason.
- Agents read the state, checks and review, and the one action they can take is asking for a review.