diff --git a/dashboard/e2e/audit-runs.spec.ts b/dashboard/e2e/audit-runs.spec.ts index dc3bad0b..89060818 100644 --- a/dashboard/e2e/audit-runs.spec.ts +++ b/dashboard/e2e/audit-runs.spec.ts @@ -434,8 +434,15 @@ const STANDING = { }, review_changes_requested: { code: "review_changes_requested", - text: "CoderHelm's review asks for changes on `9f8e7d6`; what it could not fix is listed as deferred on the pull request.", - next: "CoderHelm does not merge over its own review; the deferred findings say what each needs.", + text: "CoderHelm's review asks for changes on `9f8e7d6`; CoderHelm takes them in its next fix round.", + next: "The fix is pushed and its review reads the new head.", + needs_person: false, + link: null, + }, + building_plan: { + code: "building_plan", + text: "The plan still has tasks in `your-team/api`: CoderHelm is building them.", + next: "Its pull request opens linked to this one, with the order they merge in.", needs_person: false, link: null, }, @@ -525,7 +532,7 @@ test("a finished run never says a fix round is taking its review's findings", as await expect(outcome).not.toContainText("still working"); await expect(outcome).not.toContainText("a fix round is taking them"); await expect(page.getByTestId("merge-standing")).toHaveText("CoderHelm's review asks for changes on 6470f1d and no fix round is running on them."); - await expect(page.getByTestId("run-next")).toContainText("takes them in a fix round, or names on the pull request what only a person can do"); + await expect(page.getByTestId("run-next")).toContainText("CoderHelm takes them in its next fix round"); await expect(page.getByTestId("run-who")).toHaveText("Nothing needed from you"); await shot(page, "run-standing-finished-not-working"); expect(errors).toEqual([]); @@ -604,7 +611,7 @@ test("the top line says what the pull request waits on: a person's approval read await mockApi(page, { run: baseRun({ merge_standing: STANDING.needs_person_approval, checks: GREEN_CHECKS, preview: null }) }); await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); await expect(page.getByTestId("run-waiting-line")).toHaveText( - "Waiting on: an approving review from a person on #101 (this repo requires one before CoderHelm merges). Ready for review: checks passed.", + "Needs 1 approval from a person (repo rule) on #101. Ready for review: checks passed.", ); // It sits above the outcome card, which keeps its own detail. const line = await page.getByTestId("run-waiting-line").boundingBox(); @@ -617,7 +624,7 @@ test("the top line says what the pull request waits on: a person's approval read test("the server's line is shown as written, and a preview shows its checks and both widths", async ({ page }) => { const errors = watchConsole(page); const line = - "Waiting on: an approving review from a person on #101 (this repo requires one before CoderHelm merges). Ready for review: checks passed, preview checked."; + "Needs 1 approval from a person (repo rule) on #101. Ready for review: checks passed, preview checked."; await mockApi(page, { run: baseRun({ merge_standing: STANDING.needs_person_approval, checks: GREEN_CHECKS, preview: PREVIEW, waiting_line: line }) }); await stubShots(page); await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); @@ -645,11 +652,66 @@ test("a preview still deploying keeps the line from saying ready, and a check no }), }); await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); - await expect(page.getByTestId("run-waiting-line")).toHaveText("Waiting on: an approving review from a person on #101 (this repo requires one before CoderHelm merges)."); + await expect(page.getByTestId("run-waiting-line")).toHaveText("Needs 1 approval from a person (repo rule) on #101."); await expect(page.getByTestId("run-preview-check")).toContainText("not run yet"); await expect(page.getByTestId("run-preview-shot")).toHaveCount(0); }); +// One state: the "Needs a person" badge and the top line read the same standing, so the page +// never says a person is needed and "Nothing needed from you" at once. +test("CoderHelm's own review asking for changes is CoderHelm's wait: never a person in the line or the badge", async ({ page }) => { + const errors = watchConsole(page); + // An older gateway's line that named a person for CoderHelm's own review: never shown against the badge. + const stale = "Waiting on: a person, CoderHelm's review asks for changes on #101 it could not make (listed on the pull request)."; + await mockApi(page, { run: baseRun({ merge_standing: STANDING.review_changes_requested, waiting_line: stale }) }); + await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); + await expect(page.getByTestId("run-who")).toHaveText("Nothing needed from you"); + const line = page.getByTestId("run-waiting-line"); + await expect(line).toHaveText("Waiting on: CoderHelm's next fix round for the changes its review asked for on #101."); + await expect(line).not.toContainText("a person"); + await expect(page.getByText("Needs a person")).toHaveCount(0); + expect(errors).toEqual([]); +}); + +test("a run still building the other repository of its plan says so, and asks nobody", async ({ page }) => { + await mockApi(page, { run: baseRun({ merge_standing: STANDING.building_plan }) }); + await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); + await expect(page.getByTestId("run-outcome")).toContainText("Pull request #101 is open; CoderHelm is building the rest of the plan"); + await expect(page.getByTestId("run-who")).toHaveText("Nothing needed from you"); + await expect(page.getByTestId("run-waiting-line")).toHaveText("Waiting on: CoderHelm building the rest of the plan (its pull request opens linked to #101)."); +}); + +test("the repo's required approval is the only wait left: it reads exactly that, with the pull request linked", async ({ page }) => { + const errors = watchConsole(page); + await mockApi(page, { run: baseRun({ merge_standing: { ...STANDING.needs_person_approval, approvals: 1 }, checks: GREEN_CHECKS, preview: null }) }); + await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); + const line = page.getByTestId("run-waiting-line"); + await expect(line).toHaveText("Needs 1 approval from a person (repo rule) on #101. Ready for review: checks passed."); + await expect(page.getByTestId("run-waiting-line-pr")).toHaveAttribute("href", "https://github.com/your-team/web/pull/101"); + await expect(page.getByTestId("run-who")).toHaveText("Needs a person"); + expect(errors).toEqual([]); +}); + +test("a held draft whose reasons are CoderHelm's own never asks a person", async ({ page }) => { + await mockApi(page, { + run: baseRun({ + merge_standing: null, + draft_hold: { + kind: "held", + summary: "Finished, but pull request #101 stays a draft: the security audit didn't run.", + reasons: [{ what: "The security audit didn't run", todo: "" }], + pr_number: 101, + since: iso(5), + needs_person: false, + }, + }), + }); + await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); + await expect(page.getByTestId("run-who")).toHaveText("Nothing needed from you"); + await expect(page.getByTestId("run-waiting-line")).toContainText("Waiting on: CoderHelm"); + await expect(page.getByText("Needs a person")).toHaveCount(0); +}); + test("a run with no preview and no standing has no top line and no preview block", async ({ page }) => { await mockApi(page, { run: baseRun({ merge_standing: null, preview: { ...PREVIEW, stage: "not_needed" } }) }); await page.goto("/runs/detail/?id=01RUNDONE000000000000000A"); diff --git a/dashboard/e2e/landing-shots-runs.spec.ts b/dashboard/e2e/landing-shots-runs.spec.ts index 4933dafb..39f0ee1d 100644 --- a/dashboard/e2e/landing-shots-runs.spec.ts +++ b/dashboard/e2e/landing-shots-runs.spec.ts @@ -69,7 +69,7 @@ const RUN = { needs_person: true, link: "/reviewer/config", }, - waiting_line: "Waiting on: an approving review from a person on #412. Ready for review: checks passed, review comments answered.", + waiting_line: "Needs 1 approval from a person (repo rule) on #412. Ready for review: checks passed, review comments answered.", checks: { sha: "7c3e91ab52d04f6e8b1a9c2d3e4f5a6b7c8d9e0f", items: [ diff --git a/dashboard/e2e/run-draft-hold.spec.ts b/dashboard/e2e/run-draft-hold.spec.ts index e16861ba..3e7b780c 100644 --- a/dashboard/e2e/run-draft-hold.spec.ts +++ b/dashboard/e2e/run-draft-hold.spec.ts @@ -126,17 +126,18 @@ test("a held run says its pull request is a draft, with each reason and what to await shot(page, "run-draft-hold"); }); -test("a pull request GitHub refused to mark ready reads as needing attention", async ({ page }) => { +test("a pull request GitHub refused to mark ready is CoderHelm's to try again, never a person's", async ({ page }) => { await mockApi(page, run({ status: "completed", waiting_on: null, - draft_hold: { kind: "failed", summary: "Finished, but GitHub refused every try to mark pull request #318 ready.", reasons: [{ what: "GitHub refused to mark it ready (403)", todo: "Mark it ready on GitHub, or check the GitHub App's permissions on the repository." }], pr_number: 318, since: null }, + draft_hold: { kind: "failed", summary: "Finished, but GitHub refused every try to mark pull request #318 ready.", reasons: [{ what: "GitHub refused to mark it ready (403)", todo: "CoderHelm asks GitHub again within the hour." }], pr_number: 318, since: null }, })); await page.goto("/runs/detail?id=01RUNHOLD"); const outcome = page.getByTestId("run-outcome"); await expect(outcome).toHaveAttribute("data-tone", "attention"); await expect(outcome).toContainText("Pull request #318 couldn't be marked ready"); - await expect(outcome).toContainText("What to do: Mark it ready on GitHub"); + await expect(page.getByTestId("run-who")).toHaveText("Nothing needed from you"); + await expect(page.getByTestId("run-next")).toContainText("CoderHelm asks GitHub again within the hour"); await expect(outcome).not.toContainText("Held since"); // Not "Done. The change is ready for review." await expect(page.getByText("Pull request #318 is ready for review")).toHaveCount(0); diff --git a/dashboard/src/app/runs/detail/page.tsx b/dashboard/src/app/runs/detail/page.tsx index e9b095bd..174f7a6c 100644 --- a/dashboard/src/app/runs/detail/page.tsx +++ b/dashboard/src/app/runs/detail/page.tsx @@ -21,7 +21,7 @@ import type { CloseRunRequest } from "@/lib/api"; import { TeamAgentAsks } from "./team-asks"; import { RunOutputs } from "./run-outputs"; import { RunPreviewPanel } from "./run-preview"; -import { waitingLine } from "@/lib/waiting-line"; +import { holdNeedsPerson, waitingLine } from "@/lib/waiting-line"; import { RunAnswered, RunQuestions } from "./run-questions"; import { AsksHistory, WaitingOnYou, useRunApprovals } from "./agent-asks"; import { WorkUsedLine } from "@/components/work-used"; @@ -944,13 +944,16 @@ function RunDetailInner() { : hold.reasons.length > 1 ? `${prWords} is a draft: ${hold.reasons.length} things to deal with` : `${prWords} is a draft: 1 thing to deal with`, - who: hold.kind === "waiting" ? "none" : "you", + // One state: a person only for a reason the platform types as a person's. + who: holdNeedsPerson(hold) ? "you" : "none", next: hold.kind === "waiting" ? "CoderHelm marks it ready for review once the check passes." : hold.kind === "failed" - ? "Mark it ready on GitHub; nothing else is left." - : "Once each item is dealt with, CoderHelm checks again and marks it ready for review.", + ? "CoderHelm asks GitHub again within the hour; nothing is needed from you." + : holdNeedsPerson(hold) + ? "Once each item is dealt with, CoderHelm checks again and marks it ready for review." + : "CoderHelm settles each item itself, checks again and marks it ready for review.", // The summary repeats the first reason word for word; it shows only when there are no reasons. body: hold.reasons.length === 0 ? {hold.summary} : null, content: (hold.reasons.length > 0 || (run.status === "needs_input" && !!run.questions?.length)) && ( @@ -1243,7 +1246,7 @@ function RunDetailInner() { {topLine && (

- {topLine} +

)} @@ -1583,15 +1586,34 @@ function finishedStanding(standing: RunMergeStanding): RunMergeStanding { ...standing, code: "review_changes_requested", text: `CoderHelm's review asks for changes${sha ? ` on \`${sha.slice(0, 7)}\`` : ""} and no fix round is running on them.`, - next: "CoderHelm looks at the pull request again: it takes them in a fix round, or names on the pull request what only a person can do and why.", + next: "CoderHelm takes them in its next fix round, and its review reads the new head.", needs_person: false, }; } +/** The line with its pull request's number ("#101") as a link to it. */ +function WithPrLink({ line, number, url }: { line: string; number?: number | null; url?: string | null }) { + const token = number ? `#${number}` : ""; + const at = token ? line.indexOf(token) : -1; + if (at < 0 || !url || !url.startsWith("https://github.com/")) return <>{line}; + return ( + <> + {line.slice(0, at)} + + {token} + + {line.slice(at + token.length)} + + ); +} + /** The outcome's title for where a finished run's pull request stands: what is true now, never "still working" for a finished run. */ function standingTitle(standing: RunMergeStanding, prWords: string): string { + if (standing.code === "plan_needs_access") return `${prWords} is open; the rest of the plan needs access`; if (standing.needs_person) return standing.code === "auto_merge_off" ? `${prWords} is ready to merge` : `${prWords} is ready for review`; switch (standing.code) { + case "building_plan": + return `${prWords} is open; CoderHelm is building the rest of the plan`; case "merged": return `${prWords} is merged`; case "closed": diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index 0438d69c..2135b688 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -2568,6 +2568,8 @@ export interface RunDraftHold { pr_number: number; /** When it was first held for these reasons. */ since?: string | null; + /** A person must act: a reason only a person has (the platform's typed hand-off). Older gateways leave it out. */ + needs_person?: boolean | null; } /** Where a finished run's pull request stands on its way to merge: the one reason that is true now. */ @@ -2580,6 +2582,8 @@ export interface RunMergeStanding { next: string; /** A person has to act for the merge to happen. */ needs_person: boolean; + /** Approving reviews from people the repository's rule requires (`needs_person_approval`, `repo_requires_person_review`); absent when not known. */ + approvals?: number | null; /** Where the rule is set, when a setting decides it: a dashboard path or a GitHub URL. */ link?: string | null; } diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 81b76155..066b3b6f 100644 --- a/dashboard/src/lib/openapi-fields.ts +++ b/dashboard/src/lib/openapi-fields.ts @@ -2,7 +2,7 @@ // docs/api/openapi.json. Do not edit; run `npm run openapi:fields` instead. /** The platform commit this was generated from. */ -export const OPENAPI_REF = "c0206416f191a0c9bde29d3a6bb87622dd13a77a"; +export const OPENAPI_REF = "eb8f8f7c000a728eba36f7ca2cc373401effbdce"; /** The fields each public API schema has. */ export interface OpenApiFields { @@ -76,10 +76,10 @@ export interface OpenApiFields { RunCoderExploration: "calls_before_first_write" | "map_commit" | "tool_calls"; RunCoveredBy: "author" | "carried" | "note" | "number" | "open_items" | "outcome" | "own" | "reason" | "repo" | "superseded" | "title" | "url"; RunCoveredCarried: "branch" | "commits" | "files" | "head" | "rebuilt"; - RunDraftHold: "kind" | "pr_number" | "reasons" | "since" | "summary"; + RunDraftHold: "kind" | "needs_person" | "pr_number" | "reasons" | "since" | "summary"; RunDraftHoldReason: "todo" | "what"; RunExploration: "code_map" | "coder"; - RunMergeStanding: "code" | "link" | "needs_person" | "next" | "text"; + RunMergeStanding: "approvals" | "code" | "link" | "needs_person" | "next" | "text"; RunNoChange: "checks" | "open_pr" | "reason"; RunNoChangePr: "closed" | "line" | "number" | "repo" | "title" | "url" | "verdict" | "why"; RunNote: "message" | "timestamp"; diff --git a/dashboard/src/lib/waiting-line.ts b/dashboard/src/lib/waiting-line.ts index 2efd3eee..b963d422 100644 --- a/dashboard/src/lib/waiting-line.ts +++ b/dashboard/src/lib/waiting-line.ts @@ -38,21 +38,47 @@ export function previewWords(stage: string): string { } } +/** "1 approval", "2 approvals". */ +export function approvalsWords(n?: number | null): string { + const k = Math.max(1, n ?? 1); + return k === 1 ? "1 approval" : `${k} approvals`; +} + +/** + * Whether a line names a person as the one who must act. The page's "Needs a + * person" badge and its top line come from one state (the standing's + * `needs_person`), so a line that disagrees with it is never shown. + */ +export function namesAPerson(line: string): boolean { + const l = line.trim().toLowerCase(); + return l.startsWith("needs ") || l.includes("waiting on: a person"); +} + /** What the pull request waits on, from its merge standing. */ function fromStanding(s: RunMergeStanding, pr: string): string { + if (s.needs_person) { + switch (s.code) { + case "needs_person_approval": + return `Needs ${approvalsWords(s.approvals)} from a person (repo rule) on ${pr}.`; + case "repo_requires_person_review": + return s.approvals + ? `Needs ${approvalsWords(s.approvals)} from a person (repo rule) on ${pr}.` + : `Needs a person: the branch rules on ${pr} require an approving review from a person, or another rule GitHub enforces (repo rule).`; + case "auto_merge_off": + return `Needs a person on your team to merge ${pr} (auto-merge is off for this repo).`; + default: + return s.text ? `Needs a person on ${pr}. ${clean(s.text)}.` : ""; + } + } switch (s.code) { - case "needs_person_approval": - return `Waiting on: an approving review from a person on ${pr} (this repo requires one before CoderHelm merges).`; - case "auto_merge_off": - return `Waiting on: a person on your team to merge ${pr} (auto-merge is off for this repo).`; - case "repo_requires_person_review": - return `Waiting on: the branch rules on GitHub for ${pr} (they require an approving review from a person, or another rule GitHub enforces).`; + case "building_plan": + return `Waiting on: CoderHelm building the rest of the plan (its pull request opens linked to ${pr}).`; case "reviewing": return `Waiting on: CoderHelm's review of the newest commit on ${pr}.`; case "fixing_review": return `Waiting on: CoderHelm's fix round for its review's findings on ${pr}.`; case "review_changes_requested": - return `Waiting on: the changes CoderHelm's review asked for on ${pr}.`; + return `Waiting on: CoderHelm's next fix round for the changes its review asked for on ${pr}.`; case "checks_running": return `Waiting on: the checks still running on ${pr}.`; case "checks_failing": @@ -68,7 +94,7 @@ function fromStanding(s: RunMergeStanding, pr: string): string { case "closed": return `Nothing: ${pr} was closed without merging.`; default: - return s.text ? `Waiting on: ${lower(clean(s.text))}.` : ""; + return s.text ? `Waiting on: CoderHelm, ${lower(clean(s.text))}.` : ""; } } @@ -85,15 +111,19 @@ function readiness(input: WaitingInput): string { /** The run page's top line, or empty when there is nothing to say. */ export function waitingLine(input: WaitingInput): string { - const given = input.waiting_line?.trim(); - if (given) return given; const pr = input.pr_number ? `#${input.pr_number}` : "the pull request"; const hold = input.draft_hold; + const given = input.waiting_line?.trim(); + // The server's line, unless it disagrees with the one state the badge reads. + const person = hold ? holdNeedsPerson(hold) : !!input.merge_standing?.needs_person; + if (given && (namesAPerson(given) === person || (!hold && !input.merge_standing))) return given; if (hold) { const first = hold.reasons?.[0]?.what?.trim(); if (hold.kind === "waiting") return `Waiting on: ${lower(clean(first || hold.summary))} (CoderHelm checks again by itself).`; - if (first) return `Waiting on: ${lower(clean(first))}, on ${pr}${hold.reasons.length > 1 ? ` (and ${hold.reasons.length - 1} more)` : ""}.`; - if (hold.summary) return `Waiting on: ${lower(clean(hold.summary))}.`; + if (hold.kind === "failed") return `Waiting on: GitHub to take ${pr} out of draft (CoderHelm tries again within the hour).`; + if (!holdNeedsPerson(hold)) return `Waiting on: CoderHelm, ${pr} stays a draft until it settles this: ${lower(clean(first || hold.summary))} (it checks again by itself).`; + if (first) return `Waiting on: a person, ${pr} stays a draft because ${lower(clean(first))}${hold.reasons.length > 1 ? ` (and ${hold.reasons.length - 1} more)` : ""}.`; + if (hold.summary) return `Waiting on: a person, ${lower(clean(hold.summary))}.`; } const s = input.merge_standing; if (!s) return ""; @@ -101,3 +131,8 @@ export function waitingLine(input: WaitingInput): string { const ready = readiness(input); return [line, ready].filter(Boolean).join(" "); } + +/** Whether a draft hold waits on a person: only a held one the server types as a person's (older servers: every held one). */ +export function holdNeedsPerson(hold: RunDraftHold): boolean { + return hold.kind === "held" && hold.needs_person !== false; +}