Files
pipelines/app/tool/pipelines_probe_cdp.mjs
alan a44f31b989 feat(app): add native pipelines list and detail screen
Read-only Pipelines screen for the Flutter client:

- list_pipelines and list_runs with a last-run join, plus get_pipeline
  with an explicit version (0 = latest); no mutation requests.
- Name, run-presence, last-run-status and schedule filters; six sort
  orders; clear filters; truthful loading, empty and error states.
- Detail Summary, selectable Source and version history with selection
  and return to latest.
- Sequenced list/detail requests so stale replies cannot replace a newer
  selection or open a cleared one; refresh keeps the selected pipeline
  and version.
- Material controls on Android/desktop and Cupertino on iOS; a
  per-label segmented tab row at narrow widths and scaled text, with the
  native control kept wherever an equal share fits.
- Fixture probe entry and Chrome scripts for the rendered evidence;
  widget tests cover filters, sorting, formatting, sequencing, layout
  and the tab row.

Graph rendering remains P2: the Graph tab states that it is pending and
exposes a host hook. PipelinesScreen is not yet registered in the shell.

Evidence and limits: app/notes/P1.md.
2026-10-21 19:09:29 +01:00

133 lines
4.6 KiB
JavaScript

// Real-Chrome fixture probe for the Pipelines P1 screen.
//
// It serves a prebuilt Flutter web bundle, drives it through Chrome DevTools
// (accessibility tree + real mouse events), and writes PNGs and a JSON log.
// No live server, socket or operator data is involved.
//
// Usage: node tool/pipelines_probe_cdp.mjs <build-dir> <capture-dir>
import { mkdir, writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { tmpdir } from "node:os";
import {
connect,
launchChrome,
sleep,
startServer,
waitForPage,
waitForPort,
} from "./pipelines_probe_cdp_lib.mjs";
import {
assertName,
axNodes,
capture,
click,
clickAt,
dragSelect,
enableSemantics,
waitFor,
} from "./pipelines_probe_cdp_input.mjs";
const CHROME =
process.env.CHROME_PATH ??
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
const buildDir = resolve(process.argv[2] ?? "build/web");
const captureDir = resolve(process.argv[3] ?? "p1-captures");
const { server, url } = await startServer(buildDir);
await mkdir(captureDir, { recursive: true });
const profile = join(tmpdir(), `pipelines-p1-chrome-${process.pid}`);
const chrome = launchChrome(CHROME, profile, url);
let connection;
const log = { url, captures: [], checks: [], axSamples: [] };
try {
const devtoolsPort = await waitForPort(join(profile, "DevToolsActivePort"));
const target = await waitForPage(devtoolsPort);
connection = await connect(target.webSocketDebuggerUrl);
await connection.send("Page.enable");
await connection.send("Runtime.enable");
await connection.send("DOM.enable");
await connection.send("Accessibility.enable");
await connection.send("Emulation.setDeviceMetricsOverride", {
width: 1200,
height: 900,
deviceScaleFactor: 1,
mobile: false,
});
await waitFor(
() => connection.evaluate("document.querySelector('flutter-view') !== null"),
20000,
);
await sleep(1200);
await enableSemantics(connection);
const nodes = await axNodes(connection);
log.axSamples = nodes
.filter((node) => node.name?.value)
.slice(0, 40)
.map((node) => `${node.role?.value}: ${node.name.value}`);
await assertName(connection, "Release verification", "list row", log);
await capture(connection, captureDir, log, "01-list-desktop");
await click(connection, "Release verification");
await assertName(connection, "Content hash", "summary detail", log);
await capture(connection, captureDir, log, "02-detail-summary");
await click(connection, "Source");
await capture(connection, captureDir, log, "03-source-latest");
// Select the first source line with a real drag. The capture shows the
// browser's text selection, proving the source is selectable.
await dragSelect(connection, 500, 194, 880, 194);
await capture(connection, captureDir, log, "04-source-selection");
log.checks.push("source drag selection");
await click(connection, "Summary");
// The detail body is drawn on the canvas and Flutter's semantics tree omits
// its list rows in this build, so the v1 row is clicked at the fixture layout
// position for the fixed 1200x900 viewport.
await clickAt(connection, 620, 489);
await sleep(800);
await capture(connection, captureDir, log, "05-version-v1");
await click(connection, "Source");
await capture(connection, captureDir, log, "06-source-v1");
await connection.send("Emulation.setDeviceMetricsOverride", {
width: 390,
height: 844,
deviceScaleFactor: 1,
mobile: true,
});
await sleep(500);
await click(connection, "Back to pipelines");
await assertName(connection, "Release verification", "mobile list", log);
await capture(connection, captureDir, log, "07-list-390");
await click(connection, "Hotfix triage");
await assertName(connection, "Content hash", "mobile detail", log);
await capture(connection, captureDir, log, "08-detail-390");
await click(connection, "Back to pipelines");
await assertName(connection, "Release verification", "mobile list again", log);
await click(connection, "Filter");
await assertName(connection, "Filter pipelines", "mobile filter", log);
await capture(connection, captureDir, log, "09-filter-390");
} catch (error) {
log.error = String(error?.stack ?? error);
try {
const nodes = await axNodes(connection);
log.failureAx = nodes
.filter((node) => node.name?.value)
.map((node) => `${node.role?.value}: ${node.name.value}`)
.slice(0, 120);
} catch {
// The browser may already be gone; the error itself is still recorded.
}
process.exitCode = 1;
} finally {
await writeFile(join(captureDir, "probe.json"), JSON.stringify(log, null, 2));
connection?.close();
chrome.kill("SIGTERM");
server.close();
}