Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This repository holds the dashboard, the docs site and the website. The agent, t
| Feature | What you get |
|---|---|
| [Tickets to pull requests](https://docs.coderhelm.com/getting-started/first-run) | Assign a [GitHub issue](https://docs.coderhelm.com/getting-started/github) or [Jira ticket](https://docs.coderhelm.com/getting-started/atlassian), add the `coderhelm` label or comment `/coderhelm`. A plan, the change, your tests, a self review and a pull request. |
| [PR reviewer](https://docs.coderhelm.com/getting-started/reviewer) | Add the review label (`ch-review` by default) to any pull request. A real GitHub review with line comments, a risk level and a verdict: it requests changes only for a named correctness, security or data loss problem with its evidence, and everything else is a labeled note. |
| [PR reviewer](https://docs.coderhelm.com/getting-started/reviewer) | Add the review label (`ch-review` by default) to any pull request, or have it review every pull request. A real GitHub review with line comments, a risk level and a verdict: it requests changes only for a named correctness, security or data loss problem with its evidence, and everything else is a labeled note. |
| [CI and review comment fixes](https://docs.coderhelm.com/getting-started/review-fixes) | Fixes failing CI on its pull requests, answers review comments, resolves conflicts and, with auto merge on, merges only the exact commit it reviewed. |
| [Alerts to fixes](https://coderhelm.com/alerts) | Route CloudWatch alarms and EventBridge events through SNS. Matching alerts become analyzed pull requests that a person approves. |
| [Stale pull requests](https://docs.coderhelm.com/getting-started/stale-pull-requests) | Off by default. Marks a pull request stale after 7 days with no activity from a person and closes it 7 days later, starting in Preview only and keeping the branch. |
Expand Down
35 changes: 34 additions & 1 deletion dashboard/e2e/audit-reviewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const RELEASES = [
];

const CONFIG = {
enabled: true, label: "ch-review", killed: false, instructions: "Watch database changes.", auto_merge: false, merge_method: "squash",
enabled: true, label: "ch-review", trigger: "label", killed: false, instructions: "Watch database changes.", auto_merge: false, merge_method: "squash",
require_human_approval: true, auto_tag: false, tag_mode: "semver", tag_prefix: "v", tag_batch_minutes: 15, health_check: false,
verify_tests: false, require_tests: false, auto_labels: false, auto_label_allow: "", auto_label_requires: "", auto_label_guide: "",
release_notes: false, release_notes_branch: "", release_notes_confluence_space: "", release_notes_confluence_parent_id: "",
Expand Down Expand Up @@ -879,6 +879,39 @@ test("a reminder webhook on the wrong host is caught before saving, and Slack wo
expect(errors).toEqual([]);
});

test("the review trigger switches between the label and every pull request, and saves", async ({ page }) => {
const errors = watchConsole(page);
const db = await mockApi(page);
await page.goto("/reviewer/config?repo=your-team%2Fweb");
const control = page.getByRole("group", { name: "Review" });
const byLabel = control.getByRole("button", { name: "When labelled ch-review" });
const every = control.getByRole("button", { name: "Every pull request" });
// A repo saved before the setting existed reviews by label.
await expect(byLabel).toHaveAttribute("aria-pressed", "true");
await expect(every).toHaveAttribute("aria-pressed", "false");
await expect(page.getByText("Only pull requests someone adds the label to are reviewed, and again on each push.")).toBeVisible();
// The option names the label as it is typed.
await page.getByRole("textbox", { name: "Trigger label" }).fill("needs-review");
await expect(control.getByRole("button", { name: "When labelled needs-review" })).toBeVisible();
await page.getByRole("textbox", { name: "Trigger label" }).fill("ch-review");

await every.click();
await expect(every).toHaveAttribute("aria-pressed", "true");
await expect(page.getByText("Every pull request is reviewed when it is opened, marked ready or pushed to. Drafts wait until they are ready.")).toBeVisible();
await expect(page.getByText("Only pull requests someone adds the label to are reviewed")).toHaveCount(0);
// The label stays: it asks for a review by hand.
await expect(page.getByText("Add this label to ask for a review by hand")).toBeVisible();
await expect(page.getByTestId("reviewer-summary")).toContainText("Reviews every pull request, and any labelled “ch-review”.");
await expect(page.getByTestId("save-bar")).toContainText("1 unsaved change on your-team/web");
await shot(page, "audit-reviewer-config-every-pr");

await page.getByRole("button", { name: "Save settings" }).click();
await expect(page.getByText("Reviewer settings saved")).toBeVisible();
const { webhooks: _saved, ...base } = CONFIG;
expect(db.bodies.at(-1)).toMatchObject({ ...base, trigger: "every_pr", label: "ch-review" });
expect(errors).toEqual([]);
});

test("saving sends the same settings body as before, with every edit in it", async ({ page }) => {
const errors = watchConsole(page);
const db = await mockApi(page);
Expand Down
42 changes: 38 additions & 4 deletions dashboard/src/app/reviewer/config/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ANY_CHANGE } from "@/lib/capabilities";
import { Suspense, useEffect, useState } from "react";
import { useSearchParams } from "next/navigation";
import Link from "next/link";
import { api, type ReviewerConfig as ApiReviewerConfig, type Repo } from "@/lib/api";
import { api, type ReviewerConfig as ApiReviewerConfig, type Repo, type ReviewTrigger } from "@/lib/api";
import { ChannelPicker, channelsPayload, channelsSummary, draftFrom, draftValid, type ChannelsDraft } from "@/components/chat-channels";

/** The form: the API's settings plus the reminder channels being edited
Expand Down Expand Up @@ -77,6 +77,7 @@ export default function ReviewerConfigGuarded() {
const DEFAULTS: ReviewerConfig = {
enabled: false,
label: "ch-review",
trigger: "label",
killed: false,
instructions: "",
auto_merge: false,
Expand Down Expand Up @@ -120,6 +121,12 @@ const MERGE_METHODS = [
{ value: "rebase", label: "Rebase" },
];

/** What starts a review, one short line for each. */
const TRIGGER_HELP: Record<ReviewTrigger, string> = {
label: "Only pull requests someone adds the label to are reviewed, and again on each push.",
every_pr: "Every pull request is reviewed when it is opened, marked ready or pushed to. Drafts wait until they are ready.",
};

const TAG_MODES = [
{ value: "semver", label: "Version number" },
{ value: "date", label: "Date and time" },
Expand Down Expand Up @@ -148,7 +155,7 @@ const STOP_SECTION = "stop";

/** Which settings each section holds, for its tab's unsaved dot. */
const SECTION_KEYS: Record<SectionId, Key[]> = {
reviews: ["enabled", "label", "instructions", "killed"],
reviews: ["enabled", "trigger", "label", "instructions", "killed"],
tests: ["verify_tests", "require_tests"],
labels: ["auto_labels", "auto_label_allow", "auto_label_requires", "auto_label_guide"],
merge: ["auto_merge", "merge_method", "require_human_approval", "deploy_label", "deploy_workflows"],
Expand Down Expand Up @@ -195,7 +202,11 @@ function stateOf(cfg: ReviewerConfig): StatusLook {
function summaryLines(cfg: ReviewerConfig): string[] {
if (cfg.killed) return ["Every reviewer action on this repo is stopped, whatever else is set below."];
if (!cfg.enabled) return ["The reviewer ignores this repo. Turn it on under Reviews."];
const lines = [`Reviews pull requests labelled “${cfg.label || DEFAULTS.label}”.`];
const lines = [
cfg.trigger === "every_pr"
? `Reviews every pull request, and any labelled “${cfg.label || DEFAULTS.label}”.`
: `Reviews pull requests labelled “${cfg.label || DEFAULTS.label}”.`,
];
if (cfg.verify_tests) lines.push(`Runs the affected tests before it reviews${cfg.require_tests ? ", and requests changes when a behavior change comes without tests" : ""}.`);
else lines.push(`Reads the code without running tests${cfg.require_tests ? ", and requests changes when a behavior change comes without tests" : ""}.`);
if (cfg.auto_labels) lines.push("Adds the CI labels each pull request needs.");
Expand Down Expand Up @@ -584,10 +595,33 @@ function ReviewerConfigPage() {
layout="toggle"
control={({ labelId, helpId, inputId }) => <Switch id={inputId} checked={cfg.enabled} onChange={(v) => set("enabled", v)} labelledBy={labelId} describedBy={helpId} />}
/>
<SettingsRow
layout="stacked"
label="Review"
help={TRIGGER_HELP[cfg.trigger] ?? TRIGGER_HELP.label}
{...marks("trigger")}
control={({ helpId }) => (
<div aria-describedby={helpId} data-testid="review-trigger">
<Segmented
label="Review"
options={[
{ value: "label", label: `When labelled ${cfg.label || DEFAULTS.label}` },
{ value: "every_pr", label: "Every pull request" },
]}
value={cfg.trigger === "every_pr" ? "every_pr" : "label"}
onChange={(v: ReviewTrigger) => set("trigger", v)}
/>
</div>
)}
/>
<SettingsRow
layout="stacked"
label="Trigger label"
help="Add this label to a pull request to have it reviewed."
help={
cfg.trigger === "every_pr"
? "Add this label to ask for a review by hand, for example on a commit already reviewed."
: "Add this label to a pull request to have it reviewed."
}
{...marks("label")}
control={({ inputId, helpId }) => (
<input id={inputId} aria-describedby={helpId} value={cfg.label} onChange={(e) => set("label", e.target.value)} placeholder="ch-review" className={monoInputClass} />
Expand Down
5 changes: 5 additions & 0 deletions dashboard/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2134,9 +2134,14 @@ export interface StaleActivity {
kept_open: StaleKeptOpen[];
}

/** What starts a review of a person's pull request: the label, or every pull request. */
export type ReviewTrigger = "label" | "every_pr";

export interface ReviewerConfig {
enabled: boolean;
label: string;
/** "label" (the default): only pull requests carrying `label`. "every_pr": every pull request opened, readied or pushed to; the label still asks by hand. */
trigger: ReviewTrigger;
killed: boolean;
instructions: string;
auto_merge: boolean;
Expand Down
11 changes: 8 additions & 3 deletions docs/content/docs/getting-started/reviewer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ A request for changes lasts only while what it names does: once those threads ar

1. Open **Code review**, then **Reviewer**, then **Settings**. Under **Settings for**, pick a repository.
2. Switch on **Enable reviewer for this repo**.
3. Keep the **Trigger label** `ch-review`, or change it.
3. Under **Review**, pick what starts a review: **When labelled** (the default) or **Every pull request**.
4. Keep the **Trigger label** `ch-review`, or change it.

Add the label to a pull request to get a review. Once a pull request has the label, every new push is reviewed again. Draft pull requests are skipped until they are marked ready.
**When labelled:** add the label to a pull request to get a review. Once a pull request has the label, every new push is reviewed again.

**Every pull request:** every pull request is reviewed when it is opened, reopened, marked ready for review or pushed to, with no label needed. That includes pull requests from dependency bots, since they change your code too. The label still works: add it to ask for a review by hand. Pull requests CoderHelm opens itself are reviewed once, through the label it adds to them.

Either way, draft pull requests are skipped until they are marked ready, each commit is reviewed once, and every review counts against your team's monthly token limit.

## Follow a review while it runs

Expand Down Expand Up @@ -64,7 +69,7 @@ Open **Settings** on the **Reviewer** page. **Settings for** at the top picks wh

| Section | What you can set |
| --- | --- |
| Reviews | On or off, trigger label, what to focus on |
| Reviews | On or off, when labelled or every pull request, trigger label, what to focus on |
| Tests | Check the change by running tests (a failing run requests changes); require tests (a missing test is a Suggestion, and CoderHelm writes tests for its own changes) |
| CI labels | Labels it may add, labels that must go together, guidance |
| Auto-merge | Merge when it approves, merge method, deploy labels, also require a person's approval |
Expand Down
Loading