From 70b7495c8d6b512b0e881181a54fcd4181c8a82e Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Wed, 11 Nov 2026 14:45:11 -0500 Subject: [PATCH] Analytics: failures show their step and retries, and runs waiting on a person The Reliability tab's failures table gets a Step column (where most of the group failed) and a Retried column (how many a person retried), and a row summing the reasons past the ones listed instead of dropping them. Recently failed names the step and says when a person retried the run. A new "Waiting on a person" table groups runs that stopped for someone by what they wait for, and calls out waits that name nothing with what to do. The overview's Failed runs tile says how many failures were retried. --- dashboard/e2e/analytics.spec.ts | 34 ++++++++++++-- dashboard/src/app/analytics/page.tsx | 67 ++++++++++++++++++++++------ dashboard/src/lib/api.ts | 16 ++++++- 3 files changed, 97 insertions(+), 20 deletions(-) diff --git a/dashboard/e2e/analytics.spec.ts b/dashboard/e2e/analytics.spec.ts index b3065560..5f301347 100644 --- a/dashboard/e2e/analytics.spec.ts +++ b/dashboard/e2e/analytics.spec.ts @@ -17,7 +17,7 @@ function days(n: number) { } const SUMMARY = { - runs: 42, prs_opened: 30, prs_merged: 21, prs_closed: 3, prs_open: 6, merge_rate: 0.7, failed_runs: 4, failure_rate: 0.095, + runs: 42, prs_opened: 30, prs_merged: 21, prs_closed: 3, prs_open: 6, merge_rate: 0.7, failed_runs: 4, failure_rate: 0.095, failed_then_retried: 2, cost_usd: 96.4, run_cost_usd: 41.2, cost_basis: "metered", cost_by_feature: [{ feature: "review", cost_usd: 50 }, { feature: "run", cost_usd: 41.2 }, { feature: "feedback", cost_usd: 5.2 }], cost_per_run: 2.3, cost_per_merged_pr: 4.59, tokens_in: 12_000_000, tokens_out: 900_000, median_run_minutes: 11.5, median_hours_to_merge: 5.2, time_to_merge_known: 12, merged_untouched: 9, merged_with_edits: 3, edits_known: 12, reviews: 55, @@ -108,9 +108,17 @@ function analytics(period: string, repo: string | null, deployState: DeployState { person: "Coderhelm (E2E tests)", kind: "coderhelm", runs: 4, merged: 2 }, ], failures: [ - { reason: "Timed out after #s", count: 3, last_run_id: "01RUNFAILED00000000000000A", last_at: new Date().toISOString() }, - { reason: "Branch … already exists", count: 1, last_run_id: "01RUNFAILED00000000000000B", last_at: new Date().toISOString() }, + { reason: "Timed out after #s", count: 3, last_run_id: "01RUNFAILED00000000000000A", last_at: new Date().toISOString(), stage: "implement", retried: 2 }, + { reason: "Branch … already exists", count: 1, last_run_id: "01RUNFAILED00000000000000B", last_at: new Date().toISOString(), stage: "pr", retried: 0 }, ], + failures_more: { reasons: 2, runs: 3 }, + waiting: { + total: 4, + reasons: [ + { reason: "Review pull request", count: 3, last_run_id: "01RUNWAITING000000000000A", last_at: new Date().toISOString() }, + { reason: "Nothing recorded", count: 1, last_run_id: "01RUNWAITING000000000000B", last_at: new Date().toISOString() }, + ], + }, ci: { runs_with_red_ci: 8, fixed_by_coderhelm: 6, fix_rate: 0.75, fix_attempts: 11, fix_commits: 9, red_on_base_runs: 1, outcomes: { green_after_fix: 6, green_without_fix: 0, flaky: 1, red_on_base: 1, gave_up: 1, running: 0 }, @@ -135,7 +143,7 @@ function analytics(period: string, repo: string | null, deployState: DeployState { run_id: "01RUNMERGED00000000000000B", title: "Retry the sync job once", repo: "your-team/backend", pr_number: 55, pr_url: "https://github.com/your-team/backend/pull/55", hours_to_merge: null, human_commits: null }, ], failed_recent: [ - { run_id: "01RUNFAILED00000000000000A", title: "Update the pricing page", repo: "your-team/web", reason: "Timed out after #s", at: new Date().toISOString() }, + { run_id: "01RUNFAILED00000000000000A", title: "Update the pricing page", repo: "your-team/web", reason: "Timed out after #s", at: new Date().toISOString(), stage: "implement", retried: true }, ], repo_names: ["your-team/backend", "your-team/web"], }; @@ -272,6 +280,24 @@ test("stops and blocks show the unnecessary and the nuisance ones, with examples await shot(page, "analytics-decisions"); }); +test("failures show their step and retries, the rest summed, and what waiting runs wait for", async ({ page }) => { + await mockApi(page); + await page.goto("/analytics?tab=reliability"); + const failures = page.getByRole("table", { name: "Failures by reason" }); + await expect(failures.locator("tbody tr td:first-child")).toHaveText(["Timed out after #s", "Branch … already exists", "2 other reasons"]); + await expect(failures.locator("tbody tr").first()).toContainText("Writing code"); + await expect(failures.locator("tbody tr").nth(1)).toContainText("Opening the PR"); + const waiting = page.getByRole("table", { name: "Runs waiting on a person" }); + await expect(page.getByTestId("waiting")).toContainText("Waiting on a person (4)"); + await expect(waiting.locator("tbody tr td:first-child")).toHaveText(["Review pull request", "Nothing recorded: open the run, then retry or close it"]); + await expect(waiting.getByRole("link", { name: "Open run" }).first()).toHaveAttribute("href", /id=01RUNWAITING000000000000A$/); + await expect(page.getByRole("table", { name: "Recently failed" })).toContainText("retried by a person"); + await page.getByRole("table", { name: "Failures by reason" }).scrollIntoViewIfNeeded(); + await shot(page, "analytics-failures"); + await page.goto("/analytics"); + await expect(page.getByTestId("tile-failed")).toContainText("2 retried by a person"); +}); + test("where it struggles places every red CI run in one outcome, base-branch failures apart", async ({ page }) => { await mockApi(page); await page.goto("/analytics?tab=reliability"); diff --git a/dashboard/src/app/analytics/page.tsx b/dashboard/src/app/analytics/page.tsx index d3d7b407..232c8806 100644 --- a/dashboard/src/app/analytics/page.tsx +++ b/dashboard/src/app/analytics/page.tsx @@ -74,7 +74,7 @@ function actorLabel(a: string) { return ({ reviewer: "Reviewer", planner: "Planner", coder: "Coding agent", people: "People in the dashboard" } as Record)[a] ?? a; } function stepLabel(s: string) { - return ({ triage: "Triage", plan: "Planning", implement: "Writing code", ci_fix: "Fixing CI", review: "Self-review", feedback: "Answering feedback", pr: "Opening the PR", security: "Security check" } as Record)[s] ?? s.replace(/_/g, " "); + return ({ triage: "Triage", plan: "Planning", implement: "Writing code", test: "Testing", ci_fix: "Fixing CI", review: "Self-review", feedback: "Answering feedback", pr: "Opening the PR", security: "Security check" } as Record)[s] ?? s.replace(/_/g, " "); } function sourceLabel(s: string) { return ({ github: "GitHub issues", jira: "Jira", alert: "Alerts", other: "Other" } as Record)[s] ?? s; @@ -261,7 +261,7 @@ function Body({ data, loading, stats, tab }: { data: Analytics; loading: boolean - + @@ -320,17 +320,8 @@ function Body({ data, loading, stats, tab }: { data: Analytics; loading: boolean {tab === "reliability" && ( <> -
- [ - f.reason, - f.count, - Open run, - ])} - empty={`No failed runs in ${span}.`} - /> +
+ {(data.ci.runs_with_red_ci > 0 || (data.ci.red_on_base_runs ?? 0) > 0) && (

CI went red on {plural(data.ci.runs_with_red_ci, "run")} @@ -340,6 +331,7 @@ function Body({ data, loading, stats, tab }: { data: Analytics; loading: boolean )} {data.ci.outcomes && } {!!data.loops_stopped?.total && } + {!!data.waiting?.total && }

@@ -370,7 +362,11 @@ function Body({ data, loading, stats, tab }: { data: Analytics; loading: boolean rows={data.failed_recent.map((r) => [ {r.title || `Run ${r.run_id}`} - {r.repo} + + {r.repo} + {r.stage && <>{" · "}{stepLabel(r.stage)}} + {r.retried && <>{" · "}retried by a person} + , {r.reason}, ])} @@ -728,6 +724,49 @@ function CiOutcomes({ ci, outcomes }: { ci: Analytics["ci"]; outcomes: Analytics ); } +/** Failed runs by reason, with the step they failed in and how many a person retried. */ +function FailureTable({ data, span }: { data: Analytics; span: string }) { + const more = data.failures_more; + const rows: ReactNode[][] = data.failures.map((f) => [ + {f.reason}, + f.stage ? stepLabel(f.stage) : "—", + f.count, + f.retried == null ? "—" : f.retried, + Open run, + ]); + if (more && more.reasons > 0) { + rows.push([ + {`${plural(more.reasons, "other reason")}`}, + "—", + more.runs, + "—", + "", + ]); + } + return
; +} + +/** Runs that stopped for a person and still wait: what each waits for. */ +function Waiting({ waiting }: { waiting: NonNullable }) { + const rows: ReactNode[][] = waiting.reasons.map((r) => [ + r.reason === "Nothing recorded" ? ( + + Nothing recorded: open the run, then retry or close it + + ) : ( + r.reason + ), + r.count, + Open run, + ]); + return ( +
+

Waiting on a person ({count(waiting.total)})

+
+ + ); +} + /** Runs Coderhelm stopped for making no progress, handing them to a person. */ function LoopsStopped({ stopped }: { stopped: NonNullable }) { const rows: ReactNode[][] = stopped.reasons.map((r) => [r.reason, r.count]); diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index acc69a8e..67718dd8 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -3693,8 +3693,11 @@ export interface AnalyticsSummary { prs_open: number; /** Merged out of opened, 0-1; null with no PRs. */ merge_rate: number | null; + /** Failed runs, those a person then retried or started over included. */ failed_runs: number; failure_rate: number | null; + /** Of the failed runs, those a person retried. Older backends leave it out. */ + failed_then_retried?: number; /** Runs a person closed on purpose: not failures. Older backends leave it out. */ closed_runs?: number; /** @@ -3744,7 +3747,16 @@ export interface Analytics { repos: { repo: string; runs: number; prs: number; merged: number; failed: number; cost_usd: number; tokens?: number; merge_rate: number | null; reviews: number }[]; /** One row per person (however Jira, GitHub or the dashboard named them), Coderhelm's own work, and runs that recorded nobody. */ people: { person: string; kind?: "person" | "coderhelm" | "not_recorded"; runs: number; merged: number }[]; - failures: { reason: string; count: number; last_run_id: string; last_at: string }[]; + /** + * Failed runs by reason, most first. `stage` is the step most of the group + * failed in and `retried` how many a person retried (older backends leave + * both out). + */ + failures: { reason: string; count: number; last_run_id: string; last_at: string; stage?: string; retried?: number }[]; + /** Reasons past the ones listed, summed. Missing from older backends. */ + failures_more?: { reasons: number; runs: number }; + /** Runs that stopped for a person and still wait, by what for. Missing from older backends. */ + waiting?: { total: number; reasons: { reason: string; count: number; last_run_id: string; last_at: string }[] }; ci: { /** Runs whose own CI went red (runs red only on base-branch checks are counted apart). */ runs_with_red_ci: number; @@ -3775,7 +3787,7 @@ export interface Analytics { steps: { step: string; count: number; tokens_in: number; tokens_out: number; avg_seconds: number }[]; steps_window_days: number; merged_recent: { run_id: string; title: string; repo: string; pr_number: number; pr_url: string; hours_to_merge: number | null; human_commits: number | null }[]; - failed_recent: { run_id: string; title: string; repo: string; reason: string; at: string }[]; + failed_recent: { run_id: string; title: string; repo: string; reason: string; at: string; stage?: string; retried?: boolean }[]; repo_names: string[]; /** Absent from servers older than the comparison. */ comparison?: AnalyticsComparison;