From f12d929869eee58404586b3d0b070ceaefdb0049 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Fri, 6 Nov 2026 09:27:51 -0500 Subject: [PATCH] Run page: a covered run shows what it carried and where, and offers to close the superseded pull request A run covered by Coderhelm's own pull request continued in it: the page shows the commits and files carried over, what is still open for the ticket, and the ticket's earlier pull request as superseded with a Close button that acts only on a click. A person's covering pull request is linked and never offered to change. Retry is offered only when the work isn't in the covering pull request. --- dashboard/e2e/stop-rules.spec.ts | 93 ++++++++++++++++++ dashboard/src/app/runs/detail/page.tsx | 129 +++++++++++++++++++------ dashboard/src/lib/api.ts | 41 ++++++++ dashboard/src/lib/openapi-fields.ts | 6 +- 4 files changed, 240 insertions(+), 29 deletions(-) diff --git a/dashboard/e2e/stop-rules.spec.ts b/dashboard/e2e/stop-rules.spec.ts index 9a4b05fa..83bca10c 100644 --- a/dashboard/e2e/stop-rules.spec.ts +++ b/dashboard/e2e/stop-rules.spec.ts @@ -69,6 +69,61 @@ const RUNS: Record = { reason: "It selects the card by its name, which is the ticket's fix.", }, }, + // Coderhelm's own pull request covered the ticket and lacked part of it: + // the run carried its work there; the ticket's earlier pull request is + // superseded. + "01CONT": { + ...BASE, + run_id: "01CONT", + status: "covered_by_pr", + covered_by: { + repo: "your-team/web", + number: 52, + url: "https://github.com/your-team/web/pull/52", + title: "Merge and deploy the cards change", + author: "coderhelm[bot]", + reason: "It implements the scope.", + own: true, + outcome: "continued", + carried: { branch: "coderhelm/abc-13", head: "9f2c1e0", commits: 3, files: ["src/register.ts", "src/helpers/a.ts"], rebuilt: false }, + open_items: ["Register the two extra helper files"], + superseded: { repo: "your-team/web", number: 41, url: "https://github.com/your-team/web/pull/41", title: "Cards list fix", closed: false }, + note: "Continued in #52, Coderhelm's own open pull request that already covered this ticket.", + }, + }, + "01DONE": { + ...BASE, + run_id: "01DONE", + status: "covered_by_pr", + covered_by: { + repo: "your-team/web", + number: 52, + url: "https://github.com/your-team/web/pull/52", + title: "Merge and deploy the cards change", + author: "coderhelm[bot]", + reason: "It implements the scope.", + own: true, + outcome: "complete", + superseded: { repo: "your-team/web", number: 41, url: "https://github.com/your-team/web/pull/41", closed: true, closed_by: "Sam" }, + note: "#52 already has everything this ticket asks for.", + }, + }, + "01PERS": { + ...BASE, + run_id: "01PERS", + status: "covered_by_pr", + covered_by: { + repo: "your-team/web", + number: 60, + url: "https://github.com/your-team/web/pull/60", + title: "Cards fix", + author: "dev-b", + reason: "It fixes the spec.", + own: false, + outcome: "person", + note: "dev-b's pull request #60 covers this ticket.", + }, + }, "01ASKD": { ...BASE, run_id: "01ASKD", @@ -106,6 +161,7 @@ async function mockApi(page: Page, role = "member") { const rest = m[2] ?? ""; if (rest === "") return json(route, RUNS[m[1]]); if (rest === "/retry" && req.method() === "POST") return json(route, { status: "queued" }); + if (rest === "/close-superseded" && req.method() === "POST") return json(route, { closed: true, message: "Closed #41." }); if (rest === "/openspec") return json(route, {}); if (rest === "/traces") return json(route, { traces: [] }); if (rest === "/agent-log") return json(route, { passes: [], live_events: [] }); @@ -187,3 +243,40 @@ test("a covered run can be retried when the ticket needs its own change", async await page.getByTestId("run-outcome").getByRole("button", { name: /Retry/ }).click(); await expect.poll(() => calls).toContain("POST /api/runs/01COVR/retry"); }); + +test("a covered run that continued in Coderhelm's own pull request shows what was carried and offers to close the earlier one", async ({ page }) => { + const calls = await mockApi(page); + await page.goto("/runs/detail?id=01CONT"); + const outcome = page.getByTestId("run-outcome"); + await expect(outcome).toContainText("Continued in #52"); + await expect(page.getByTestId("covered-carried")).toContainText("3 commits onto coderhelm/abc-13"); + await expect(page.getByTestId("covered-open-items")).toContainText("Register the two extra helper files"); + await expect(page.getByTestId("covered-superseded")).toContainText("#41 is superseded by #52"); + await expect(page.getByTestId("covered-by-link")).toHaveAttribute("href", "https://github.com/your-team/web/pull/52"); + // Retry isn't the way on: the work is in #52. + await expect(outcome.getByRole("button", { name: /Retry/ })).toHaveCount(0); + // Closing #41 happens only on a click, after a confirm. + expect(calls).not.toContain("POST /api/runs/01CONT/close-superseded"); + await page.getByTestId("close-superseded").click(); + await page.getByTestId("confirm-dialog").getByRole("button", { name: "Close #41" }).click(); + await expect.poll(() => calls).toContain("POST /api/runs/01CONT/close-superseded"); +}); + +test("a covering pull request that has everything says so, with the earlier one closed", async ({ page }) => { + await mockApi(page); + await page.goto("/runs/detail?id=01DONE"); + await expect(page.getByTestId("run-outcome")).toContainText("#52 already has everything this ticket asks for"); + await expect(page.getByTestId("covered-superseded")).toContainText("#41 is closed by Sam"); + await expect(page.getByTestId("close-superseded")).toHaveCount(0); +}); + +test("a person's covering pull request is linked, never offered to continue in or close", async ({ page }) => { + await mockApi(page); + await page.goto("/runs/detail?id=01PERS"); + const outcome = page.getByTestId("run-outcome"); + await expect(outcome).toContainText("Covered by dev-b's pull request #60"); + await expect(page.getByTestId("covered-by")).toContainText("dev-b's pull request #60 covers this ticket."); + await expect(page.getByTestId("close-superseded")).toHaveCount(0); + await expect(outcome.getByRole("button", { name: /Continue/ })).toHaveCount(0); + await expect(outcome.getByRole("button", { name: /Retry/ })).toBeVisible(); +}); diff --git a/dashboard/src/app/runs/detail/page.tsx b/dashboard/src/app/runs/detail/page.tsx index a6e43067..5a36ed7f 100644 --- a/dashboard/src/app/runs/detail/page.tsx +++ b/dashboard/src/app/runs/detail/page.tsx @@ -332,7 +332,7 @@ function RunDetailInner() { const [loading, setLoading] = useState(true); // "missing" when the gateway says there is no such run, "failed" for anything else. const [loadError, setLoadError] = useState<"missing" | "failed" | null>(null); - const [busy, setBusy] = useState<"retry" | "review" | "reset" | "cancel" | "close" | "reopen" | null>(null); + const [busy, setBusy] = useState<"retry" | "review" | "reset" | "cancel" | "close" | "reopen" | "close-superseded" | null>(null); const [closeOpen, setCloseOpen] = useState(false); const [specTab, setSpecTab] = useState("proposal"); const [usage, setUsage] = useState(null); @@ -601,6 +601,30 @@ function RunDetailInner() { setBusy(null); } }; + // Close the ticket's earlier pull request a covered run superseded: only on + // a person's click (the gateway closes only Coderhelm's own pull request). + const closeSuperseded = async (n: number) => { + const ok = await confirm({ + title: `Close #${n}?`, + message: `#${n} is superseded: this ticket's change is in the pull request the run continued in. Closing it is visible to everyone on the repository; its branch is kept.`, + confirmLabel: `Close #${n}`, + }); + if (ok !== "primary") return; + setBusy("close-superseded"); + try { + const r = await api.closeSupersededPr(runId); + if (!r.ok) { + toast(r.message || actionError(new Error(r.error), `close #${n}`), "error"); + } else { + toast(r.message || `Closed #${n}.`); + } + fetchRun(); + } catch (e) { + toast(actionError(e, `close #${n}`), "error"); + } finally { + setBusy(null); + } + }; const cancel = async () => { setBusy("cancel"); try { @@ -781,34 +805,85 @@ function RunDetailInner() { ); } else if (run.status === "covered_by_pr") { const cb = run.covered_by; - outcome = ( - - {cb?.url && ( - - Open #{cb.number} - + const kind = cb?.outcome ?? ""; + const carried = cb?.carried; + const sup = cb?.superseded; + // The work is in the covering pull request: Retry isn't what's next. + const done = kind === "continued" || kind === "complete"; + const title = !cb + ? "Already being fixed in an open pull request" + : kind === "continued" + ? `Continued in #${cb.number}` + : kind === "complete" + ? `#${cb.number} already has everything this ticket asks for` + : kind === "person" + ? `Covered by ${cb.author || "a person"}'s pull request #${cb.number}` + : `Already being fixed in #${cb.number}`; + { + outcome = ( + + {cb?.url && ( + + Open #{cb.number} + + )} + {canAct && sup && !sup.closed && done && ( + + )} + {!done && retryButton} + + } + > +
+ {cb && ( +

+ {cb.title || `${cb.repo}#${cb.number}`} + {cb.author ? <> by {cb.author} : null} +

)} - {retryButton} - - } - > -
- {cb && ( -

- {cb.title || `${cb.repo}#${cb.number}`} - {cb.author ? <> by {cb.author} : null} + {cb?.reason &&

{cb.reason}

} + {carried && (carried.commits ?? 0) > 0 && ( +

+ Carried over: {carried.commits} commit{carried.commits === 1 ? "" : "s"} onto {carried.branch} + {carried.rebuilt ? " (rebuilt on it)" : ""} + {carried.files?.length ? <>, changing {carried.files.slice(0, 6).map((f, i) => {i > 0 ? ", " : ""}{f})}{carried.files.length > 6 ? ` and ${carried.files.length - 6} more` : ""} : null} + . +

+ )} + {!!cb?.open_items?.length && ( +
+

Still open for this ticket in #{cb.number}

+
    + {cb.open_items.map((i) => ( +
  • {i}
  • + ))} +
+
+ )} + {sup && ( +

+ {sup.url ? #{sup.number} : <>#{sup.number}} + {sup.closed + ? <> is closed{sup.closed_by ? <> by {sup.closed_by} : null}: superseded by #{cb?.number}. + : <> is superseded by #{cb?.number}, which carries this ticket's change. It stays open until someone closes it: Coderhelm doesn't close a pull request by itself.} +

+ )} +

+ {cb?.note + ? cb.note + : "Coderhelm built no second fix and linked this pull request on the ticket. If the ticket needs a separate change, say so on the ticket, then retry."}

- )} - {cb?.reason &&

{cb.reason}

} -

Coderhelm built no second fix and linked this pull request on the ticket. If the ticket needs a separate change, say so on the ticket, then retry.

-
- - ); +
+
+ ); + } } else if (run.status === "failed") { outcome = ( request("/api/runs/close", { method: "POST", body: JSON.stringify({ run_ids: ids, ...body }) }), /** Undo a close: the run shows as before (or waiting on a person); nothing restarts. */ + /** + * Close the ticket's earlier pull request a covered run superseded. Only + * Coderhelm's own pull request is closed (the gateway reads it from GitHub + * first); anything else comes back `ok: false` with the reason. + */ + closeSupersededPr: (id: string) => + requestWithBody<{ closed?: boolean; message?: string }, { message?: string }>( + `/api/runs/${encodeURIComponent(id)}/close-superseded`, + { method: "POST" }, + ), reopenRun: (id: string) => requestWithBody<{ status: string; message?: string }, { status?: string; message?: string }>( `/api/runs/${encodeURIComponent(id)}/reopen`, @@ -2109,6 +2119,37 @@ export interface RunCoveredBy { title?: string; author?: string; reason?: string; + /** It is Coderhelm's own pull request: only then does a run continue in it or offer to close the earlier one. */ + own?: boolean; + /** `continued`, `complete`, `person`, `busy` or `not_carried`; empty on older runs. */ + outcome?: string; + /** What the run put on its branch, when it continued in it. */ + carried?: RunCoveredCarried | null; + /** What is still open for this ticket in it. */ + open_items?: string[]; + /** The ticket's earlier pull request Coderhelm opened, now redundant. */ + superseded?: RunSupersededPr | null; + /** What the run page says, in one paragraph. */ + note?: string; +} + +/** What a covered run carried over to Coderhelm's own covering pull request. */ +export interface RunCoveredCarried { + branch: string; + head?: string; + commits?: number; + files?: string[]; + rebuilt?: boolean; +} + +/** The ticket's earlier pull request, superseded by the covering one. */ +export interface RunSupersededPr { + repo: string; + number: number; + url?: string; + title?: string; + closed?: boolean; + closed_by?: string; } /** An answer given in Coderhelm to a run's question. */ diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 4e39e12f..b62e6e7a 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 = "4af300bd05abf7db9f07f0cfe4e7046098aa0bea"; +export const OPENAPI_REF = "1c295b2fccaa0bc86b3ce72cf2598d1154948ff3"; /** The fields each public API schema has. */ export interface OpenApiFields { @@ -64,11 +64,13 @@ export interface OpenApiFields { Run: "answers" | "answers_url" | "applied_standards" | "branch" | "branches" | "cache_read_tokens" | "cache_write_tokens" | "close_reason" | "closed_at" | "closed_by" | "closed_from" | "codegen_env_missing" | "continued_run_id" | "cost_usd" | "covered_by" | "created_at" | "current_pass" | "duration_s" | "error" | "files_modified" | "fix_location" | "lesson" | "mcp_servers" | "outside_change_report" | "pass_history" | "policy_approval" | "policy_note" | "pr_number" | "pr_numbers" | "pr_url" | "pr_urls" | "progress_notes" | "prs" | "questions" | "questions_url" | "repo" | "round_incomplete" | "run_id" | "sign_in_prompts" | "status" | "stop_kind" | "ticket_id" | "ticket_source" | "title" | "tokens_in" | "tokens_out" | "tooling_failure" | "trigger" | "updated_at"; RunActionResult: "status"; RunAnswer: "answer" | "answered_at" | "author" | "question" | "question_id"; - RunCoveredBy: "author" | "number" | "reason" | "repo" | "title" | "url"; + RunCoveredBy: "author" | "carried" | "note" | "number" | "open_items" | "outcome" | "own" | "reason" | "repo" | "superseded" | "title" | "url"; + RunCoveredCarried: "branch" | "commits" | "files" | "head" | "rebuilt"; RunNote: "message" | "timestamp"; RunPass: "pass" | "started_at"; RunQuestion: "decision" | "evidence" | "id" | "question" | "suggestions" | "why"; RunSummary: "cost_usd" | "created_at" | "current_pass" | "duration_s" | "pr_number" | "pr_url" | "repo" | "run_id" | "status" | "ticket_id" | "ticket_source" | "title" | "tokens_in" | "tokens_out" | "trigger"; + RunSupersededPr: "closed" | "closed_by" | "number" | "repo" | "title" | "url"; RunToolingFailure: "command" | "error" | "tried"; RunTrigger: "by" | "kind" | "label" | "ref" | "ref_url"; RunsPage: "next" | "runs" | "scanned";