From c490e2aefbd369eacdcd54cc9797018b3c17b766 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Fri, 6 Nov 2026 20:13:37 -0500 Subject: [PATCH 1/2] Learning page shows whether each learning loop still learns; a held draft and a GitHub wait show on the run page The Learning page opens with one card per learning loop (GET /api/learning/health): what it learns from, when it last learned, its count this week against what should have fed it, and for a loop that went quiet, a red state with what to check. A finished run whose pull request stays a draft (draft_hold) reads "Finished, PR held" in its status and at the top of the run page, with the summary and each reason with what to do. A working run waiting out GitHub's hourly limit (github_wait) says when it goes on and that nothing is needed. The API field list is regenerated at the platform commit that adds draft_hold. --- dashboard/e2e/learning.spec.ts | 86 ++++++++++- dashboard/e2e/run-draft-hold.spec.ts | 181 ++++++++++++++++++++++++ dashboard/e2e/wide-data/learning.ts | 28 ++++ dashboard/e2e/wide-data/runs.ts | 13 ++ dashboard/src/app/learning/health.tsx | 170 ++++++++++++++++++++++ dashboard/src/app/learning/page.tsx | 5 +- dashboard/src/app/runs/detail/page.tsx | 53 ++++++- dashboard/src/components/run-status.tsx | 18 ++- dashboard/src/lib/api-contract.ts | 5 +- dashboard/src/lib/api.ts | 56 ++++++++ dashboard/src/lib/openapi-fields.ts | 10 +- 11 files changed, 615 insertions(+), 10 deletions(-) create mode 100644 dashboard/e2e/run-draft-hold.spec.ts create mode 100644 dashboard/src/app/learning/health.tsx diff --git a/dashboard/e2e/learning.spec.ts b/dashboard/e2e/learning.spec.ts index 50b9a4a5..ad764550 100644 --- a/dashboard/e2e/learning.spec.ts +++ b/dashboard/e2e/learning.spec.ts @@ -1,7 +1,7 @@ import { expect, test, type Page, type Route } from "@playwright/test"; import fs from "node:fs"; import path from "node:path"; -import { learningFixture } from "./wide-data/learning"; +import { learningFixture, learningHealthFixture } from "./wide-data/learning"; import { pickOption } from "./select"; // The Learning page: what Coderhelm learned from outcomes, the behavior it @@ -22,6 +22,8 @@ interface Backend { pinned: string; weights: Record; calls: { method: string; path: string; body: unknown }[]; + /** The health check's answer, or its error status; left out, a gateway without it (404). */ + health?: unknown; } async function mockApi(page: Page, init: Partial = {}): Promise { @@ -44,6 +46,12 @@ async function mockApi(page: Page, init: Partial = {}): Promise { + await mockApi(page, { health: learningHealthFixture({ repo: REPO, text: "", quiet: ["pr_outcomes"], idle: ["coder_lessons", "stop_outcomes"] }) }); + await page.goto("/learning"); + const health = page.getByTestId("learning-health"); + await expect(health).toHaveAttribute("data-state", "red"); + await expect(health.getByText("1 loop stopped learning")).toBeVisible(); + + // The red loop comes first, in plain words: what it learns from, when it last learned, what to check. + const red = page.getByTestId("loop-pr_outcomes"); + await expect(health.locator("li[data-state]").first()).toHaveAttribute("data-testid", "loop-pr_outcomes"); + await expect(red).toHaveAttribute("data-state", "quiet"); + await expect(red).toContainText("Not learning"); + await expect(red).toContainText("Learns from: Whether Coderhelm's pull requests were merged as written"); + await expect(red).toContainText(/Last learned: .*ago/); + await expect(red).toContainText("3 of 5 this week"); + await expect(red).toContainText(`2 closed pull request(s) were never scored: ${REPO}#12345`); + await expect(page.getByTestId("loop-pr_outcomes-check")).toContainText("What to check: Pull requests closed this week were never scored."); + + // An idle loop had nothing to learn from: no red, never learned. + const idle = page.getByTestId("loop-coder_lessons"); + await expect(idle).toHaveAttribute("data-state", "idle"); + await expect(idle).toContainText("Nothing to learn from yet"); + await expect(idle).toContainText("Last learned: never"); + await expect(idle).toContainText("Learns from: Repeated setbacks in one area of the code"); + await expect(page.getByTestId("loop-coder_lessons-check")).toHaveCount(0); + + // A working loop with no expected count shows its count alone. + const ok = page.getByTestId("loop-calibration"); + await expect(ok).toContainText("Learning"); + await expect(ok).toContainText("4 this week"); + await expect(health.locator("li[data-state]")).toHaveCount(9); + await noSideways(page); + fs.mkdirSync(SHOTS_DIR, { recursive: true }); + await page.locator("#health").screenshot({ path: path.join(SHOTS_DIR, "learning-health-desktop.png") }); +}); + +test("every loop learning reads as fine, with no red", async ({ page }) => { + await mockApi(page, { health: learningHealthFixture({ repo: REPO, text: "", quiet: [], idle: ["stop_outcomes"] }) }); + await page.goto("/learning"); + const health = page.getByTestId("learning-health"); + await expect(health).toHaveAttribute("data-state", "ok"); + await expect(health).toContainText("Every loop that had something to learn from learned from it."); + await expect(health.getByText(/stopped learning/)).toHaveCount(0); + await expect(page.getByTestId("loop-stop_outcomes")).toContainText("Nothing to learn from yet"); + await expect(health.getByText("What to check:")).toHaveCount(0); +}); + +test("a health check that fails says so and retries, and the rest of the page still loads", async ({ page }) => { + const db = await mockApi(page, { health: 500 }); + await page.goto("/learning"); + await expect(page.getByText("Couldn't check the learning loops")).toBeVisible(); + await expect(page.getByTestId("tile-events")).toBeVisible(); + db.health = learningHealthFixture({ repo: REPO, text: "" }); + await page.getByRole("button", { name: "Try again" }).click(); + await expect(page.getByTestId("learning-health")).toHaveAttribute("data-state", "red"); +}); + +test("a gateway without the health check shows no health section", async ({ page }) => { + await mockApi(page); + await page.goto("/learning"); + await expect(page.getByTestId("tile-events")).toBeVisible(); + await expect(page.getByRole("heading", { name: "Is it still learning?" })).toHaveCount(0); +}); + +test("the health check fits a phone at 375 wide", async ({ page }) => { + await page.setViewportSize({ width: 375, height: 844 }); + await mockApi(page, { health: learningHealthFixture({ repo: "your-team/payments-reconciliation-ledger-service", text: "packages/payments-reconciliation-ledger/src/adapters/stripe/webhooks/handlers/charge-refunded-partially.ts" }) }); + await page.goto("/learning"); + await expect(page.getByTestId("loop-pr_outcomes-check")).toBeVisible(); + await noSideways(page); + fs.mkdirSync(SHOTS_DIR, { recursive: true }); + await page.locator("#health").screenshot({ path: path.join(SHOTS_DIR, "learning-health-phone.png") }); +}); diff --git a/dashboard/e2e/run-draft-hold.spec.ts b/dashboard/e2e/run-draft-hold.spec.ts new file mode 100644 index 00000000..52f87251 --- /dev/null +++ b/dashboard/e2e/run-draft-hold.spec.ts @@ -0,0 +1,181 @@ +import { expect, test, type Page, type Route } from "@playwright/test"; +import fs from "node:fs"; +import path from "node:path"; + +// A run that finished with its pull request still a draft (`draft_hold`) says +// "Finished, PR held" at the top, with the summary and each reason with what +// to do. A run waiting out GitHub's hourly limit (`github_wait`) says when it +// goes on, and that nothing is needed. Every API call is answered here. + +const SHOTS_DIR = process.env.E2E_SHOTS_DIR || path.join("test-results", "shots"); + +const now = Date.now(); +const iso = (minsAgo: number) => new Date(now - minsAgo * 60_000).toISOString(); + +type Run = Record & { run_id: string; status: string }; + +const SECURITY = { + what: "Security items are open under Open items", + todo: "Fix them on this branch (Coderhelm checks again on the next push), or delete each security line once a person has checked it.", +}; +const SANDBOX = { + what: "The sandbox could not run the end-to-end tests", + todo: "Add the missing BASE_URL to the repository's test settings, then push to the branch.", +}; + +function run(over: Partial = {}): Run { + return { + run_id: "01RUNHOLD", + status: "needs_input", + ticket_source: "jira", + ticket_id: "ABC-9", + title: "Add rate limits to the sign-up form", + repo: "your-team/web", + pr_url: "https://github.com/your-team/web/pull/318", + pr_number: 318, + current_pass: "review", + tokens_in: 1200, + tokens_out: 300, + duration_s: 900, + created_at: iso(60), + updated_at: iso(5), + pass_history: [ + { pass: "triage", started_at: iso(60) }, + { pass: "implement", started_at: iso(50) }, + { pass: "pr", started_at: iso(20) }, + { pass: "review", started_at: iso(10) }, + ], + progress_notes: [], + waiting_on: { action: "Review pull request #318", detail: "It stays a draft until the items below are dealt with.", url: "https://github.com/your-team/web/pull/318", since: iso(5) }, + draft_hold: { + kind: "held", + summary: `Finished, but pull request #318 stays a draft: ${SECURITY.what}. ${SECURITY.todo}`, + reasons: [SECURITY, SANDBOX], + pr_number: 318, + since: iso(5), + }, + ...over, + }; +} + +async function mockApi(page: Page, r: Run) { + const json = (route: Route, body: unknown, status = 200) => + route.fulfill({ status, contentType: "application/json", body: JSON.stringify(body) }); + await page.route((url) => url.hostname !== "localhost", (route) => route.abort()); + await page.route((url) => url.hostname === "localhost" && /^\/(api|auth)\//.test(url.pathname), async (route) => { + const url = new URL(route.request().url()); + const p = url.pathname; + if (p === "/api/me") return json(route, { user_id: "u_1", team_id: "t_1", github_login: "pat", email: "pat@example.com", avatar_url: "", role: "member" }); + if (p === "/api/usage") return json(route, { month: "2026-11", total_tokens: 0, tokens_in: 0, tokens_out: 0, total_runs: 0, max_tokens: 0 }); + if (p === "/api/banners") return json(route, { banners: [] }); + if (p === "/api/teams") return json(route, { teams: [{ team_id: "t_1", org: "your-team", status: "active", current: true }] }); + if (p === "/api/repos") return json(route, { repos: [{ name: "your-team/web", enabled: true, ticket_source: "jira" }] }); + if (p === "/api/plugins/catalog") return json(route, { plugins: [] }); + const m = p.match(/^\/api\/runs\/([^/]+)(?:\/(.+))?$/); + if (m) { + if (decodeURIComponent(m[1]) !== r.run_id) return json(route, { error: "No run with this id in the team.", code: "not_found" }, 404); + const action = m[2]; + if (!action) return json(route, r); + if (action === "openspec") return json(route, {}); + if (action === "traces") return json(route, { traces: [] }); + if (action === "agent-log") return json(route, { passes: [], live_events: [] }); + if (action === "asks") return json(route, { asks: [] }); + } + return json(route, { error: `Not mocked: ${p}` }, 404); + }); +} + +async function noSideways(page: Page) { + const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); + expect(overflow, "the page scrolls sideways").toBeLessThanOrEqual(0); +} + +async function shot(page: Page, name: string) { + fs.mkdirSync(SHOTS_DIR, { recursive: true }); + await page.screenshot({ path: path.join(SHOTS_DIR, `${name}.png`), fullPage: true }); +} + +test("a held run reads Finished, PR held, with each reason and what to do", async ({ page }) => { + await mockApi(page, run()); + await page.goto("/runs/detail?id=01RUNHOLD"); + + const outcome = page.getByTestId("run-outcome"); + await expect(outcome).toBeVisible(); + await expect(outcome).toHaveAttribute("data-tone", "waiting"); + await expect(outcome.getByText("Finished, PR held", { exact: true })).toBeVisible(); + // The status beside the title says the same, not "Needs your answer". + await expect(page.getByText("Finished, PR held", { exact: true })).toHaveCount(2); + await expect(page.getByText("Needs your answer")).toHaveCount(0); + + await expect(page.getByTestId("draft-hold-summary")).toHaveText(/pull request #318 stays a draft: Security items are open/); + const reasons = page.getByTestId("draft-hold-reasons"); + await expect(reasons.getByRole("listitem").filter({ hasText: SECURITY.what })).toContainText(`What to do: ${SECURITY.todo}`); + await expect(reasons.getByRole("listitem").filter({ hasText: SANDBOX.what })).toContainText(`What to do: ${SANDBOX.todo}`); + await expect(reasons).toContainText("Held since"); + await expect(outcome.getByRole("link", { name: /Open pull request #318/ })).toHaveAttribute("href", "https://github.com/your-team/web/pull/318"); + // The named wait under it is the same pull request; the hold says it once. + await expect(page.getByText("Review pull request #318")).toHaveCount(0); + await shot(page, "run-draft-hold"); +}); + +test("a pull request GitHub refused to mark ready reads as needing attention", 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 }, + })); + await page.goto("/runs/detail?id=01RUNHOLD"); + const outcome = page.getByTestId("run-outcome"); + await expect(outcome).toHaveAttribute("data-tone", "attention"); + await expect(outcome).toContainText("Finished, PR held: GitHub refused to mark it ready"); + await expect(outcome).toContainText("What to do: Mark it ready on GitHub"); + await expect(outcome).not.toContainText("Held since"); + // Not "Done. The change is ready for review." + await expect(page.getByText("Done. The change is ready for review.")).toHaveCount(0); +}); + +test("a run with no hold still reads as before", async ({ page }) => { + await mockApi(page, run({ status: "completed", waiting_on: null, draft_hold: null })); + await page.goto("/runs/detail?id=01RUNHOLD"); + await expect(page.getByTestId("run-outcome")).toContainText("Done. The change is ready for review."); + await expect(page.getByText("Finished, PR held")).toHaveCount(0); +}); + +test("a run waiting for GitHub's hourly limit says when it goes on", async ({ page }) => { + await mockApi(page, run({ + status: "running", + current_pass: "implement", + waiting_on: null, + draft_hold: null, + github_wait: "Waiting for GitHub's hourly limit to reset at 21:05 UTC; continues by itself", + })); + await page.goto("/runs/detail?id=01RUNHOLD"); + const outcome = page.getByTestId("run-outcome"); + await expect(outcome).toHaveAttribute("data-tone", "waiting"); + await expect(outcome).toContainText("Waiting for GitHub"); + await expect(page.getByTestId("github-wait")).toHaveText("Waiting for GitHub's hourly limit to reset at 21:05 UTC; continues by itself. Nothing is needed from you."); + await expect(page.getByText("Coderhelm is working on this")).toHaveCount(0); +}); + +test("a finished run ignores a stale GitHub wait", async ({ page }) => { + await mockApi(page, run({ status: "completed", waiting_on: null, draft_hold: null, github_wait: "Waiting for GitHub's hourly limit to reset at 21:05 UTC; continues by itself" })); + await page.goto("/runs/detail?id=01RUNHOLD"); + await expect(page.getByTestId("run-outcome")).toContainText("Done. The change is ready for review."); + await expect(page.getByTestId("github-wait")).toHaveCount(0); +}); + +test("the hold and the GitHub wait fit a phone at 375 wide", async ({ page }) => { + await page.setViewportSize({ width: 375, height: 844 }); + const long = "packages/payments-reconciliation-ledger/src/adapters/stripe/webhooks/handlers/charge-refunded-partially.ts"; + await mockApi(page, run({ draft_hold: { kind: "held", summary: `Finished, but pull request #318 stays a draft: ${long}`, reasons: [{ what: long, todo: `Fix ${long} on branch coderhelm/abc-9-add-rate-limits-to-the-sign-up-form-and-the-password-reset-form` }], pr_number: 318, since: iso(5) } })); + await page.goto("/runs/detail?id=01RUNHOLD"); + await expect(page.getByTestId("draft-hold-reasons")).toBeVisible(); + await noSideways(page); + await shot(page, "run-draft-hold-phone"); + + await page.unrouteAll({ behavior: "ignoreErrors" }); + await mockApi(page, run({ run_id: "01RUNWAIT", status: "running", waiting_on: null, draft_hold: null, github_wait: `Waiting for GitHub's hourly limit to reset at 21:05 UTC; continues by itself ${long}` })); + await page.goto("/runs/detail?id=01RUNWAIT"); + await expect(page.getByTestId("github-wait")).toBeVisible(); + await noSideways(page); +}); diff --git a/dashboard/e2e/wide-data/learning.ts b/dashboard/e2e/wide-data/learning.ts index 8680581a..6d279c5a 100644 --- a/dashboard/e2e/wide-data/learning.ts +++ b/dashboard/e2e/wide-data/learning.ts @@ -169,7 +169,35 @@ export function exemplarsFixture(o: Pick { + const state = quiet.has(key) ? "quiet" : idle.has(key) ? "idle" : "ok"; + return { key, label, state, last_signal_at: state === "idle" ? "" : iso(state === "quiet" ? 9 * DAY : 90), count: state === "idle" ? 0 : count, expected: state === "idle" && expected !== null ? 0 : expected, detail }; + }; + const loops = [ + loop("pr_outcomes", "Outcomes of CoderHelm's pull requests", 3, 5, quiet.has("pr_outcomes") ? `2 closed pull request(s) were never scored: ${o.repo}#12345, ${o.repo}#67890 ${o.text}` : "5 of 5 pull requests that closed were scored"), + loop("review_outcomes", "Outcomes of review comments", 14, 6, "9 acted on, 3 dismissed, 2 left open, from 6 review(s)"), + loop("calibration", "Reviewer calibration", 4, null, "4 category counter(s) updated; changes: 1 raised, 0 downgraded, 0 suppressed, 0 back to none"), + loop("reviewer_variants", "Reviewer prompt variants", 6, 6, "3 arm(s), 41 pull(s) in all; 6 outcome(s) credited to a variant this window"), + loop("coder_variants", "Coder prompt variants", 2, 5, "2 arm(s), 9 pull(s) in all; 2 outcome(s) credited to a variant this window"), + loop("examples", "Good and avoid examples in prompts", 5, null, "5 of 12 example(s) used this window"), + loop("coder_lessons", "Coder lessons from outcomes", 0, 0, "0 setback(s) in 0 area(s); 0 area(s) with enough evidence for a lesson; 0 lesson(s) written or reinforced"), + loop("review_lessons", "Reviewer lessons from people's pushback", 2, 2, "2 pull request(s) with pushback, 2 judged, 1 lesson(s) learned, 0 stuck"), + loop("stop_outcomes", "What people did after asks, stops and blocks", 0, 0, "0 ask(s), stop(s) and block(s); 0 with a person's act recorded, 0 shown wrong (the judge is given those)"), + ]; + const q = loops.filter((l) => l.state === "quiet").map((l) => l.key); + return { window_days: 7, generated_at: iso(0), state: q.length ? "red" : "ok", quiet: q, loops }; +} + export const learningData: Handler = ({ method, path }) => { + if (path === "/api/learning/health" && method === "GET") return learningHealthFixture({ repo: REPO, text: `${SENTENCE} ${TOKEN}` }); if (path === "/api/learning" && method === "GET") { return learningFixture({ repo: REPO, repo2: REPO_2, text: `${TITLE} ${SENTENCE} ${TOKEN}`, file: FILE, canManage: true }); } diff --git a/dashboard/e2e/wide-data/runs.ts b/dashboard/e2e/wide-data/runs.ts index bbfa44d3..852fb32f 100644 --- a/dashboard/e2e/wide-data/runs.ts +++ b/dashboard/e2e/wide-data/runs.ts @@ -55,6 +55,19 @@ const RUN = { { message: `Ran npm test -- --run ${FILE_2} and every test passed after the change`, timestamp: iso(17) }, { message: TOKEN, timestamp: iso(16) }, ], + // Finished with its pull request still a draft: the summary and each reason with what to do. + draft_hold: { + kind: "held", + summary: `Finished, but pull request #12345 stays a draft: ${TOKEN} is open under Open items. ${SENTENCE}`, + reasons: [ + { what: `Security items are open under Open items: ${FILE}`, todo: `Fix them on branch ${BRANCH} (Coderhelm checks again on the next push), or delete each security line once a person has checked it. ${LONG_URL}` }, + { what: TOKEN, todo: SENTENCE }, + ], + pr_number: 12345, + since: iso(10), + }, + // Shown only while the run works; here for the field's sake. + github_wait: `Waiting for GitHub's hourly limit to reset at 21:05 UTC; continues by itself ${TOKEN}`, fix_location: "both", outside_change_report: MARKDOWN, lesson: `${SENTENCE} ${LONG_URL}`, diff --git a/dashboard/src/app/learning/health.tsx b/dashboard/src/app/learning/health.tsx new file mode 100644 index 00000000..008acfe9 --- /dev/null +++ b/dashboard/src/app/learning/health.tsx @@ -0,0 +1,170 @@ +"use client"; + +import { useCallback, useEffect, useState } from "react"; +import { api, errorStatus, type LearningHealth as Health, type LearningLoop } from "@/lib/api"; +import { Callout } from "@/components/callout"; +import { ListSkeleton, Time } from "@/components/list"; +import { StatusPill } from "@/components/status-pill"; +import { cardClass, Section } from "@/components/page"; +import { smallSecondaryButton } from "@/components/ui"; + +// "Is Coderhelm still learning?": one card per learning loop (GET +// /api/learning/health), saying what it learns from, when it last learned, +// how much it learned this week against what should have fed it, and, for a +// loop that went quiet, what to check. The week is fixed by the gateway, so +// the page's period and repository filters don't apply here. + +/** What each loop learns from, and what to check when it goes quiet. Unknown keys show the gateway's own detail. */ +const LOOPS: Record = { + pr_outcomes: { + from: "Whether Coderhelm's pull requests were merged as written, merged after people's edits, or closed.", + check: "Pull requests closed this week were never scored. Check that the GitHub App still gets pull request events (Settings, Integrations, GitHub), then look in the gateway's log for the pull requests named above.", + }, + review_outcomes: { + from: "Whether people acted on the reviewer's comments, dismissed them, or left them open.", + check: "Reviews ran this week but none of their comments was scored. Check that the GitHub App still gets review comment and pull request events.", + }, + calibration: { + from: "How often each kind of review comment is acted on, per repository, which tunes what the reviewer raises.", + check: "Comments were scored but no category moved. Look in the gateway's log for the learning step that follows a scored comment.", + }, + reviewer_variants: { + from: "Which way of reviewing gets the better outcomes.", + check: "Reviews ran but no variant was picked or credited this week. Look in the reviewer's log for the variant it chose.", + }, + coder_variants: { + from: "Which way of writing code gets its pull requests merged.", + check: "Pull requests closed but no coding variant was picked or credited this week. Look in the worker's log for the variant each run chose.", + }, + examples: { + from: "Past comments and changes that landed well or badly, put in the agents' prompts as examples to follow or to avoid.", + check: "Reviews ran but no example was used in a prompt this week. Check that the repositories reviewed have examples under Examples in use.", + }, + coder_lessons: { + from: "Repeated setbacks in one area of the code: closed pull requests, reverts, checks that failed.", + check: "Some areas had enough setbacks for a lesson, but none was written or reinforced. Look in the worker's log for the lessons step.", + }, + review_lessons: { + from: "People pushing back on the reviewer's comments.", + check: "Pull requests with pushback have waited more than 2 hours to be judged. Look in the worker's log for the review lessons step.", + }, + stop_outcomes: { + from: "What people did after Coderhelm asked a question, stopped, or blocked a merge.", + check: "Asks, stops and blocks from this week have no recorded follow up. Check that pull request and ticket events still arrive.", + }, +}; + +const STATE: Record = { + ok: { label: "Learning", tone: "success" }, + idle: { label: "Nothing to learn from yet", tone: "neutral" }, + quiet: { label: "Not learning", tone: "error" }, +}; +const stateOf = (s: string) => STATE[s] ?? { label: s, tone: "neutral" as const }; + +function amount(l: LearningLoop, days: number): string { + const period = days === 7 ? "this week" : `in ${days} days`; + if (l.expected == null) return `${l.count.toLocaleString()} ${period}`; + return `${l.count.toLocaleString()} of ${l.expected.toLocaleString()} ${period}`; +} + +function LoopCard({ l, days }: { l: LearningLoop; days: number }) { + const known = LOOPS[l.key]; + const state = stateOf(l.state); + const quiet = l.state === "quiet"; + return ( +
  • +
    +

    {l.label}

    + {state.label} +
    + {known && ( +

    + Learns from: + {known.from} +

    + )} +

    + Last learned: + {l.last_signal_at ?

    + {l.detail &&

    {l.detail}

    } + {quiet && ( +

    + What to check: + {known?.check ?? "This loop should have learned from this week's work and did not. Look in the gateway's and the worker's logs for it."} +

    + )} +
  • + ); +} + +export function LearningHealthSection() { + const [health, setHealth] = useState(null); + const [error, setError] = useState(""); + const [gone, setGone] = useState(false); + + const load = useCallback(async () => { + setError(""); + try { + setHealth(await api.getLearningHealth()); + } catch (e) { + // A gateway from before the health check has no such route: show nothing. + if (errorStatus(e) === 404) setGone(true); + else setError(e instanceof Error ? e.message : "The request failed."); + } + }, []); + + useEffect(() => { + void load(); + }, [load]); + + if (gone) return null; + const days = health?.window_days ?? 7; + const quiet = health?.loops.filter((l) => l.state === "quiet") ?? []; + const red = health?.state === "red" || quiet.length > 0; + + return ( +
    + {error ? ( + void load()}> + Try again + + } + > +

    {error}

    +
    + ) : !health ? ( + + ) : ( +
    + {red ? ( + +

    Each one should have learned from this week's work and did not. What to check is under each.

    +
    + ) : ( +

    Every loop that had something to learn from learned from it.

    + )} +
      + {[...health.loops] + // The quiet ones first; the rest keep the gateway's order. + .sort((a, b) => Number(b.state === "quiet") - Number(a.state === "quiet")) + .map((l) => ( + + ))} +
    +
    + )} +
    + ); +} diff --git a/dashboard/src/app/learning/page.tsx b/dashboard/src/app/learning/page.tsx index d4d2bf0a..a894ad10 100644 --- a/dashboard/src/app/learning/page.tsx +++ b/dashboard/src/app/learning/page.tsx @@ -12,6 +12,7 @@ import { } from "@/lib/api"; import { CardSkeleton, ChartSkeleton } from "@/components/skeleton"; import { Examples } from "./examples"; +import { LearningHealthSection } from "./health"; import { StatGrid, StatTile } from "@/components/stat-tile"; import { DataTable, type Column } from "@/components/data-table"; import { Problem } from "@/components/problem"; @@ -585,7 +586,9 @@ export default function LearningPage() { lead="What Coderhelm learned from how its work was received: review comments acted on or dismissed, ratings, merges, reverts and CI. Every change it made because of that is listed with its evidence, and can be turned off." /> -
    + + +
    diff --git a/dashboard/src/app/runs/detail/page.tsx b/dashboard/src/app/runs/detail/page.tsx index fb36a1c1..b66beca4 100644 --- a/dashboard/src/app/runs/detail/page.tsx +++ b/dashboard/src/app/runs/detail/page.tsx @@ -649,6 +649,12 @@ function RunDetailInner() { : []; const done = ["completed", "merged", "success"].includes(run.status); const live = runIsLive(run.status) || run.status === "queued" || run.status === "pending"; + // Finished with its pull request still a draft (the gateway clears it once + // the pull request is ready or closed): held reads "Finished, PR held". + // An unfinished fix round on the same pull request says so first (Resume). + const hold = run.draft_hold && ["needs_input", "completed", "success"].includes(run.status) && !(done && run.round_incomplete) ? run.draft_hold : null; + // Waiting out GitHub's limit while still working; it goes on by itself. + const githubWait = run.github_wait && live ? run.github_wait.trim().replace(/[.;]\s*$/, "") : ""; // Asks and stop notes are current while the run works or waits on an answer. const asksAreCurrent = live || run.status === "needs_input"; const hasPr = !!run.pr_number || !!run.pr_url || runPrs.length > 0 || (run.pr_urls?.length ?? 0) > 0; @@ -924,7 +930,50 @@ function RunDetailInner() { } else { // `body` is one sentence; `content` is a block of its own (a form, a list). const look: { tone: OutcomeTone; title: string; body: React.ReactNode; content?: React.ReactNode; actions?: React.ReactNode } = - run.status === "merged" + hold + ? { + // Finished, and the pull request stays a draft: why, and what to do about each reason. + tone: hold.kind === "failed" ? "attention" : "waiting", + title: hold.kind === "failed" ? "Finished, PR held: GitHub refused to mark it ready" : hold.kind === "waiting" ? "Finished, PR held until a check settles" : "Finished, PR held", + body: {hold.summary}, + content: hold.reasons.length > 0 && ( +
      + {hold.reasons.map((r, i) => ( +
    • +

      {r.what}

      +

      + What to do: + {r.todo} +

      +
    • + ))} + {hold.since && ( +
    • + Held since
    • + )} +
    + ), + actions: ( + <> + {openPrButtons("primary")} + {retryButton} + + ), + } + : githubWait + ? { + // GitHub's limit or an outage: the run goes on by itself at the time given. + tone: "waiting", + title: "Waiting for GitHub", + body: ( + + {githubWait}. Nothing is needed from you. + + ), + actions: openPrButtons("secondary"), + } + : run.status === "merged" ? { tone: "success", title: "Done. The change was merged.", body: "The pull request is merged, so the change is in.", actions: openPrButtons("secondary") } : done ? { @@ -1043,7 +1092,7 @@ function RunDetailInner() { } + status={} lead={ {run.repo || "Choosing a repository…"} diff --git a/dashboard/src/components/run-status.tsx b/dashboard/src/components/run-status.tsx index 973fbea0..ec16b949 100644 --- a/dashboard/src/components/run-status.tsx +++ b/dashboard/src/components/run-status.tsx @@ -70,8 +70,22 @@ export function runIsLive(status: string | null | undefined): boolean { /** A finished run whose pull request is open while its last fix round didn't finish. */ const UNFINISHED_ROUND: RunLook = { label: "PR open, fix unfinished", tone: "attention", group: "done" }; -export function RunStatusBadge({ status, unfinishedRound }: { status: string | null | undefined; unfinishedRound?: boolean }) { - const look = unfinishedRound ? UNFINISHED_ROUND : runStatusLook(status); +/** A finished run whose pull request is still a draft, for named reasons (`draft_hold`). */ +const DRAFT_HELD: RunLook = { label: "Finished, PR held", tone: "waiting", group: "waiting" }; +/** The same, when GitHub refused every try to mark it ready. */ +const DRAFT_NOT_MARKED: RunLook = { label: "Finished, PR held", tone: "attention", group: "waiting" }; + +export function RunStatusBadge({ + status, + unfinishedRound, + draftHold, +}: { + status: string | null | undefined; + unfinishedRound?: boolean; + /** The run's `draft_hold.kind`, when its pull request is still a draft. */ + draftHold?: string | null; +}) { + const look = draftHold ? (draftHold === "failed" ? DRAFT_NOT_MARKED : DRAFT_HELD) : unfinishedRound ? UNFINISHED_ROUND : runStatusLook(status); return ( diff --git a/dashboard/src/lib/api-contract.ts b/dashboard/src/lib/api-contract.ts index 0cff90c9..95a003a9 100644 --- a/dashboard/src/lib/api-contract.ts +++ b/dashboard/src/lib/api-contract.ts @@ -6,7 +6,7 @@ // Nothing here runs; it is checked by the compiler only. import type { OpenApiFields } from "./openapi-fields"; -import type { AnswerRunResult, Plan, ReviewSession, Run, RunAnswer, RunDetail, RunQuestion, RunTrigger, SessionStep, Task, api } from "./api"; +import type { AnswerRunResult, Plan, ReviewSession, Run, RunAnswer, RunDetail, RunDraftHold, RunDraftHoldReason, RunQuestion, RunTrigger, SessionStep, Task, api } from "./api"; type Answer = Awaited>; @@ -26,6 +26,9 @@ export type RunTriggerContract = None>; export type RunQuestionContract = None>; export type RunAnswerContract = None>; export type AnswerRunContract = None>; +// Why a finished run's pull request is still a draft, and what to do about each reason. +export type RunDraftHoldContract = None>; +export type RunDraftHoldReasonContract = None>; // Plans and their tasks (the plan pages and the runs they start). export type PlansPageContract = None, "PlansPage">>; diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index b6f36ea0..0aeabd7d 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -498,6 +498,8 @@ export const api = { /** The Learning page: rewards, finding categories, behavior changes, exemplars and variants. */ getLearning: (days: number, repo?: string) => request(`/api/learning?days=${days}${repo ? `&repo=${encodeURIComponent(repo)}` : ""}`), + /** Each learning loop's last signal and its count over the last week; `red` when one that should have learned did not. */ + getLearningHealth: () => request("/api/learning/health"), /** Pin one variant for an agent (admin), or `null` to let results choose again. */ pinVariant: (agent: string, arm: string | null) => request<{ ok: boolean }>("/api/learning/pin", { method: "POST", body: JSON.stringify({ agent, arm }) }), @@ -2022,6 +2024,27 @@ export interface RunWaitingOn { since?: string | null; } +/** Why a finished run's pull request is still a draft. */ +export interface RunDraftHold { + /** `held` (a person must act; the run is `needs_input`), `waiting` (settles by itself) or `failed` (GitHub refused to mark it ready). */ + kind: "held" | "waiting" | "failed" | (string & {}); + /** The run page's line, ready to show. */ + summary: string; + /** Each reason, with what to do about it. */ + reasons: RunDraftHoldReason[]; + pr_number: number; + /** When it was first held for these reasons. */ + since?: string | null; +} + +/** One reason a pull request stays a draft. */ +export interface RunDraftHoldReason { + /** What holds it. */ + what: string; + /** What to do about it. */ + todo: string; +} + export interface CodegenEnvMissing { repo: string; command: string; @@ -2108,6 +2131,10 @@ export interface RunDetail extends Run { questions?: RunQuestion[]; /** While `needs_input`: what it waits for from a person, by name. */ waiting_on?: RunWaitingOn | null; + /** Set when the run finished and its pull request is still a draft: why, and what to do about each reason. */ + draft_hold?: RunDraftHold | null; + /** While the run waits for GitHub (its hourly limit, or GitHub not answering): when it goes on, in plain words. */ + github_wait?: string | null; /** The comment with those questions on the ticket or issue. */ questions_url?: string | null; /** Answers people gave to them in Coderhelm. */ @@ -4233,6 +4260,35 @@ export interface Learning { bandit: LearningBandit[]; } +/** `quiet`: the loop should have learned from this window's work and did not. */ +export type LearningLoopState = "ok" | "quiet" | "idle"; + +/** One learning loop on the health check. */ +export interface LearningLoop { + /** `pr_outcomes`, `review_outcomes`, `calibration`, `reviewer_variants`, `coder_variants`, `examples`, `coder_lessons`, `review_lessons`, `stop_outcomes`. */ + key: string; + label: string; + state: LearningLoopState | (string & {}); + /** RFC 3339, or empty when it never learned. */ + last_signal_at: string; + /** Signals over the window. */ + count: number; + /** What should have fed it over the window, when that is countable. */ + expected: number | null; + detail: string; +} + +/** GET /api/learning/health: per learning loop, its last signal and its count over the window. */ +export interface LearningHealth { + window_days: number; + generated_at: string; + /** `red` when any loop is `quiet`. */ + state: "ok" | "red" | (string & {}); + /** Keys of the quiet loops. */ + quiet: string[]; + loops: LearningLoop[]; +} + // ── This install (self-hosted) ────────────────────────────────────────── export interface AutoUpdateSettings { diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index c201a876..6104b10d 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 = "8e88509e274d1f7c993420e65d77a0381a9d9079"; +export const OPENAPI_REF = "0bcd4365b903400185b02bb2423d55da8cc2f9fb"; /** The fields each public API schema has. */ export interface OpenApiFields { @@ -61,14 +61,18 @@ export interface OpenApiFields { RotateBody: "overlap_hours"; RotatedSecret: "previous_secret_expires_at" | "secret"; RoundIncomplete: "at" | "can_resume" | "files" | "kind" | "number" | "pushed" | "reason" | "summary" | "wip_branch"; - 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" | "waiting_on"; + 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" | "draft_hold" | "duration_s" | "error" | "files_modified" | "fix_location" | "github_wait" | "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" | "waiting_on"; 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"; + RunDraftHold: "kind" | "pr_number" | "reasons" | "since" | "summary"; + RunDraftHoldReason: "todo" | "what"; 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"; RunWaitingOn: "action" | "detail" | "since" | "url"; From 4f3d50243adf678d91a28efe4856f96e3d5c1b00 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Fri, 6 Nov 2026 23:46:54 -0500 Subject: [PATCH 2/2] Learning health uses the dashboard's own loop titles; API field list at platform main Each learning loop's title comes from its id in plain words, Coderhelm spelling, and the API's name strings are never shown. An id the dashboard doesn't know reads as its words. The test data follows the platform's same-unit counts (pull requests on both sides), so no loop reads more than it should have had. src/lib/openapi-fields.ts is regenerated at coderhelm-platform main now that the draft hold has merged. --- dashboard/e2e/learning.spec.ts | 17 +++++++++++++++++ dashboard/e2e/wide-data/learning.ts | 12 +++++++----- dashboard/src/app/learning/health.tsx | 27 ++++++++++++++++++++++++--- dashboard/src/lib/api.ts | 1 + dashboard/src/lib/openapi-fields.ts | 2 +- 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/dashboard/e2e/learning.spec.ts b/dashboard/e2e/learning.spec.ts index ad764550..eeee0eb8 100644 --- a/dashboard/e2e/learning.spec.ts +++ b/dashboard/e2e/learning.spec.ts @@ -474,9 +474,17 @@ test("a quiet loop turns the health check red and says what to check", async ({ await expect(idle).toHaveAttribute("data-state", "idle"); await expect(idle).toContainText("Nothing to learn from yet"); await expect(idle).toContainText("Last learned: never"); + await expect(idle).toContainText("0 this week"); await expect(idle).toContainText("Learns from: Repeated setbacks in one area of the code"); await expect(page.getByTestId("loop-coder_lessons-check")).toHaveCount(0); + // Titles are the dashboard's own words, never the API's names. + await expect(red.getByRole("heading")).toHaveText("What happens to Coderhelm's pull requests"); + await expect(health.getByText("Outcomes of CoderHelm's pull requests")).toHaveCount(0); + await expect(health.getByText(/CoderHelm/)).toHaveCount(0); + await expect(page.getByTestId("loop-review_outcomes")).toContainText("4 of 6 this week"); + await expect(page.getByTestId("loop-review_outcomes").getByRole("heading")).toHaveText("What people do with review comments"); + // A working loop with no expected count shows its count alone. const ok = page.getByTestId("loop-calibration"); await expect(ok).toContainText("Learning"); @@ -524,3 +532,12 @@ test("the health check fits a phone at 375 wide", async ({ page }) => { fs.mkdirSync(SHOTS_DIR, { recursive: true }); await page.locator("#health").screenshot({ path: path.join(SHOTS_DIR, "learning-health-phone.png") }); }); + +test("a loop this dashboard has no title for reads as its id in words", async ({ page }) => { + await mockApi(page, { health: learningHealthFixture({ repo: REPO, text: "", quiet: [], extra: true }) }); + await page.goto("/learning"); + const extra = page.getByTestId("loop-planner_lessons"); + await expect(extra.getByRole("heading")).toHaveText("Planner lessons"); + await expect(page.getByText("Planner lessons (API name)")).toHaveCount(0); + await expect(extra).toContainText("1 of 2 this week"); +}); diff --git a/dashboard/e2e/wide-data/learning.ts b/dashboard/e2e/wide-data/learning.ts index 6d279c5a..4fabcb4e 100644 --- a/dashboard/e2e/wide-data/learning.ts +++ b/dashboard/e2e/wide-data/learning.ts @@ -174,7 +174,7 @@ export function exemplarsFixture(o: Pick { @@ -183,15 +183,17 @@ export function learningHealthFixture(o: { repo: string; text: string; quiet?: s }; const loops = [ loop("pr_outcomes", "Outcomes of CoderHelm's pull requests", 3, 5, quiet.has("pr_outcomes") ? `2 closed pull request(s) were never scored: ${o.repo}#12345, ${o.repo}#67890 ${o.text}` : "5 of 5 pull requests that closed were scored"), - loop("review_outcomes", "Outcomes of review comments", 14, 6, "9 acted on, 3 dismissed, 2 left open, from 6 review(s)"), + loop("review_outcomes", "Outcomes of review comments", 4, 6, "4 of 6 reviewed pull request(s) have a comment outcome; comments: 9 acted on, 3 dismissed, 2 left open"), loop("calibration", "Reviewer calibration", 4, null, "4 category counter(s) updated; changes: 1 raised, 0 downgraded, 0 suppressed, 0 back to none"), - loop("reviewer_variants", "Reviewer prompt variants", 6, 6, "3 arm(s), 41 pull(s) in all; 6 outcome(s) credited to a variant this window"), - loop("coder_variants", "Coder prompt variants", 2, 5, "2 arm(s), 9 pull(s) in all; 2 outcome(s) credited to a variant this window"), + loop("reviewer_variants", "Reviewer prompt variants", 4, 6, "4 of 6 pull request(s) have an outcome credited to a variant; 3 arm(s), 41 pull(s) in all"), + loop("coder_variants", "Coder prompt variants", 2, 5, "2 of 5 pull request(s) have an outcome credited to a variant; 2 arm(s), 9 pull(s) in all"), loop("examples", "Good and avoid examples in prompts", 5, null, "5 of 12 example(s) used this window"), - loop("coder_lessons", "Coder lessons from outcomes", 0, 0, "0 setback(s) in 0 area(s); 0 area(s) with enough evidence for a lesson; 0 lesson(s) written or reinforced"), + loop("coder_lessons", "Coder lessons from outcomes", 0, null, "0 setback(s) in 0 area(s); 0 area(s) with enough evidence for a lesson; 0 lesson(s) written or reinforced"), loop("review_lessons", "Reviewer lessons from people's pushback", 2, 2, "2 pull request(s) with pushback, 2 judged, 1 lesson(s) learned, 0 stuck"), loop("stop_outcomes", "What people did after asks, stops and blocks", 0, 0, "0 ask(s), stop(s) and block(s); 0 with a person's act recorded, 0 shown wrong (the judge is given those)"), ]; + // A loop a newer gateway adds, which this dashboard has no title for. + if (o.extra) loops.push(loop("planner_lessons", "Planner lessons (API name)", 1, 2, "1 of 2 plans with a lesson")); const q = loops.filter((l) => l.state === "quiet").map((l) => l.key); return { window_days: 7, generated_at: iso(0), state: q.length ? "red" : "ok", quiet: q, loops }; } diff --git a/dashboard/src/app/learning/health.tsx b/dashboard/src/app/learning/health.tsx index 008acfe9..8bd7f58b 100644 --- a/dashboard/src/app/learning/health.tsx +++ b/dashboard/src/app/learning/health.tsx @@ -14,41 +14,54 @@ import { smallSecondaryButton } from "@/components/ui"; // loop that went quiet, what to check. The week is fixed by the gateway, so // the page's period and repository filters don't apply here. -/** What each loop learns from, and what to check when it goes quiet. Unknown keys show the gateway's own detail. */ -const LOOPS: Record = { +/** + * Each loop's title, what it learns from, and what to check when it goes quiet, + * by the loop's id. The titles are the dashboard's own; the API's `label` is + * never shown. An id this dashboard doesn't know reads as its words. + */ +const LOOPS: Record = { pr_outcomes: { + title: "What happens to Coderhelm's pull requests", from: "Whether Coderhelm's pull requests were merged as written, merged after people's edits, or closed.", check: "Pull requests closed this week were never scored. Check that the GitHub App still gets pull request events (Settings, Integrations, GitHub), then look in the gateway's log for the pull requests named above.", }, review_outcomes: { + title: "What people do with review comments", from: "Whether people acted on the reviewer's comments, dismissed them, or left them open.", check: "Reviews ran this week but none of their comments was scored. Check that the GitHub App still gets review comment and pull request events.", }, calibration: { + title: "What the reviewer raises", from: "How often each kind of review comment is acted on, per repository, which tunes what the reviewer raises.", check: "Comments were scored but no category moved. Look in the gateway's log for the learning step that follows a scored comment.", }, reviewer_variants: { + title: "Ways of reviewing", from: "Which way of reviewing gets the better outcomes.", check: "Reviews ran but no variant was picked or credited this week. Look in the reviewer's log for the variant it chose.", }, coder_variants: { + title: "Ways of writing code", from: "Which way of writing code gets its pull requests merged.", check: "Pull requests closed but no coding variant was picked or credited this week. Look in the worker's log for the variant each run chose.", }, examples: { + title: "Examples to follow or avoid", from: "Past comments and changes that landed well or badly, put in the agents' prompts as examples to follow or to avoid.", check: "Reviews ran but no example was used in a prompt this week. Check that the repositories reviewed have examples under Examples in use.", }, coder_lessons: { + title: "Lessons for the coding agent", from: "Repeated setbacks in one area of the code: closed pull requests, reverts, checks that failed.", check: "Some areas had enough setbacks for a lesson, but none was written or reinforced. Look in the worker's log for the lessons step.", }, review_lessons: { + title: "Lessons for the reviewer", from: "People pushing back on the reviewer's comments.", check: "Pull requests with pushback have waited more than 2 hours to be judged. Look in the worker's log for the review lessons step.", }, stop_outcomes: { + title: "What people do after Coderhelm asks or stops", from: "What people did after Coderhelm asked a question, stopped, or blocked a merge.", check: "Asks, stops and blocks from this week have no recorded follow up. Check that pull request and ticket events still arrive.", }, @@ -61,6 +74,14 @@ const STATE: Record STATE[s] ?? { label: s, tone: "neutral" as const }; +/** "coder_lessons" reads "Coder lessons" when this dashboard has no title for it. */ +function titleOf(key: string): string { + const known = LOOPS[key]?.title; + if (known) return known; + const words = key.replace(/_/g, " ").trim(); + return words.charAt(0).toUpperCase() + words.slice(1); +} + function amount(l: LearningLoop, days: number): string { const period = days === 7 ? "this week" : `in ${days} days`; if (l.expected == null) return `${l.count.toLocaleString()} ${period}`; @@ -74,7 +95,7 @@ function LoopCard({ l, days }: { l: LearningLoop; days: number }) { return (
  • -

    {l.label}

    +

    {titleOf(l.key)}

    {state.label}
    {known && ( diff --git a/dashboard/src/lib/api.ts b/dashboard/src/lib/api.ts index 0aeabd7d..3160a666 100644 --- a/dashboard/src/lib/api.ts +++ b/dashboard/src/lib/api.ts @@ -4267,6 +4267,7 @@ export type LearningLoopState = "ok" | "quiet" | "idle"; export interface LearningLoop { /** `pr_outcomes`, `review_outcomes`, `calibration`, `reviewer_variants`, `coder_variants`, `examples`, `coder_lessons`, `review_lessons`, `stop_outcomes`. */ key: string; + /** The API's own name for it; the page shows its own title by `key` instead. */ label: string; state: LearningLoopState | (string & {}); /** RFC 3339, or empty when it never learned. */ diff --git a/dashboard/src/lib/openapi-fields.ts b/dashboard/src/lib/openapi-fields.ts index 6104b10d..50a115bd 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 = "0bcd4365b903400185b02bb2423d55da8cc2f9fb"; +export const OPENAPI_REF = "de34e9c10940158650799353fda932d6ca73c0a0"; /** The fields each public API schema has. */ export interface OpenApiFields {