diff --git a/web/service/stovepipe/src/server/instrumentation.test.ts b/web/service/stovepipe/src/server/instrumentation.test.ts index afc39348e..3c2fe1946 100644 --- a/web/service/stovepipe/src/server/instrumentation.test.ts +++ b/web/service/stovepipe/src/server/instrumentation.test.ts @@ -6,12 +6,13 @@ import { instrumentStovepipeWeb } from "./instrumentation"; function createHostFixture() { const list = vi.fn().mockResolvedValue({ requests: [], nextPageToken: "" }); const listOpenIssues = vi.fn().mockResolvedValue({ issues: [], nextPageToken: "" }); + const listIssueHistory = vi.fn().mockResolvedValue({ events: [], nextPageToken: "" }); const getRequestHistoryByID = vi.fn().mockRejectedValue(new Error("private failure")); const getProjectStatusByID = vi.fn().mockRejectedValue(new Error("private failure")); const getIssuesByRequestID = vi.fn().mockRejectedValue(new Error("private failure")); const listRequestProjectsByIssue = vi.fn().mockRejectedValue(new Error("private failure")); const listRequestIssuesByProject = vi.fn().mockRejectedValue(new Error("private failure")); - const web = createStovepipeWeb({ queues: [{ name: "demo" }], service: { list, listOpenIssues, getRequestHistoryByID, getProjectStatusByID, getIssuesByRequestID, listRequestProjectsByIssue, listRequestIssuesByProject } }); + const web = createStovepipeWeb({ queues: [{ name: "demo" }], service: { list, listOpenIssues, listIssueHistory, getRequestHistoryByID, getProjectStatusByID, getIssuesByRequestID, listRequestProjectsByIssue, listRequestIssuesByProject } }); const record = vi.fn(); const add = vi.fn(); const span = { setAttribute: vi.fn(), setStatus: vi.fn(), recordException: vi.fn(), end: vi.fn() }; @@ -20,7 +21,7 @@ function createHostFixture() { const host = instrumentStovepipeWeb(web, { createHistogram, createCounter } as unknown as Meter, { startSpan: () => span } as unknown as Tracer); - return { host, list, listOpenIssues, web, record, add, span, createHistogram, createCounter }; + return { host, list, listOpenIssues, listIssueHistory, web, record, add, span, createHistogram, createCounter }; } describe("Stovepipe host instrumentation", () => { @@ -73,3 +74,13 @@ describe("Stovepipe host instrumentation", () => { expect(fixture.record).toHaveBeenCalledWith(expect.any(Number), { outcome: "exception" }); }); }); + +it("records a failed issue-history section as a failed page load", async () => { + const fixture = createHostFixture(); + fixture.listIssueHistory.mockRejectedValue(new Error("private history failure")); + const result = await fixture.host.handle({ path: "/demo", search: new URLSearchParams({ view: "issue-history", task: "test", unit: "" }) }); + expect(result).toMatchObject({ kind: "render", model: { kind: "issue-history", issueHistory: { ok: false } } }); + expect(fixture.add).toHaveBeenCalledWith(1, { outcome: "error" }); + expect(fixture.span.setStatus).toHaveBeenCalledWith({ code: SpanStatusCode.ERROR }); + expect(JSON.stringify(result)).not.toContain("private history failure"); +}); diff --git a/web/service/stovepipe/src/server/instrumentation.ts b/web/service/stovepipe/src/server/instrumentation.ts index ef7aaa0c8..651c0e719 100644 --- a/web/service/stovepipe/src/server/instrumentation.ts +++ b/web/service/stovepipe/src/server/instrumentation.ts @@ -17,7 +17,8 @@ export function instrumentStovepipeWeb( if (result.kind === "render") { const sections = result.model.kind === "queue" ? [result.model.requests] : result.model.kind === "issues" - ? [result.model.issues] : [result.model.history, result.model.projectStatus, result.model.requestIssues, result.model.issueProjects?.result, result.model.projectIssues?.result]; + ? [result.model.issues] : result.model.kind === "issue-history" + ? [result.model.issueHistory] : [result.model.history, result.model.projectStatus, result.model.requestIssues, result.model.issueProjects?.result, result.model.projectIssues?.result]; if (sections.some((section) => section != null && !section.ok)) { outcome = "error"; observeTelemetry(() => span?.setStatus({ code: SpanStatusCode.ERROR })); diff --git a/web/stovepipe/README.md b/web/stovepipe/README.md index 8b2c3525f..63b808b21 100644 --- a/web/stovepipe/README.md +++ b/web/stovepipe/README.md @@ -1,6 +1,6 @@ # Stovepipe web UI -A framework-neutral React UI for queue requests, open issues, and request details. The host supplies authentication, backend transport, routing adapters, and styling. +A framework-neutral React UI for queue requests, open issues, issue history, and request details. The host supplies authentication, backend transport, routing adapters, and styling. ## Host integration @@ -15,3 +15,4 @@ See the [shared package contract](../README.md#layers) for bundling requirements - Missing results are unknown, not green. Recording completion does not imply validation success. - Paginated listings are live, not snapshots. +- Issue history shows retained openings, repeat reports, and closures across requests, in recorded timestamp order rather than request ingest order. Older coverage may be incomplete. diff --git a/web/stovepipe/controller/issues.ts b/web/stovepipe/controller/issues.ts index bfeaf1638..3f44b09ba 100644 --- a/web/stovepipe/controller/issues.ts +++ b/web/stovepipe/controller/issues.ts @@ -1,6 +1,6 @@ import type { StovepipeService } from "../extension/service/index.js"; import type { StovepipePaths } from "../core/paths.js"; -import type { OpenIssuesModel, RequestIssuesModel, IssueProjectsModel } from "../entity/index.js"; +import type { OpenIssuesModel, RequestIssuesModel, IssueProjectsModel, IssueHistoryModel } from "../entity/index.js"; export async function loadOpenIssues( service: StovepipeService, @@ -20,6 +20,7 @@ export async function loadOpenIssues( firstSeenAtMs: issue.changedAtMs.toString(), requestId: issue.requestId, requestHref: paths.request(queue, issue.requestId), + historyHref: paths.issueHistory(queue, issue.taskId, issue.unitId), })), nextHref: result.nextPageToken ? paths.openIssues(queue, result.nextPageToken) : null, }; @@ -39,6 +40,7 @@ export async function loadRequestIssues( return { issues: result.issues.map(issue => ({ ...issue, + historyHref: paths.issueHistory(queue, issue.taskId, issue.unitId), projectsHref: issue.unitId && (issue.kind === "new" || issue.kind === "existing") ? paths.issueProjects(queue, requestId, issue.taskId, issue.unitId, pageToken) : null, })), @@ -70,3 +72,26 @@ export async function loadIssueProjects( nextHref: result.nextPageToken ? paths.issueProjects(queue, requestId, taskId, unitId, issuesPage, result.nextPageToken) : null, }; } + +export async function loadIssueHistory( + service: StovepipeService, + paths: StovepipePaths, + queue: string, + taskId: string, + unitId: string, + pageToken: string, + signal?: AbortSignal, +): Promise { + const result = await service.listIssueHistory( + { queue, taskId, unitId, pageSize: 50, pageToken }, signal ? { signal } : {}, + ); + return { + taskId, unitId, + events: result.events.map(event => ({ + ...event, timestampMs: event.timestampMs.toString(), + requestHref: event.requestId ? paths.requestIssues(queue, event.requestId) : null, + })), + firstHref: pageToken ? paths.issueHistory(queue, taskId, unitId) : null, + nextHref: result.nextPageToken ? paths.issueHistory(queue, taskId, unitId, result.nextPageToken) : null, + }; +} diff --git a/web/stovepipe/core/paths.ts b/web/stovepipe/core/paths.ts index ba15de27b..1f31dcd3e 100644 --- a/web/stovepipe/core/paths.ts +++ b/web/stovepipe/core/paths.ts @@ -20,6 +20,11 @@ export class StovepipePaths { if (page) search.set("page", page); return `${this.queue(queue)}?${search}`; } + issueHistory(queue: string, taskId: string, unitId: string, page = ""): string { + const search = new URLSearchParams({ view: "issue-history", task: taskId, unit: unitId }); + if (page) search.set("page", page); + return `${this.queue(queue)}?${search}`; + } requestIssues(queue: string, requestId: string, page = ""): string { const search = new URLSearchParams({ view: "issues" }); if (page) search.set("issues", page); diff --git a/web/stovepipe/entity/index.ts b/web/stovepipe/entity/index.ts index 5ecbd0622..2385daea9 100644 --- a/web/stovepipe/entity/index.ts +++ b/web/stovepipe/entity/index.ts @@ -38,6 +38,8 @@ export interface OpenIssueModel { taskId: string; /** Validation unit; empty identifies a task-wide failure. */ unitId: string; + /** Retained cross-request history for this task and unit. */ + historyHref: string; /** Opening time in Unix milliseconds as a decimal string. */ firstSeenAtMs: string; /** Request that established this opening. */ @@ -51,9 +53,28 @@ export interface OpenIssuesModel { /** Opaque continuation URL; null when no further row was observed. */ nextHref: string | null; } +export interface IssueHistoryModel { + /** Exact validation task selected for this history. */ + taskId: string; + /** Exact unit; empty means a task-wide issue. */ + unitId: string; + /** Retained occurrences in backend timestamp/build/event order. */ + events: { + event: string; + buildId: string; + timestampMs: string; + firstSeenBuildId: string; + requestId: string; + requestHref: string | null; + }[]; + /** First retained event page; null when already on it. */ + firstHref: string | null; + /** Opaque continuation URL; null on the final page. */ + nextHref: string | null; +} export interface RequestIssuesModel { /** Accepted issue updates on this page, not the queue's open-issue set. */ - issues: { taskId: string; unitId: string; kind: string; buildId: string; firstSeenBuildId: string; projectsHref: string | null }[]; + issues: { taskId: string; unitId: string; kind: string; buildId: string; firstSeenBuildId: string; projectsHref: string | null; historyHref: string }[]; /** Backend reconciliation status; completion does not imply a green build. */ status: string; /** First issue page for this request; null when already on it. */ @@ -169,6 +190,10 @@ export type StovepipePageModel = PageBase & kind: "issues"; issues: ReadResult; } + | { + kind: "issue-history"; + issueHistory: ReadResult; + } | { kind: "request"; requestId: string; diff --git a/web/stovepipe/extension/service/index.ts b/web/stovepipe/extension/service/index.ts index 776655be8..dcee914c5 100644 --- a/web/stovepipe/extension/service/index.ts +++ b/web/stovepipe/extension/service/index.ts @@ -80,6 +80,10 @@ export interface ProjectIssuePage { /** Hosts supply a transport client; the library has no generated-binding dependency. */ export interface StovepipeService { + listIssueHistory( + request: { queue: string; taskId: string; unitId: string; pageSize: number; pageToken: string }, + options?: { signal?: AbortSignal }, + ): Promise<{ events: { event: string; buildId: string; timestampMs: bigint; firstSeenBuildId: string; requestId: string }[]; nextPageToken: string }>; listRequestIssuesByProject( request: { queue: string; requestId: string; project: string; pageSize: number; pageToken: string }, options?: { signal?: AbortSignal }, diff --git a/web/stovepipe/module.test.ts b/web/stovepipe/module.test.ts index ce0cc08b2..b40dce5b8 100644 --- a/web/stovepipe/module.test.ts +++ b/web/stovepipe/module.test.ts @@ -22,6 +22,7 @@ const summary: RequestSummary = { }; function createPageTestContext(options: Pick = {}) { const service: StovepipeService = { + listIssueHistory: vi.fn().mockResolvedValue({ events: [], nextPageToken: "" }), listRequestIssuesByProject: vi.fn().mockResolvedValue({ attributions: [], attributionComplete: true, nextPageToken: "" }), listRequestProjectsByIssue: vi.fn().mockResolvedValue({ attributions: [], attributionComplete: true, nextPageToken: "" }), getIssuesByRequestID: vi.fn().mockResolvedValue({ issues: [], status: "complete", nextPageToken: "" }), @@ -89,6 +90,7 @@ describe("Stovepipe page loading", () => { issues: [{ taskId: "build/test", unitId: "", firstSeenAtMs: "9007199254740993", requestId: summary.requestId, requestHref: paths.request("repo/main", summary.requestId), + historyHref: paths.issueHistory("repo/main", "build/test", ""), }], nextHref: paths.openIssues("repo/main", "next+/="), } }, @@ -584,7 +586,7 @@ it("loads request issues only for their tab and preserves opaque continuation to expect(result).toMatchObject({ kind: "render", model: { kind: "request", requestIssues: { ok: true, data: { status: "in_progress", firstHref: paths.requestIssues("repo/main", summary.requestId), nextHref: paths.requestIssues("repo/main", summary.requestId, "next+/="), - issues: [{ taskId: "build/test", unitId: "//pkg:a", kind: "new" }], + issues: [{ taskId: "build/test", unitId: "//pkg:a", kind: "new", historyHref: paths.issueHistory("repo/main", "build/test", "//pkg:a") }], } } } }); }); @@ -664,3 +666,47 @@ it("rejects another project's association without hiding its recorded statuses", const result = await app.handle({ path: paths.request("repo/main", summary.requestId), search: new URLSearchParams({ project: "p" }) }); expect(result).toMatchObject({ kind: "render", model: { projectStatus: { ok: true }, projectIssues: { result: { ok: false } } } }); }); + +it.each(["", "//pkg:a/b?x=1#hash+%"])("loads retained history for the exact issue (%s) without unrelated reads", async unitId => { + const { app, service, paths } = createPageTestContext(); + const taskId = "build/test?variant=1"; + vi.mocked(service.listIssueHistory).mockResolvedValue({ events: [ + { event: "reported", buildId: "runner/7", timestampMs: 9007199254740993n, firstSeenBuildId: "runner/1", requestId: "7" }, + { event: "future", buildId: "expired", timestampMs: 1000n, firstSeenBuildId: "", requestId: "" }, + ], nextPageToken: "next+/=" }); + const url = new URL(paths.issueHistory("repo/main", taskId, unitId, "opaque+/="), "https://example.test"); + const signal = new AbortController().signal; + const result = await app.handle({ path: url.pathname, search: url.searchParams, signal }); + expect(service.listIssueHistory).toHaveBeenCalledWith( + { queue: "repo/main", taskId, unitId, pageSize: 50, pageToken: "opaque+/=" }, { signal }, + ); + expect(service.list).not.toHaveBeenCalled(); + expect(service.listOpenIssues).not.toHaveBeenCalled(); + expect(service.getRequestHistoryByID).not.toHaveBeenCalled(); + expect(service.getProjectStatusByID).not.toHaveBeenCalled(); + expect(result).toMatchObject({ kind: "render", model: { kind: "issue-history", issueHistory: { ok: true, data: { + taskId, unitId, firstHref: paths.issueHistory("repo/main", taskId, unitId), + nextHref: paths.issueHistory("repo/main", taskId, unitId, "next+/="), events: [ + { timestampMs: "9007199254740993", requestHref: paths.requestIssues("repo/main", "7") }, + { event: "future", requestHref: null }, + ], + } } } }); + expect(() => JSON.stringify(result)).not.toThrow(); +}); + +it("sanitizes issue history failures", async () => { + const { app, service, paths } = createPageTestContext(); + vi.mocked(service.listIssueHistory).mockRejectedValue(new Error("private history failure")); + const url = new URL(paths.issueHistory("repo/main", "task", ""), "https://example.test"); + const result = await app.handle({ path: url.pathname, search: url.searchParams }); + expect(result).toMatchObject({ kind: "render", model: { kind: "issue-history", issueHistory: { ok: false, error: expect.stringContaining("Unable to load issue history") } } }); + expect(JSON.stringify(result)).not.toContain("private history failure"); +}); + +it("requires a history task and authorizes the queue before reading history", async () => { + const { app, service, paths } = createPageTestContext(); + expect(await app.handle({ path: paths.queue("repo/main"), search: new URLSearchParams({ view: "issue-history" }) })).toEqual({ kind: "not-found" }); + const denied = createStovepipeWeb({ service, paths, queues: [{ name: "repo/main" }], authorize: () => false }); + expect(await denied.handle({ path: paths.queue("repo/main"), search: new URLSearchParams({ view: "issue-history", task: "task" }) })).toEqual({ kind: "forbidden" }); + expect(service.listIssueHistory).not.toHaveBeenCalled(); +}); diff --git a/web/stovepipe/module.ts b/web/stovepipe/module.ts index 37800a94a..27606772f 100644 --- a/web/stovepipe/module.ts +++ b/web/stovepipe/module.ts @@ -5,7 +5,7 @@ import type { Queue, StovepipePageModel } from "./entity/index.js"; import { parseProjectPageSize, StovepipePaths } from "./core/paths.js"; import { readSection } from "./controller/page.js"; import { loadQueueRequests } from "./controller/queue.js"; -import { loadOpenIssues, loadRequestIssues, loadIssueProjects } from "./controller/issues.js"; +import { loadOpenIssues, loadRequestIssues, loadIssueProjects, loadIssueHistory } from "./controller/issues.js"; import { loadRequestHistory, type BuildUrlResolver } from "./controller/request.js"; import { loadProjectStatus, loadProjectIssues } from "./controller/projects.js"; @@ -51,6 +51,10 @@ export function createStovepipeWeb(options: StovepipeWebOptions) { const route = parseStovepipeRoute(request.path, paths, options.queues); if (!route) return { kind: "not-found" }; const { queue, requestId } = route; + const issueHistoryView = !requestId && request.search.get("view") === "issue-history"; + const historyTask = request.search.get("task") ?? ""; + const historyUnit = request.search.get("unit") ?? ""; + if (issueHistoryView && !historyTask) return { kind: "not-found" }; const issuesView = !requestId && request.search.get("view") === "issues"; if (options.authorize && !(await options.authorize(request.principal, queue.name))) return { kind: "forbidden" }; @@ -64,10 +68,19 @@ export function createStovepipeWeb(options: StovepipeWebOptions) { href: issuesView ? paths.openIssues(queue.name) : paths.queue(queue.name), })), queueHref: paths.queue(queue.name), - latestHref: issuesView ? paths.openIssues(queue.name) : paths.queue(queue.name), - showLatestLink: Boolean(!requestId && request.search.get("page")), + latestHref: issueHistoryView ? paths.issueHistory(queue.name, historyTask, historyUnit) + : issuesView ? paths.openIssues(queue.name) : paths.queue(queue.name), + showLatestLink: Boolean(!requestId && !issueHistoryView && request.search.get("page")), loadedAtMs: Date.now(), }; + if (issueHistoryView) { + const issueHistory = await readSection( + () => loadIssueHistory(service, paths, queue.name, historyTask, historyUnit, + request.search.get("page") ?? "", request.signal), + onLog, "issue history", + ); + return { kind: "render", model: { ...common, kind: "issue-history", issueHistory } }; + } if (issuesView) { const issues = await readSection( () => loadOpenIssues(service, paths, queue.name, request.search.get("page") ?? "", request.signal), diff --git a/web/stovepipe/view/app.test.tsx b/web/stovepipe/view/app.test.tsx index 5d728cb48..3b55b4fac 100644 --- a/web/stovepipe/view/app.test.tsx +++ b/web/stovepipe/view/app.test.tsx @@ -98,7 +98,7 @@ it("shows a separate queue issues tab and retains successful issue data on refre const issuesModel: StovepipePageModel = { ...model, kind: "issues", key: "/repo%2Fmain?view=issues", latestHref: "/repo%2Fmain?view=issues", issues: { ok: true, data: { - issues: [{ taskId: "buildtest", unitId: "", firstSeenAtMs: "1000", requestId: "7", requestHref: "/repo%2Fmain/request/7" }], + issues: [{ taskId: "buildtest", unitId: "", firstSeenAtMs: "1000", requestId: "7", requestHref: "/repo%2Fmain/request/7", historyHref: "/history" }], nextHref: null, } }, }; @@ -116,7 +116,7 @@ it("retains issue data and auto-refresh when a cursor refresh fails on the first ...model, kind: "issues", key: "/repo%2Fmain?view=issues&page=cursor", latestHref: "/repo%2Fmain?view=issues", showLatestLink: true, issues: { ok: true, data: { - issues: [{ taskId: "buildtest", unitId: "", firstSeenAtMs: "1000", requestId: "7", requestHref: "/repo%2Fmain/request/7" }], + issues: [{ taskId: "buildtest", unitId: "", firstSeenAtMs: "1000", requestId: "7", requestHref: "/repo%2Fmain/request/7", historyHref: "/history" }], nextHref: null, } }, }; @@ -367,3 +367,21 @@ it("renders request issues and retains them on a same-page refresh failure", () expect(screen.getByRole("alert")).toHaveTextContent("Issues unavailable"); expect(screen.getByRole("status")).toHaveTextContent("Issue recording was abandoned"); }); + +it("shows retained issue history independently and retains only the same page on failure", () => { + const historyModel: StovepipePageModel = { + ...model, kind: "issue-history", key: "/repo%2Fmain?view=issue-history&task=test&unit=u", + issueHistory: { ok: true, data: { taskId: "test", unitId: "u", firstHref: null, nextHref: "/next", events: [ + { event: "reported", buildId: "build/7", timestampMs: "1000", firstSeenBuildId: "build/1", requestId: "7", requestHref: "/request/7?view=issues" }, + ] } }, + }; + const { rerender } = render(); + expect(screen.getByRole("table", { name: "Issue history events" })).toHaveTextContent("build/7"); + expect(screen.queryByRole("navigation", { name: "Request views" })).toBeNull(); + rerender(); + expect(screen.getByRole("alert")).toHaveTextContent("History unavailable"); + expect(screen.getByText("build/7")).toBeVisible(); + rerender(); + expect(screen.getByRole("alert")).toHaveTextContent("Next history unavailable"); + expect(screen.queryByText("build/7")).toBeNull(); +}); diff --git a/web/stovepipe/view/app.tsx b/web/stovepipe/view/app.tsx index 9da37191d..b00c1ba8f 100644 --- a/web/stovepipe/view/app.tsx +++ b/web/stovepipe/view/app.tsx @@ -9,7 +9,7 @@ import type { StovepipePageModel } from "../entity/index.js"; import { Link, Section } from "./components.js"; import { RequestDetails, History } from "./pages.js"; import { QueueRequests } from "./queue.js"; -import { OpenIssues, RequestIssues } from "./issues.js"; +import { OpenIssues, RequestIssues, IssueHistory } from "./issues.js"; import { ProjectResults, RecordedResult } from "./projects.js"; import { StovepipeLogo } from "./stovepipe-logo.js"; @@ -87,7 +87,7 @@ function Page({ model }: { model: StovepipePageModel }) { )} {model.kind !== "request" ? <> {model.queue} - {model.kind === "issues" ? "Open issues grouped by task." : "Requests ordered by acceptance time, newest first."} + {model.kind === "issues" ? "Open issues grouped by task." : model.kind === "issue-history" ? "Retained events for one issue across requests." : "Requests ordered by acceptance time, newest first."} : Request {model.requestId}} @@ -104,6 +104,12 @@ function Page({ model }: { model: StovepipePageModel }) {
{(data) => data && }
+ ) : model.kind === "issue-history" ? ( + +
+ {data => data && } +
+
) : model.kind === "issues" ? (
diff --git a/web/stovepipe/view/issues.test.tsx b/web/stovepipe/view/issues.test.tsx index 6f970ba43..0f104c238 100644 --- a/web/stovepipe/view/issues.test.tsx +++ b/web/stovepipe/view/issues.test.tsx @@ -1,13 +1,13 @@ import { act, cleanup, fireEvent, render, screen, waitFor, within } from "../../platform/test/rtl.js"; import { afterEach, expect, it, vi } from "vitest"; -import { OpenIssuePagesProvider, OpenIssues, RequestIssues } from "./issues.js"; +import { OpenIssuePagesProvider, OpenIssues, RequestIssues, IssueHistory } from "./issues.js"; import type { OpenIssueModel } from "../entity/index.js"; afterEach(cleanup); const taskWide: OpenIssueModel = { taskId: "buildtest", unitId: "", firstSeenAtMs: "1000", - requestId: "7", requestHref: "/queue/request/7", + requestId: "7", requestHref: "/queue/request/7", historyHref: "/history", }; const target = { ...taskWide, unitId: "//pkg:go_default_test" }; @@ -18,6 +18,7 @@ it("groups units under their task and distinguishes task-wide failures", () => { expect(rows[1]).toHaveTextContent("Task-wide failure"); expect(rows[2]).toHaveTextContent("//pkg:go_default_test"); expect(within(rows[2]!).getByRole("link", { name: "7" })).toHaveAttribute("href", "/queue/request/7"); + expect(within(rows[1]!).getByRole("link", { name: "View history" })).toHaveAttribute("href", "/history"); expect(screen.getByRole("status")).toHaveTextContent("3 issues loaded"); }); @@ -189,14 +190,15 @@ it("does not loop when a continuation repeats", async () => { it("groups request updates into new, existing and resolved without hiding unknown kinds", () => { render(); expect(screen.getByRole("table", { name: "New Issues" })).toHaveTextContent("//pkg:new"); expect(screen.getByRole("table", { name: "Existing Issues" })).toHaveTextContent("//pkg:existing"); expect(screen.getByRole("table", { name: "Resolved Issues" })).toHaveTextContent("Task-wide failure"); + expect(within(screen.getByRole("table", { name: "Resolved Issues" })).getByRole("link", { name: "View history" })).toHaveAttribute("href", "/history"); expect(screen.getByRole("table", { name: "Other Issues" })).toHaveTextContent("//pkg:unknown"); expect(screen.getByRole("link", { name: "Next issues →" })).toHaveAttribute("href", "/next"); }); @@ -216,7 +218,7 @@ it.each([ it.each([false, true])("distinguishes incomplete attribution from an empty completed project list (%s)", complete => { render(); @@ -226,7 +228,7 @@ it.each([false, true])("distinguishes incomplete attribution from an empty compl it("shows paginated affected projects and keeps the collapse action on failure", () => { const model = { status: "complete", firstHref: null, nextHref: null, issues: [ - { taskId: "test", unitId: "unit", kind: "existing", buildId: "build/7", firstSeenBuildId: "build/7", projectsHref: "/projects" }, + { taskId: "test", unitId: "unit", kind: "existing", buildId: "build/7", firstSeenBuildId: "build/7", projectsHref: "/projects", historyHref: "/history" }, ] }; const selection = { taskId: "test", unitId: "unit", key: "selection", closeHref: "/issues" }; const { rerender } = render( { + render( ({ + event, buildId: `build/${index}`, timestampMs: "1000", firstSeenBuildId: index ? "build/0" : "", + requestId: index ? "7" : "", requestHref: index ? "/request/7?view=issues" : null, + })), + }} />); + const table = screen.getByRole("table", { name: "Issue history events" }); + const rows = within(table).getAllByRole("row"); + expect(rows).toHaveLength(6); + expect(rows[1]).toHaveTextContent("Opened / reopened"); + expect(rows[1]).toHaveTextContent("Unknown"); + expect(rows[1]).toHaveTextContent("Not retained"); + expect(rows[2]).toHaveTextContent("Reported again"); + expect(within(rows[2]!).getByRole("link", { name: "7" })).toHaveAttribute("href", "/request/7?view=issues"); + expect(rows[3]).toHaveTextContent("Closed"); + expect(rows[4]).toHaveTextContent("Opened / reopened"); + expect(rows[5]).toHaveTextContent("future"); + expect(screen.getByRole("link", { name: "First events" })).toHaveAttribute("href", "/first"); + expect(screen.getByRole("link", { name: "Next events →" })).toHaveAttribute("href", "/next"); + expect(screen.getByText(/Older history may be incomplete/)).toBeVisible(); +}); + +it("does not mistake empty retained task-wide history for absence of an issue", () => { + render(); + expect(screen.getByText("Task-wide failure")).toBeVisible(); + expect(screen.getByText(/This does not establish that the issue never existed/)).toBeVisible(); + expect(screen.queryByRole("table")).toBeNull(); + expect(screen.queryByRole("link")).toBeNull(); +}); diff --git a/web/stovepipe/view/issues.tsx b/web/stovepipe/view/issues.tsx index c20493804..7a03ffbcc 100644 --- a/web/stovepipe/view/issues.tsx +++ b/web/stovepipe/view/issues.tsx @@ -7,7 +7,7 @@ import { Button, SIZE } from "baseui/button"; import { StyledTableBodyCell, StyledTableBodyRow } from "baseui/table-semantic"; import { Tag } from "baseui/tag"; import { HeadingSmall, ParagraphSmall } from "baseui/typography"; -import type { OpenIssueModel, OpenIssuesModel, RequestIssuesModel, IssueProjectsSelection } from "../entity/index.js"; +import type { OpenIssueModel, OpenIssuesModel, RequestIssuesModel, IssueProjectsSelection, IssueHistoryModel } from "../entity/index.js"; import { Link, Table, Section } from "./components.js"; export type OpenIssuePageLoader = (href: string, signal: AbortSignal) => Promise; @@ -67,13 +67,14 @@ export function OpenIssues({ initial }: { initial: OpenIssuesModel }) { } {[...tasks].map(([task, issues]) => {task} - +
{issues.map(issue => {issue.unitId ? {issue.unitId} : Task-wide failure} {issue.firstSeenAtMs === "0" ? "Unknown" : } {issue.requestId} + View history )}
)} @@ -111,7 +112,7 @@ export function RequestIssues({ model, projects }: { model: RequestIssuesModel; ? !["new", "existing", "closed"].includes(issue.kind) : issue.kind === group.kind); return {group.label} - {issues.length ? + {issues.length ?
{issues.map(issue => { const selected = projects?.taskId === issue.taskId && projects.unitId === issue.unitId ? projects : null; return @@ -122,8 +123,9 @@ export function RequestIssues({ model, projects }: { model: RequestIssuesModel; {issue.firstSeenBuildId || "Unknown"} {issue.buildId || "Unknown"} {issue.projectsHref ? {selected ? "Hide projects" : "Show projects"} : "Not available"} + View history - {selected && + {selected &&
{page => page &&
{!page.complete ? Project attribution is not available yet or did not complete. : page.projects.length ?
    {page.projects.map(project =>
  • {project}
  • )}
@@ -145,3 +147,30 @@ export function RequestIssues({ model, projects }: { model: RequestIssuesModel; ; } + +export function IssueHistory({ model }: { model: IssueHistoryModel }) { + return
+ Issue history + +
Task
{model.taskId} +
Unit
{model.unitId + ? {model.unitId} : Task-wide failure} +
+ Retained events across requests, oldest recorded timestamp first. Timestamp ties use build ID and event order, not request chronology. Open events include reopenings. + Older history may be incomplete. Late events can appear on earlier pages; return to the first page to refresh coverage. + {model.events.length ?
+ {model.events.map(event => + + {event.event === "open" ? "Opened / reopened" : event.event === "reported" ? "Reported again" : event.event === "closed" ? "Closed" : event.event} + {event.buildId} + {event.firstSeenBuildId || "Unknown"} + {event.requestHref + ? {event.requestId} : "Not retained"} + )} +
: No retained issue events on this page. This does not establish that the issue never existed.} + + {model.firstHref && First events} + {model.nextHref && Next events →} + +
; +} diff --git a/web/stovepipe/view/styles.css b/web/stovepipe/view/styles.css index 7746378f1..35225e4ad 100644 --- a/web/stovepipe/view/styles.css +++ b/web/stovepipe/view/styles.css @@ -3,7 +3,7 @@ .sq-stovepipe-open-issues table { table-layout: fixed; width: 100%; - min-width: 40rem; + min-width: 48rem; } .sq-stovepipe-open-issues th:nth-child(2) { @@ -67,7 +67,7 @@ .sq-stovepipe-request-issues table { table-layout: fixed; width: 100%; - min-width: 58rem; + min-width: 66rem; } .sq-stovepipe-request-issues th:first-child { @@ -85,3 +85,30 @@ .sq-stovepipe-request-view[aria-label="Project Results"] table[aria-label="Recorded project results"] > thead th:nth-child(4) { width: 8rem; } + +.sq-stovepipe-open-issues th:last-child, +.sq-stovepipe-request-issues th:last-child { + width: 8rem; +} + +.sq-stovepipe-issue-history table { + table-layout: fixed; + width: 100%; + min-width: 60rem; +} + +.sq-stovepipe-issue-history th:first-child { + width: 17rem; +} + +.sq-stovepipe-issue-history th:nth-child(2) { + width: 12rem; +} + +.sq-stovepipe-issue-history th:last-child { + width: 8rem; +} + +.sq-stovepipe-issue-history td { + overflow-wrap: anywhere; +} diff --git a/web/test/e2e/stovepipe/run_e2e.py b/web/test/e2e/stovepipe/run_e2e.py index 1cd969632..82475ed58 100644 --- a/web/test/e2e/stovepipe/run_e2e.py +++ b/web/test/e2e/stovepipe/run_e2e.py @@ -121,6 +121,19 @@ def _pagination_fixture_sql() -> str: f"INSERT INTO {table} (queue,request_id,task_id,unit_id,project) " f"VALUES ('web/pagination','51','expensive','//packages/extra-{i:02d}:test','project-01');" ) + for i in range(53): + statements.append( + "INSERT INTO build (queue,id,request_id,status,version) " + f"VALUES ('web/pagination','history/build/{i:02d}','{51 if i % 2 == 0 else 50}','failed',1);" + ) + for unit, count in (("", 53), ("//packages/test-01:go_default_test", 4)): + for i in range(count): + event = "open" if i in (0, count - 1) else "closed" if i == count - 2 else "reported" + opening = i if event == "open" else 0 + statements.append( + "INSERT INTO issue_log (queue,task_id,unit_id,build_id,event,timestamp_ms,first_seen_build_id) " + f"VALUES ('web/pagination','buildtest','{unit}','history/build/{i:02d}','{event}',{4000+i},'history/build/{opening:02d}');" + ) closed_issue_count = 500 for i in range(closed_issue_count + 1): closed = i < closed_issue_count diff --git a/web/test/e2e/stovepipe/stovepipe.spec.ts b/web/test/e2e/stovepipe/stovepipe.spec.ts index 27a916577..df5ea0acb 100644 --- a/web/test/e2e/stovepipe/stovepipe.spec.ts +++ b/web/test/e2e/stovepipe/stovepipe.spec.ts @@ -30,6 +30,24 @@ test.describe("server-rendered styling", () => { await expect(page.getByRole("heading", { name: "expensive", exact: true })).toBeVisible(); await expect(page.getByRole("link", { name: "First page", exact: true })).toHaveAttribute("href", "/web%2Fpagination?view=issues"); }); + test("browses issue history across requests without JavaScript", async ({ page }) => { + await page.goto("/web%2Fpagination?view=issues"); + await page.getByRole("table", { name: "Issues for buildtest" }).locator("tbody tr").first().getByRole("link", { name: "View history" }).click(); + const table = page.getByRole("table", { name: "Issue history events" }); + await expect(table.locator("tbody tr")).toHaveCount(50); + await expect(table).toContainText("Reported again"); + await expect(page.getByText("Task-wide failure", { exact: true })).toBeVisible(); + await page.getByRole("link", { name: "Next events →" }).click(); + await expect(table.locator("tbody tr")).toHaveCount(3); + await expect(table).toContainText("Closed"); + await expect(table).toContainText("Opened / reopened"); + await page.reload(); + await expect(table.locator("tbody tr")).toHaveCount(3); + await page.getByRole("link", { name: "First events", exact: true }).click(); + await expect(table.locator("tbody tr")).toHaveCount(50); + await table.getByRole("link", { name: "51", exact: true }).first().click(); + await expect(page.getByRole("table", { name: "Existing Issues" })).toBeVisible(); + }); test("renders request status and views without JavaScript", async ({ page }) => { await page.goto("/web%2Fpagination/request/51"); const status = page.getByRole("region", { name: "Request status" }); @@ -693,3 +711,28 @@ test("retains project paging across views and resets the cursor when page size c await expect(rows).toHaveCount(51); expect(new URL(page.url()).searchParams.get("projectPageSize")).toBe("100"); }); + + +test("opens unit history from request issues with shareable URLs and accessible tables", async ({ page }) => { + await page.goto("/web%2Fpagination/request/51?view=issues"); + const row = page.getByRole("table", { name: "Existing Issues" }).getByRole("row").filter({ hasText: "//packages/test-01:go_default_test" }); + await row.getByRole("link", { name: "View history" }).click(); + await expect(page).toHaveURL(/view=issue-history/); + const url = new URL(page.url()); + expect(url.searchParams.get("task")).toBe("buildtest"); + expect(url.searchParams.get("unit")).toBe("//packages/test-01:go_default_test"); + const table = page.getByRole("table", { name: "Issue history events" }); + await expect(table.locator("tbody tr")).toHaveCount(4); + await expect(table).toContainText("Closed"); + await expect(table).toContainText("Reported again"); + await expect(page.getByRole("link", { name: "Next events →" })).toHaveCount(0); + const accessibility = await new AxeBuilder({ page }).analyze(); + expect(accessibility.violations).toEqual([]); + await page.screenshot({ path: test.info().outputPath("issue-history-desktop.png") }); + await page.setViewportSize({ width: 390, height: 844 }); + await expect(table).toBeVisible(); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true); + await page.screenshot({ path: test.info().outputPath("issue-history-mobile.png") }); + await page.goBack(); + await expect(row).toBeVisible(); +}); diff --git a/web/test/package/react18/react18-runtime.test.mjs b/web/test/package/react18/react18-runtime.test.mjs index 9b9d6bda6..13914976f 100644 --- a/web/test/package/react18/react18-runtime.test.mjs +++ b/web/test/package/react18/react18-runtime.test.mjs @@ -49,6 +49,9 @@ test("renders and hydrates packaged pages with React 18 and host themes", { time } const stovepipe = createStovepipeWeb({ queues: [{ name: "repo/main" }], service: { + listIssueHistory: async () => ({ events: [ + { event: "reported", buildId: "build/2", timestampMs: 200n, firstSeenBuildId: "build/1", requestId: "1" }, + ], nextPageToken: "" }), getIssuesByRequestID: async () => ({ issues: [ { taskId: "buildtest", unitId: "unit-1", kind: "new", buildId: "build/1", firstSeenBuildId: "build/1" }, ], status: "complete", nextPageToken: "" }), @@ -63,7 +66,7 @@ test("renders and hydrates packaged pages with React 18 and host themes", { time }), getRequestHistoryByID: async () => ({ requestSummary: { requestId: "1", queue: "repo/main", changeUri: "git://repo/main/sha", baseUri: "", requestState: "accepted", stateUpdatedAtMs: 100n, acceptedAtMs: 100n, outcomeReason: "", projectCount: 0, brokenProjectCount: 0 }, events: [] }), } }); - for (const href of ["/repo%2Fmain", "/repo%2Fmain/request/1", "/repo%2Fmain/request/1?view=history", "/repo%2Fmain/request/1?view=issues", "/repo%2Fmain/request/1?view=issues&issueTask=buildtest&issueUnit=unit-1", "/repo%2Fmain/request/1?project=example-project"]) { + for (const href of ["/repo%2Fmain?view=issue-history&task=buildtest&unit=unit-1", "/repo%2Fmain", "/repo%2Fmain/request/1", "/repo%2Fmain/request/1?view=history", "/repo%2Fmain/request/1?view=issues", "/repo%2Fmain/request/1?view=issues&issueTask=buildtest&issueUnit=unit-1", "/repo%2Fmain/request/1?project=example-project"]) { const url = new URL(href, "https://submitqueue.test"); const result = await stovepipe.handle({ path: url.pathname, search: url.searchParams }); assert.equal(result.kind, "render");