diff --git a/dashboard/e2e/prs-overview-data.ts b/dashboard/e2e/prs-overview-data.ts index 3d4ff6d9..3ed14f33 100644 --- a/dashboard/e2e/prs-overview-data.ts +++ b/dashboard/e2e/prs-overview-data.ts @@ -441,7 +441,6 @@ export function overview(kind: Scenario = "normal", repo?: string): PrsOverview missing.push({ path: "review.flow", reason: "history", text: "Not enough history yet: the weekly flow needs 2 weeks of review logs." }); missing.push({ path: "review.depth.rubber_stamp", reason: "history", text: "Not enough history yet: the repo's p10 approval time needs 30 approvals." }); missing.push({ path: "review.rubber_stamp_by_size", reason: "history", text: "Not enough history yet: fewer than 10 qualifying PRs." }); - missing.push({ path: "repo_view.flow", reason: "history", text: "Not enough history yet: the flow by stage needs 2 nightly snapshots." }); missing.push({ path: "failures.main_red", reason: "history", text: "Not enough history yet: main's checks are read from this week on." }); missing.push({ path: "failures.flaky", reason: "history", text: "Not enough history yet: a flaky check needs 10 runs." }); } @@ -613,24 +612,80 @@ export function overview(kind: Scenario = "normal", repo?: string): PrsOverview missing, sources: [{ name: "records", read: "ok", detail: "" }], }; - if (repo) { - const days = young ? 1 : 84; - o.repo_view = { - flow: young - ? null - : Array.from({ length: days }, (_, i) => ({ - day: iso((days - i) * D).slice(0, 10), - stages: { draft: 1 + (i % 3 === 0 ? 1 : 0), first_review: 3 + Math.round(4 * Math.sin(i / 9) ** 2) + Math.floor(i / 20), in_review: 3 + (i % 5 === 0 ? 1 : 0), blocked: 1 + Math.floor(i / 30), coderhelm_working: i % 4 === 0 ? 1 : 0, approved: 2 }, - })), - merged: Array.from({ length: 34 }, (_, i) => { - const r = rng(i + 5); - const ch = i % 4 === 0; - return { key: `${repo}#${200 + i}`, number: 200 + i, title: TITLES[i % TITLES.length], cycle_secs: Math.round((1 + r() * r() * 120) * H), merged_at: iso((90 - i * 2.5) * D), coderhelm: ch }; - }), - }; - } + o.trends = isEmpty ? null : trendsOf(kind, repo, young, all); return o; } +/** A normal draw (Box-Muller) from the seeded generator. */ +function normal(r: () => number): number { + return Math.sqrt(-2 * Math.log(Math.max(1e-9, r()))) * Math.cos(2 * Math.PI * r()); +} + +const STAGE_KEYS: PrStage[] = ["draft", "first_review", "in_review", "blocked", "coderhelm_working", "approved"]; + +/** + * The trends as history would give them: merges on weekdays at working + * hours (a weekend merge now and then), cycle times long-tailed and longer + * for ones that sat over a weekend, and the open count walking with + * weekday arrivals and merges. A young org's stage split begins 9 days ago. + */ +function trendsOf(kind: Scenario, repo: string | undefined, young: boolean, open: OverviewDot[]): NonNullable { + const r = rng(kind.length * 131 + (repo?.length ?? 0) * 17 + 3); + const scale = repo ? 0.18 : 1; + const rate = (kind === "bad" ? 3.2 : kind === "quiet" ? 0.8 : 4.6) * scale; + const today = new Date(NOW); + today.setUTCHours(0, 0, 0, 0); + const dayStart = (back: number) => today.getTime() - back * D * 1000; + const merged: NonNullable["merged"] = []; + let n = 900; + for (let back = 89; back >= 0; back--) { + const t0 = dayStart(back); + const wd = new Date(t0).getUTCDay(); + const weekend = wd === 0 || wd === 6; + const want = weekend ? (r() < 0.15 * scale + 0.05 ? 1 : 0) : Math.max(0, Math.round(rate + normal(r) * Math.sqrt(rate))); + for (let k = 0; k < want; k++) { + const at = t0 + (9 + r() * 10) * H * 1000; + if (at > NOW) continue; + let cycle = Math.exp(Math.log(19 * H) + normal(r) * 1.15); + // Waiting through a weekend adds it. + if (wd <= 2 && r() < 0.35) cycle += 2 * D; + cycle = Math.min(40 * D, Math.max(12 * 60, cycle)); + const rp = repo ?? REPOS[Math.floor(r() * 9)]; + const number = n++; + merged.push({ key: `${rp}#${number}`, repo: rp, number, title: TITLES[Math.floor(r() * TITLES.length)], merged_at: new Date(at).toISOString(), cycle_secs: Math.round(cycle), coderhelm: r() < 0.18 }); + } + } + // Open per day: walk back from today's open, weekdays moving, weekends still. + const nowByStage: Record = {}; + for (const d of open) nowByStage[d.stage] = (nowByStage[d.stage] ?? 0) + 1; + let total = open.length; + const days: NonNullable["flow"] = []; + const split = young ? 9 : 84; + for (let back = 0; back < 84; back++) { + const t0 = dayStart(back); + const wd = new Date(t0).getUTCDay(); + const stages: Partial> = {}; + if (back < split) { + let left = total; + STAGE_KEYS.forEach((st, i) => { + const share = (nowByStage[st] ?? 0) / Math.max(1, open.length); + const v = i === STAGE_KEYS.length - 1 ? left : Math.max(0, Math.min(left, Math.round(total * share + normal(r) * 0.8))); + stages[st] = v; + left -= v; + }); + } + days.unshift({ day: new Date(t0).toISOString().slice(0, 10), stages: back < split ? stages : {}, total, unknown: back < split ? 0 : total }); + const weekend = wd === 0 || wd === 6; + if (!weekend) total = Math.max(0, total + Math.round(normal(r) * 2.2 * Math.sqrt(scale) + (kind === "bad" ? -0.6 : 0.1))); + } + return { + flow: days, + split_from: young ? days[days.length - split].day : days[0].day, + merged: merged.reverse(), + cycle_days: 90, + flow_days: 84, + }; +} + /** Every login the fixtures use for people: none may appear outside a pull request's row or an item's owner. */ export const PEOPLE = ["octocat", "mara", "theo", "jun"]; diff --git a/dashboard/e2e/prs-overview-sizes.spec.ts b/dashboard/e2e/prs-overview-sizes.spec.ts new file mode 100644 index 00000000..78f46b59 --- /dev/null +++ b/dashboard/e2e/prs-overview-sizes.spec.ts @@ -0,0 +1,127 @@ +import fs from "node:fs"; +import path from "node:path"; +import { expect, test, type Locator } from "@playwright/test"; +import { mockOverview } from "./prs-overview-mock"; +import { sized, type Size } from "./prs-overview-sizes"; + +// The overview at three sizes of org (one repo with three open pull requests +// and no history; 14 repos and about 40 open; about 300 open) and four widths. +// Each is captured, and the layout rules hold at every one: no tooltip is +// visible until something is hovered or focused, the age chart is never +// taller than its marks need, and a handful of pull requests is a list, not +// an empty plot. + +/** + * The legend items with no drawn mark of their kind: a mark counts only on + * a drawn dot or band (never the chart's own element). + */ +async function undrawnLegendItems(aging: Locator): Promise { + const out: string[] = []; + const legend = aging.getByTestId("aging-legend"); + if ((await legend.count()) === 0) return out; + for (const item of await legend.locator("[data-mark]").all()) { + const mark = (await item.getAttribute("data-mark")) ?? ""; + const drawn = await aging.locator(`[data-testid="aging-dot"][data-marks~="${mark}"], [data-testid="aging-band"][data-marks~="${mark}"]`).count(); + if (drawn === 0) out.push(mark); + } + return out; +} + +const SHOTS_DIR = process.env.E2E_SHOTS_DIR || path.join("test-results", "overview-sizes"); +const PREFIX = process.env.E2E_SHOTS_PREFIX || `org-polish-${process.env.E2E_SHOTS_TAG || "after"}`; +const WIDTHS = [1440, 1280, 1024, 375]; +const SIZES: Size[] = ["sparse", "medium", "big"]; + +for (const size of SIZES) { + for (const width of WIDTHS) { + test(`overview, ${size} org at ${width}px: captured, nothing floating at rest, the chart sized to its marks`, async ({ page }) => { + await page.setViewportSize({ width, height: 900 }); + await mockOverview(page, () => sized(size)); + await page.goto("/prs/overview?org=acme"); + await expect(page.getByTestId("overview-summary")).toBeVisible(); + await page.mouse.move(0, 0); + fs.mkdirSync(SHOTS_DIR, { recursive: true }); + await page.screenshot({ path: path.join(SHOTS_DIR, `${PREFIX}-${size}-${width}.png`), fullPage: true }); + if (width >= 640) await page.getByTestId("overview-aging").screenshot({ path: path.join(SHOTS_DIR, `${PREFIX}-${size}-${width}-aging.png`) }); + + // Nothing floats over the page until a mark is hovered or focused. + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); + + if (width >= 640) { + const aging = page.getByTestId("overview-aging"); + await expect(aging).toBeVisible(); + const marks = sized(size).aging.dots.length; + if (marks < 10) { + // A few pull requests are a list with their ages, not a plot. + await expect(aging.getByTestId("aging-chart")).toHaveCount(0); + await expect(aging.getByTestId("aging-row")).toHaveCount(marks); + } else { + const chart = aging.getByTestId("aging-chart"); + const box = await chart.boundingBox(); + expect(box && box.height, "the chart is never taller than 320px").toBeLessThanOrEqual(320); + // Axis words are body size or smaller. + const sizes = await chart.locator("text").evaluateAll((els) => els.map((e) => parseFloat(getComputedStyle(e).fontSize) * (e.getBoundingClientRect().height / Math.max(1, (e as SVGTextElement).getBBox().height)))); + expect(Math.max(...sizes), "axis labels are at most 13px on screen").toBeLessThanOrEqual(13.5); + // A mark shows its tooltip on hover, and it goes away after. + await chart.getByTestId("aging-dot").first().hover(); + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(1); + await page.mouse.move(0, 0); + await expect(page.locator('[role="tooltip"]:visible')).toHaveCount(0); + } + // The legend names only what is drawn. + expect(await undrawnLegendItems(aging)).toEqual([]); + } + + // A new install: panels with nothing to say are one quiet line, never rows of 0. + if (size === "sparse" && width >= 640) { + const stale = page.getByTestId("panel-stale"); + await expect(stale.getByTestId("panel-rest")).toContainText("Nothing idle"); + await expect(stale).not.toContainText("Not enough history yet"); + await expect(page.getByTestId("panel-security")).not.toContainText("Not enough history yet"); + await expect(page.getByTestId("overview-coderhelm")).not.toContainText("Not enough history yet"); + // Whose turn and the conditions leave out their zeros; the note is said once. + await expect(page.locator('[data-testid="turn-link"]:visible')).toHaveText(["people 2", "CoderHelm 1"]); + await expect(page.locator('[data-testid="conditions-none"]:visible')).toHaveText("nothing stale, abandoned or zombie"); + await expect(page.getByTestId("history-note")).toContainText("review health"); + await expect(page.getByText("Failures and review health")).toHaveCount(0); + } + + // On a phone a new install lists its open PRs by age, and has no + // failures or review folds; on a desktop, no such panels either. + if (size === "sparse" && width < 640) { + const phoneAge = page.getByTestId("overview-aging-phone"); + await expect(phoneAge).toBeVisible(); + await expect(phoneAge.getByTestId("aging-row")).toHaveCount(3); + await expect(phoneAge.getByTestId("aging-row").first()).toContainText("2.1d"); + await expect(page.getByTestId("phone-failures")).toHaveCount(0); + await expect(page.getByTestId("phone-review")).toHaveCount(0); + } + if (width >= 1024) { + const panels = page.getByTestId("overview-panels"); + const merged = size !== "sparse"; + await expect(panels.getByTestId("panel-failures")).toHaveCount(merged ? 1 : 0); + await expect(panels.getByTestId("panel-review")).toHaveCount(merged ? 1 : 0); + await expect(panels.getByTestId("panel-stale")).toHaveCount(1); + await expect(panels.getByTestId("panel-security")).toHaveCount(1); + } + + // No sideways scroll at any width. + const sideways = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); + expect(sideways).toBeLessThanOrEqual(1); + + }); + } +} + +test("the legend check fails when a legend item has no drawn mark", async ({ page }) => { + await page.setViewportSize({ width: 1440, height: 900 }); + await mockOverview(page, () => sized("medium")); + await page.goto("/prs/overview?org=acme"); + const aging = page.getByTestId("overview-aging"); + await expect(aging.getByTestId("aging-dot").first()).toBeVisible(); + expect(await undrawnLegendItems(aging)).toEqual([]); + // Take every person's mark off the chart: the legend still names it, and + // the check says so. + await aging.evaluate((el) => el.querySelectorAll('[data-testid="aging-dot"][data-marks~="person"]').forEach((d) => d.remove())); + expect(await undrawnLegendItems(aging)).toEqual(["person"]); +}); diff --git a/dashboard/e2e/prs-overview-sizes.ts b/dashboard/e2e/prs-overview-sizes.ts new file mode 100644 index 00000000..9d58d86f --- /dev/null +++ b/dashboard/e2e/prs-overview-sizes.ts @@ -0,0 +1,103 @@ +// The overview at three sizes of org, for the layout and screenshot checks: +// a new install with one repo, three open pull requests and no history; a +// medium org (14 repos, about 40 open); and a big one (14 repos, about 300 +// open, more than the chart shows). Invented data, from the bookstore. + +import type { OverviewDot, PrStage, PrsOverview } from "../src/lib/api"; +import { overview } from "./prs-overview-data"; + +export type Size = "sparse" | "medium" | "big"; + +const H = 3600; +const D = 86_400; + +/** One repo, three open pull requests, no history: the first day of an install. */ +function sparse(): PrsOverview { + const o = overview("empty"); + const repo = "acme/bookstore"; + const mk = (n: number, stage: PrStage, state: string, state_label: string, age: number, who: "person" | "coderhelm" | "bot", title: string): OverviewDot => ({ + key: `${repo}#${n}`, + repo, + number: n, + title, + stage, + state, + state_label, + age_secs: age, + coderhelm: who === "coderhelm", + author_type: who, + band: null, + idle: false, + main_blocked: false, + }); + const dots = [ + mk(12, "first_review", "needs_review", "Needs review", 40 * 60, "person", "Add the paperback filter to search"), + mk(11, "in_review", "changes_requested", "Changes requested", 5 * H, "coderhelm", "Round cart totals per currency"), + mk(9, "approved", "checks_running", "Checks running", 2 * D + 3 * H, "person", "Show stock per warehouse on the book page"), + ]; + const stages: Partial> = { first_review: 1, in_review: 1, approved: 1 }; + o.scope = { ...o.scope, repos: 1, repos_read: 1 }; + o.open = 3; + o.drafts = 0; + o.aging = { ...o.aging, dots, shown: 3, total: 3 }; + o.strip = o.strip.map((c) => ({ ...c, count: stages[c.stage as PrStage] ?? 0, delta: null, spark: null, past_p85: 0 })); + o.turns = { person: 2, coderhelm: 1, machines: 0, nobody: 0 }; + o.thresholds = { ...o.thresholds, cycle: null, first_review: null, external: true }; + o.history = { ...o.history, days: 0, weeks: 0, young: true, merged_90d: 0 }; + o.summary = { + ...o.summary, + verdict: { ...o.summary.verdict, state: "quiet", word: "Quiet", parts: [{ t: "3 open pull requests in bookstore, none waiting longer than a couple of days." }] }, + attention: [], + quiet: { repos: 1, open: 3, parts: [{ t: "Nothing needs you: no pull request is idle or blocked." }] }, + coderhelm: { ...o.summary.coderhelm, parts: [{ t: "One pull request of its own in review; nothing merged yet." }] }, + }; + o.coderhelm = { + author: { ...o.coderhelm.author, opened: 1, merged: 0, closed_unmerged: 0, open: 1, merge_rate: null, p50_merge_secs: null, waiting_on_people: null }, + fixer: { fixed: 0, merged: 0, closed_unmerged: 0, open: 0 }, + reviewer: { reviewed: 2, findings: null, verified_rate: null, p50_first_look_secs: 4 * 60 }, + runs: null, + exceptions: { ...o.coderhelm.exceptions, needs_decision: 0, oldest_secs: null, reworked: null, merges: null, cost_per_merged: null }, + }; + o.security = { ...o.security, dependency: null }; + // Opened in the last two days, nothing merged: the trends have nothing to say yet. + const today = new Date(); + today.setUTCHours(0, 0, 0, 0); + o.trends = { + flow: Array.from({ length: 84 }, (_, i) => { + const back = 83 - i; + const total = back === 0 ? 3 : back <= 2 ? 1 : 0; + return { day: new Date(today.getTime() - back * D * 1000).toISOString().slice(0, 10), stages: back === 0 ? stages : back <= 2 ? { approved: 1 } : {}, total, unknown: 0 }; + }), + split_from: new Date(today.getTime() - 83 * D * 1000).toISOString().slice(0, 10), + merged: [], + cycle_days: 90, + flow_days: 84, + }; + o.stale = { ...o.stale, stale: 0, past_usual: 0, on_author: 0, on_reviewer: 0, abandoned: { count: 0, oldest_secs: null }, zombie: 0, drift: null, draft_p85_secs: null, archive_candidates: 0 }; + o.repos = [{ ...o.repos[0], repo, open: 3, stages, past_p85: 0, health: "healthy", why: "3 open, none past usual.", link: { overview: `repo=${repo}` } }]; + return o; +} + +/** About 300 open across 14 repos: the chart shows the oldest it can. */ +function big(): PrsOverview { + const o = overview("bad"); + const base = o.aging.dots; + const dots: OverviewDot[] = []; + for (let k = 0; k < 5; k++) { + for (const d of base) { + const number = d.number + 1000 * (k + 1); + dots.push({ ...d, number, key: `${d.repo}#${number}`, age_secs: Math.round(d.age_secs * (0.6 + 0.2 * k)) }); + } + } + o.aging = { ...o.aging, dots: dots.slice(0, 200), shown: 200, total: dots.length }; + o.open = dots.length; + o.strip = o.strip.map((c) => ({ ...c, count: c.count * 5, past_p85: (c.past_p85 ?? 0) * 5 })); + o.repos = o.repos.map((r) => ({ ...r, open: r.open * 5, past_p85: r.past_p85 * 5 })); + return o; +} + +export function sized(size: Size): PrsOverview { + if (size === "sparse") return sparse(); + if (size === "big") return big(); + return overview("normal"); +} diff --git a/dashboard/e2e/prs-overview.spec.ts b/dashboard/e2e/prs-overview.spec.ts index 0e9ab8a2..e923bb50 100644 --- a/dashboard/e2e/prs-overview.spec.ts +++ b/dashboard/e2e/prs-overview.spec.ts @@ -124,11 +124,13 @@ test("the repo table: health words with their rule, new columns, and a row opens const db = await open(page, "bad"); const rows = page.getByTestId("repo-row"); await expect(rows.first()).toHaveAttribute("data-health", "slipping"); + await expect(page.getByTestId("rollup-rule")).toBeHidden(); + await page.getByText("How health is decided").click(); await expect(page.getByTestId("rollup-rule")).toContainText("The org takes the worst state"); await expect(page.getByTestId("repo-flags").first()).not.toBeEmpty(); await page.getByTestId("repo-link").first().click(); await expect(page).toHaveURL(/\/prs\/overview\/?\?org=acme&repo=acme%2F/, { timeout: 60_000 }); - await expect(page.getByTestId("overview-repo-views")).toBeVisible(); + await expect(page.locator('[data-testid="overview-trends"]:visible')).toBeVisible(); await expect.poll(() => db.calls.some((c) => c.includes("/api/prs/overview?") && c.includes("repo=acme"))).toBe(true); }); @@ -169,8 +171,35 @@ test("not enough history yet: young data says so instead of a zero", async ({ pa await open(page, "young"); await expect(page.getByTestId("history-note")).toContainText("1 week"); await expect(page.getByTestId("not-yet").first()).toBeVisible(); - await expect(page.getByTestId("aging-external")).toBeVisible(); - await expect(page.getByTestId("aging-band").first()).toBeAttached(); + // The org has percentile lines of its own, so no external benchmark is drawn. + await expect(page.getByTestId("aging-line-p85")).toBeAttached(); + await expect(page.getByTestId("aging-band")).toHaveCount(0); +}); + +test("without lines of its own, an external benchmark is one thin dashed line, labeled as external", async ({ page }) => { + await open(page, () => { + const o = overview("young"); + o.thresholds = { ...o.thresholds, cycle: null, external: true }; + return o; + }); + await expect(page.getByTestId("aging-external")).toContainText("external benchmarks"); + const band = page.getByTestId("aging-band").first(); + await expect(band).toBeAttached(); + await expect(band.locator("line")).toHaveAttribute("stroke-width", "1"); + await expect(band.locator("line")).toHaveAttribute("stroke-dasharray", "3 3"); +}); + +test("a tooltip shows on hover or focus only, and the legend names only what is drawn", async ({ page }) => { + await open(page, "normal"); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + const dot = page.getByTestId("aging-dot").first(); + await dot.focus(); + await expect(page.getByRole("tooltip")).toBeVisible(); + await page.getByTestId("aging-select-past").focus(); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + // The normal week has no main blocked: its key isn't in the legend. + await expect(page.getByTestId("aging-legend").locator('[data-mark="blocked"]')).toHaveCount(0); + await expect(page.getByTestId("aging-legend").locator('[data-mark="person"]')).toBeVisible(); }); test("a backfill in progress shows how far it has read", async ({ page }) => { @@ -239,8 +268,8 @@ for (const width of [320, 375]) { test("the Security panel counts open alerts with no pull request and says code scanning needs its permission", async ({ page }) => { await open(page, "bad"); const sec = page.getByTestId("panel-security"); - await expect(sec.getByTestId("security-alerts")).toHaveText("crit 1 · high 2 · medi 4 · low 0"); - await expect(sec.getByTestId("security-alerts-text")).toContainText("Code scanning alerts need the security events permission."); + await expect(sec.getByTestId("security-alerts")).toHaveText("1 critical · 2 high · 4 medium"); + await expect(sec.getByTestId("security-code-scanning")).toHaveText("Code scanning alerts need the security events permission."); }); test("settings: the digest and nudges start off, sensitive paths save per repo, and an email digest needs an address", async ({ page }) => { @@ -270,3 +299,40 @@ test("settings: without agent settings they can be read but not changed", async await expect(page.getByTestId("prs-settings-sensitive")).toBeDisabled(); await expect(page.getByTestId("prs-settings-nudges")).toBeDisabled(); }); + +test("the trends: open PRs by stage over 12 weeks and every merge's cycle time, on the org page, with a card per day or point", async ({ page }) => { + await open(page, "normal"); + const flow = page.locator('[data-testid="stage-trend"]:visible'); + const cycle = page.locator('[data-testid="cycle-trend"]:visible'); + await expect(flow).toBeVisible(); + await expect(cycle).toBeVisible(); + await expect(page.locator('[data-testid="cycle-point"]:visible')).toHaveCount(overview("normal").trends!.merged.length); + await expect(page.locator('[data-testid="cycle-line-p85"]:visible')).toBeAttached(); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + const box = (await flow.boundingBox())!; + await flow.hover({ position: { x: box.width * 0.6, y: box.height / 2 } }); + await expect(page.getByTestId("stage-trend-tip")).toContainText("open"); + await page.mouse.move(0, 0); + await expect(page.locator('[role="tooltip"]')).toHaveCount(0); + await cycle.focus(); + await expect(page.getByTestId("cycle-trend-tip")).toBeVisible(); +}); + +test("a young org's stage split starts where the change log does, labeled, with totals before it", async ({ page }) => { + await open(page, "young"); + await expect(page.locator('[data-testid="stage-trend-split"]:visible')).toContainText("stage split from"); + await expect(page.locator('[data-testid="stage-trend-total"]:visible')).toBeAttached(); +}); + +test("a recorded number with too few events says so, not that history is missing", async ({ page }) => { + await open(page, () => { + const o = overview("normal"); + o.strip = o.strip.map((c) => (c.stage === "first_review" ? { ...c, delta: null } : c)); + o.missing = [...o.missing, { path: "strip.first_review.delta", reason: "few", text: "Too few yet: the change needs 10 or more pull requests in the stage." }]; + return o; + }); + const cell = page.locator('[data-testid="strip-cell"][data-stage="first_review"]:visible'); + await expect(cell.getByTestId("not-yet")).toHaveText("Too few to rate yet"); + await expect(cell.getByTestId("not-yet")).toHaveAttribute("title", /needs 10 or more/); + await expect(page.locator('[data-testid="strip-cell"][data-stage="draft"]:visible').getByTestId("not-yet")).toHaveCount(0); +}); diff --git a/dashboard/scripts/ui-lint.mjs b/dashboard/scripts/ui-lint.mjs index 9f18f820..967336e3 100644 --- a/dashboard/scripts/ui-lint.mjs +++ b/dashboard/scripts/ui-lint.mjs @@ -479,7 +479,7 @@ const TOKEN_FILES = new Set(["src/app/tokens.css", "src/lib/tokens.ts"]); * shell, lib/ and For you (src/app/foryou/, built on the tokens from the * start) are held to them. */ -const TOKENS_LATER = [/^src\/app\/(?!layout\.tsx$|not-found\.tsx$|globals\.css$|tokens\.css$|foryou\/)/]; +const TOKENS_LATER = [/^src\/app\/(?!layout\.tsx$|not-found\.tsx$|globals\.css$|tokens\.css$|foryou\/|prs\/)/]; const tokensLater = (rel) => TOKENS_LATER.some((re) => re.test(rel)); const SPACE_STEPS = new Set(["0", "px", "0.5", "1", "1.5", "2", "2.5", "3", "4", "5", "6", "8", "10", "12", "16", "20", "24", "auto", "full"]); const SPACE = /^-?(px|py|pt|pb|pl|pr|ps|pe|p|mx|my|mt|mb|ml|mr|ms|me|m|gap-x|gap-y|gap|space-x|space-y)-(.+)$/; diff --git a/dashboard/src/app/prs/detail.tsx b/dashboard/src/app/prs/detail.tsx index e8ebca76..0a5b4e76 100644 --- a/dashboard/src/app/prs/detail.tsx +++ b/dashboard/src/app/prs/detail.tsx @@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from "react"; import { api, ApiError, type PrDetail, type PrRow, type PrTimelineEvent } from "@/lib/api"; import { Chip, ShapeIcon, StatusText, Time, TONES, type Shape, type Tone } from "@/components/list"; import { ChevronRightIcon } from "@/components/icons"; +import { SectionHeading } from "@/components/page"; import { CoderHelmAvatar } from "@/components/support"; import { focusRing, linkButton, secondaryButton } from "@/components/ui"; import { actorWords, foldTimeline, isCoderHelm, ledgerLook, ledgerShares, longSecs, nextActor, RULE_WORDS, stateLook, type TimelineItem } from "./model"; @@ -130,7 +131,7 @@ export function PrDetailPanel({ onClick={onClose} aria-label="Close the pull request" aria-keyshortcuts="Escape" - className={`inline-flex h-11 min-w-11 shrink-0 items-center justify-center rounded-lg px-3 text-sm text-zinc-300 hover:bg-zinc-800 hover:text-zinc-100 ${focusRing}`} + className={`inline-flex h-11 min-w-11 shrink-0 items-center justify-center rounded-lg px-3 text-sm text-fg-secondary hover:bg-control hover:text-fg ${focusRing}`} > Close @@ -145,13 +146,13 @@ export function PrDetailPanel({ data-testid="pr-detail" className={ overlay - ? "fixed inset-0 z-40 overflow-y-auto overscroll-contain bg-zinc-950 p-4 sm:left-auto sm:w-[34rem] sm:border-l sm:border-zinc-800 sm:shadow-2xl" - : "sticky top-4 max-h-[calc(100dvh-2rem)] min-w-0 overflow-y-auto rounded-lg border border-zinc-800 bg-zinc-900/40 p-4" + ? "fixed inset-0 z-40 overflow-y-auto overscroll-contain bg-canvas p-4 sm:left-auto sm:w-[34rem] sm:border-l sm:border-line sm:shadow-2xl" + : "sticky top-4 max-h-[calc(100dvh-2rem)] min-w-0 overflow-y-auto rounded-lg border border-line bg-raised/40 p-4" } >
-

+

{repo}#{number} @@ -166,7 +167,7 @@ export function PrDetailPanel({ )}

-

+

{pr?.title || `${repo}#${number}`}

@@ -174,19 +175,19 @@ export function PrDetailPanel({
{missing ? ( -

+

This pull request isn't open in your team's repos any more, or it was never one of them.

) : ( <> {pr && ( -
+

{pr.next?.text}

-

- Next: {nextActor(pr, viewer)} +

+ Next: {nextActor(pr, viewer)} {pr.next?.rule && <> · {RULE_WORDS[pr.next.rule] ?? pr.next.rule}} {pr.next?.since && ( <> @@ -216,13 +217,13 @@ export function PrDetailPanel({ )} {error && ( -

+

Couldn't read this pull request: {error}

)} {!detail && !error && ( -

+

Reading the pull request…

)} @@ -243,7 +244,11 @@ export function PrDetailPanel({ } function SectionTitle({ children }: { children: React.ReactNode }) { - return

{children}

; + return ( + + {children} + + ); } function Checklist({ detail }: { detail: PrDetail }) { @@ -258,9 +263,9 @@ function Checklist({ detail }: { detail: PrDetail }) {
  • {m.words}: - + {c.text} - {c.source && ({RULE_WORDS[c.source] ?? c.source})} + {c.source && ({RULE_WORDS[c.source] ?? c.source})}
  • ); @@ -271,16 +276,16 @@ function Checklist({ detail }: { detail: PrDetail }) { } const BAR: Record = { - live: "bg-sky-400", - queued: "bg-sky-400/60", - waiting: "bg-amber-400", - attention: "bg-orange-400", - success: "bg-emerald-400", - merged: "bg-violet-400", - danger: "bg-red-400", - info: "bg-blue-400", - neutral: "bg-zinc-400", - muted: "bg-zinc-600", + live: "bg-info-solid", + queued: "bg-info-solid/60", + waiting: "bg-warn-solid", + attention: "bg-severe-solid", + success: "bg-good-solid", + merged: "bg-done-solid", + danger: "bg-bad-solid", + info: "bg-accent-solid", + neutral: "bg-fg-muted", + muted: "bg-line-emphasis", }; /** Who held the turn, for how long: one bar, and the same in words under it. */ @@ -291,16 +296,16 @@ function Ledger({ detail }: { detail: PrDetail }) { return (
    Wait ledger · open {longSecs(detail.ledger.open_secs)} -
    +
    {shares.map((s, i) => ( ))}
    -
      +
        {shares.map((s) => { const l = ledgerLook(s.who); return ( @@ -319,11 +324,11 @@ function EventLine({ e }: { e: PrTimelineEvent }) { const helm = isCoderHelm(e.actor, e.coderhelm); return (
      • - {helm ? :
      • ); } @@ -332,13 +337,13 @@ function RunBlock({ item }: { item: Extract }) { const [open, setOpen] = useState(item.status === "running"); const id = `run-${item.runId}`; return ( -
      • +
      • {open && ( -
        +
          {item.events.map((e, i) => ( @@ -377,7 +382,7 @@ function Timeline({ detail }: { detail: PrDetail }) { return (
          Timeline -
          +
          {FILTERS.map((f) => (
          {items.length === 0 ? ( -

          Nothing of this kind happened on it yet.

          +

          Nothing of this kind happened on it yet.

          ) : (
            {items.map((it, i) => @@ -414,7 +419,7 @@ function Links({ pr }: { pr: PrRow }) {
              {pr.links.map((l) => (
            • - {words[l.kind] ?? l.kind} + {words[l.kind] ?? l.kind} {l.url ? ( @@ -423,7 +428,7 @@ function Links({ pr }: { pr: PrRow }) { (opens in a new tab) ) : ( - + {l.repo}#{l.number} )} @@ -443,26 +448,26 @@ function People({ pr }: { pr: PrRow }) { People
              • - Author + Author {helmAuthor ? ( - + CoderHelm AI - {pr.for && for @{pr.for}} + {pr.for && for @{pr.for}} ) : ( - @{pr.author?.login} + @{pr.author?.login} )}
              • {people .filter((p) => p.login !== pr.author?.login) .map((p) => (
              • - {isCoderHelm(p.login, p.coderhelm) ? "CoderHelm" : `@${p.login}`} - {p.roles.join(", ")} + {isCoderHelm(p.login, p.coderhelm) ? "CoderHelm" : `@${p.login}`} + {p.roles.join(", ")}
              • ))} -
              • - Turn: {(pr.next?.from ?? []).map((w) => actorWords(w)).join(", ") || "nobody"} +
              • + Turn: {(pr.next?.from ?? []).map((w) => actorWords(w)).join(", ") || "nobody"}
          diff --git a/dashboard/src/app/prs/overview/charts.tsx b/dashboard/src/app/prs/overview/charts.tsx index 91a38645..1dfb6b1c 100644 --- a/dashboard/src/app/prs/overview/charts.tsx +++ b/dashboard/src/app/prs/overview/charts.tsx @@ -9,9 +9,10 @@ // Every mark carries its meaning in words or shape; colour only repeats it. import Link from "next/link"; -import { useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from "react"; +import { useEffect, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from "react"; import type { OverviewDot, OverviewPercentiles, PrStage, PrsOverview } from "@/lib/api"; -import { focusRing } from "@/components/ui"; +import { focusRing, smallSecondaryButton } from "@/components/ui"; +import { CHART } from "@/lib/tokens"; import { dur, durLong, STAGE_FILL, STAGES, stageLook, type Scope, prHref } from "./model"; /** A word-sized line of up to 8 weekly values; nothing when there are fewer than 2. */ @@ -32,21 +33,21 @@ export function Sparkline({ values, label, className = "" }: { values: number[] height={h} className={`shrink-0 overflow-visible ${className}`} > - - + + ); } /** A stacked bar of a repo's open pull requests by stage, each segment named. */ export function MixBar({ stages, open }: { stages: Partial>; open: number }) { - if (open <= 0) return none open; + if (open <= 0) return none open; const parts = STAGES.map((s) => ({ s, n: stages[s.stage] ?? 0 })).filter((p) => p.n > 0); const words = parts.map((p) => `${p.n} ${p.s.short.toLowerCase()}`).join(", "); return ( - + {parts.map((p) => ( - + ))} ); @@ -55,7 +56,7 @@ export function MixBar({ stages, open }: { stages: Partial +
            {STAGES.map((s) => (