Merge branch 'main' into theme
This commit is contained in:
+307
-10
@@ -15,6 +15,9 @@
|
||||
// real runs and chat session. The default run never sends a `submit`: the live
|
||||
// server's pipeline list is never mutated.
|
||||
//
|
||||
// `--viewer` drives ONLY R8's deterministic markdown/text viewer fixture (no
|
||||
// dependency on the operator's current run history) and captures 44–48.
|
||||
//
|
||||
// `--decide` drives ONLY R11's live human-decision flow: it reuses an existing
|
||||
// entry-stage human pipeline or submits one uniquely named create-only
|
||||
// definition, starts two throwaway runs in fresh temp workspaces, and presses
|
||||
@@ -82,14 +85,16 @@ const scratch = process.argv.includes("--scratch");
|
||||
const notifyOnly = process.argv.includes("--notify");
|
||||
// Focused R11 evidence only; the one explicit mode allowed to submit a pipeline.
|
||||
const decideOnly = process.argv.includes("--decide");
|
||||
// Focused R8 evidence only: the deterministic markdown viewer fixture, with no
|
||||
// dependency on the operator's current run history.
|
||||
const viewerOnly = process.argv.includes("--viewer");
|
||||
|
||||
// The page must connect through its own proxy (the server rejects a cross-origin
|
||||
// upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL
|
||||
// field at the real Pipelines server after connecting so artifact tiles and the
|
||||
// viewer resolve to real files; that is exactly the URL a correctly configured
|
||||
// page would carry.
|
||||
const artifactServerUrl = `ws://${pipelines}/connect`;
|
||||
const pipelineUrl = artifactServerUrl;
|
||||
// Artifact URLs resolve against the configured server. Point them at the page's
|
||||
// own proxy origin (serve.mjs forwards /artifacts/ and /connect), so the viewer's
|
||||
// markdown fetch and the image/video tiles are same-origin exactly as they are
|
||||
// in a correctly configured deployment.
|
||||
const artifactServerUrl = `ws://127.0.0.1:${port}/connect`;
|
||||
const pipelineUrl = `ws://${pipelines}/connect`;
|
||||
|
||||
const shots = [];
|
||||
let serve = null;
|
||||
@@ -1670,6 +1675,292 @@ async function runNotificationChecks() {
|
||||
);
|
||||
}
|
||||
|
||||
// --- R8: the markdown-first artifact viewer --------------------------------
|
||||
// A deterministic synthetic run served by the page's own static origin. The run
|
||||
// is injected over the real get_run command (never a new protocol field): its
|
||||
// ordinary artifacts include the stage-turn names and a small media+markdown
|
||||
// list, so the gallery, the viewer, keyboard paging, the backdrop and the honest
|
||||
// failure path are exercised without depending on whatever history the operator
|
||||
// currently has (the live fixture may be wiped between runs).
|
||||
const VIEWER_FIXTURE_RUN_ID = 990001;
|
||||
|
||||
function viewerFixtureRun() {
|
||||
const fixture = (name, contentType, url) => ({
|
||||
name,
|
||||
content_type: contentType,
|
||||
size_bytes: 96,
|
||||
url,
|
||||
});
|
||||
return {
|
||||
id: VIEWER_FIXTURE_RUN_ID,
|
||||
pipeline_id: 1,
|
||||
version: 1,
|
||||
name: "Viewer fixture",
|
||||
title: "Markdown viewer fixture",
|
||||
status: "succeeded",
|
||||
executing: false,
|
||||
outcome: "success",
|
||||
current_stage: "",
|
||||
content_hash: "viewerfixture",
|
||||
created_at: "2026-10-19T20:00:00Z",
|
||||
finished_at: "2026-10-19T20:01:00Z",
|
||||
completed_steps: 1,
|
||||
diagnostic: "",
|
||||
resource_wait: null,
|
||||
input: { prompt: "Render the stage turn." },
|
||||
output: { result: "ready" },
|
||||
graph: {
|
||||
stages: [
|
||||
{ key: "implementer", type: "model", edges: { success: "#success" }, prompt: "Render." },
|
||||
],
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
sequence: 1,
|
||||
stage: "implementer",
|
||||
status: "completed",
|
||||
outcome: "success",
|
||||
target: "#success",
|
||||
diagnostic: "",
|
||||
session_id: "",
|
||||
agent_active: false,
|
||||
control: { visit: 1, max_visits: 1 },
|
||||
started_at: "2026-10-19T20:00:00Z",
|
||||
finished_at: "2026-10-19T20:01:00Z",
|
||||
input: { prompt: "Render the stage turn." },
|
||||
output: { result: "ready" },
|
||||
artifacts: [
|
||||
fixture("input.md", "text/markdown; charset=utf-8", "/test/fixtures/artifacts/input.md"),
|
||||
fixture("shot.png", "image/png", "/test/fixtures/artifacts/shot.png"),
|
||||
fixture("memory.md", "text/plain; charset=utf-8", "/test/fixtures/artifacts/memory.md"),
|
||||
fixture("output.md", "text/markdown; charset=utf-8", "/test/fixtures/artifacts/output.md"),
|
||||
// Deliberately absent from the static origin: the viewer must show the
|
||||
// honest fetch failure, not an empty or invented document.
|
||||
fixture("missing.txt", "text/plain; charset=utf-8", "/test/fixtures/artifacts/missing.txt"),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** The visible gallery tiles' stable metadata and document marking. */
|
||||
async function viewerTiles(scope) {
|
||||
return page.evaluate(`[...document.querySelectorAll(${JSON.stringify(scope)} + " .artifact-tile")].map((tile) => ({
|
||||
name: tile.getAttribute("data-artifact-name") ?? "",
|
||||
kind: tile.getAttribute("data-artifact-kind") ?? "",
|
||||
label: tile.querySelector(".artifact-kind")?.textContent ?? "",
|
||||
glyph: !!tile.querySelector(".artifact-doc-glyph"),
|
||||
}))`);
|
||||
}
|
||||
|
||||
async function runMarkdownViewerChecks() {
|
||||
step("R8: the deterministic markdown/text stage-turn fixture run");
|
||||
const fixture = viewerFixtureRun();
|
||||
// This init script only answers get_run for the fixture id: every other frame
|
||||
// (the socket, the real list, the operator's own data) still goes to the server.
|
||||
await page.addInitScript(`(() => {
|
||||
window.__viewerFixtureRun = ${JSON.stringify(fixture)};
|
||||
window.__pipelinesIntercept = (frame) => (
|
||||
frame.type === "get_run" && frame.run_id === ${VIEWER_FIXTURE_RUN_ID}
|
||||
? { id: frame.id, type: "run_detail", run_detail: window.__viewerFixtureRun }
|
||||
: null
|
||||
);
|
||||
})()`);
|
||||
await openDeepLink(`/runs/${VIEWER_FIXTURE_RUN_ID}`);
|
||||
await page.waitForSelector("#detailTitle", { timeout: 20000 });
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${VIEWER_FIXTURE_RUN_ID} ") ?? false`,
|
||||
),
|
||||
{ timeout: 20000, what: "the markdown fixture run detail to load" },
|
||||
);
|
||||
|
||||
step("R8: the run gallery shows input.md, memory.md and output.md as Documents");
|
||||
await page.clickText(".run-detail .section-toggle", "Artifacts");
|
||||
await page.waitForSelector('.run-detail .artifact-gallery .artifact-tile[data-artifact-name="input.md"]', {
|
||||
timeout: 15000,
|
||||
});
|
||||
const runTiles = await viewerTiles(".run-detail .artifact-gallery");
|
||||
for (const name of ["input.md", "memory.md", "output.md"]) {
|
||||
const tile = runTiles.find((entry) => entry.name === name);
|
||||
if (!tile) throw new Error(`the run gallery is missing ${name}: ${JSON.stringify(runTiles)}`);
|
||||
if (tile.kind !== "Document" || tile.label !== "Document" || !tile.glyph) {
|
||||
throw new Error(`${name} is not presented as a Document: ${JSON.stringify(tile)}`);
|
||||
}
|
||||
}
|
||||
const runImage = runTiles.find((entry) => entry.name === "shot.png");
|
||||
if (!runImage || runImage.kind !== "Image" || runImage.glyph) {
|
||||
throw new Error(`shot.png is not presented as media: ${JSON.stringify(runImage)}`);
|
||||
}
|
||||
console.log(` run gallery: ${runTiles.map((tile) => `${tile.name} (${tile.label})`).join(", ")}`);
|
||||
await shot("44-viewer-turn-documents.png");
|
||||
|
||||
step("R8: the per-visit gallery presents the same turn documents");
|
||||
await clickDetailTab("Timeline");
|
||||
await page.click('.detail .timeline-row[data-stage-key="implementer"]');
|
||||
await page.waitForSelector(".stage-pane", { timeout: 15000 });
|
||||
await page.clickText(".stage-pane .section-toggle", "Artifacts");
|
||||
await page.waitForSelector('.stage-pane .artifact-tile[data-artifact-name="input.md"]', { timeout: 15000 });
|
||||
const visitTiles = await viewerTiles(".stage-pane");
|
||||
for (const name of ["input.md", "memory.md", "output.md"]) {
|
||||
const tile = visitTiles.find((entry) => entry.name === name);
|
||||
if (!tile || tile.kind !== "Document" || tile.label !== "Document" || !tile.glyph) {
|
||||
throw new Error(`the visit gallery does not present ${name} as a Document: ${JSON.stringify(tile)}`);
|
||||
}
|
||||
}
|
||||
console.log(` visit gallery: ${visitTiles.map((tile) => tile.name).join(", ")}`);
|
||||
|
||||
step("R8: opening input.md renders the fetched markdown in the viewer");
|
||||
await page.click('.stage-pane .artifact-tile[data-artifact-name="input.md"]');
|
||||
await page.waitForSelector(".artifact-viewer .viewer-panel", { timeout: 15000 });
|
||||
await page.waitForSelector(".viewer-markdown h3.md-heading", { timeout: 15000 });
|
||||
const rendered = await page.evaluate(`(() => {
|
||||
const viewer = document.querySelector(".artifact-viewer");
|
||||
const heading = viewer?.querySelector(".viewer-markdown h3.md-heading");
|
||||
const code = viewer?.querySelector(".viewer-markdown .md-code-block pre code");
|
||||
const fetched = performance.getEntriesByType("resource").map((entry) => entry.name)
|
||||
.filter((name) => name.endsWith("/test/fixtures/artifacts/input.md"));
|
||||
return {
|
||||
heading: heading?.textContent ?? "",
|
||||
code: code?.textContent ?? "",
|
||||
fetched: fetched.length,
|
||||
position: viewer?.querySelector(".viewer-position")?.textContent ?? "",
|
||||
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
|
||||
prevDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="prev"]')?.disabled ?? null,
|
||||
nextDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="next"]')?.disabled ?? null,
|
||||
hasPanel: !!viewer?.querySelector(".viewer-panel"),
|
||||
};
|
||||
})()`);
|
||||
if (rendered.heading !== "Turn input" || !rendered.code.includes("go test ./...")) {
|
||||
throw new Error(`the markdown did not render through the page renderer: ${JSON.stringify(rendered)}`);
|
||||
}
|
||||
if (!rendered.hasPanel || rendered.title !== "input.md" || !rendered.position.startsWith("1 of 5")) {
|
||||
throw new Error(`the viewer head/position is wrong: ${JSON.stringify(rendered)}`);
|
||||
}
|
||||
if (rendered.fetched < 1) {
|
||||
throw new Error(`the viewer did not fetch the resolved artifact url: ${JSON.stringify(rendered)}`);
|
||||
}
|
||||
if (rendered.prevDisabled !== true || rendered.nextDisabled !== false) {
|
||||
throw new Error(`the first artifact's paging state is wrong: ${JSON.stringify(rendered)}`);
|
||||
}
|
||||
console.log(
|
||||
` rendered "${rendered.heading}" with fenced code (${rendered.code.trim().split("\n")[0]}); ${rendered.position}`,
|
||||
);
|
||||
await shot("45-viewer-markdown-rendered.png");
|
||||
|
||||
step("R8: ArrowRight advances to the next artifact, ArrowLeft returns");
|
||||
await page.evaluate(
|
||||
`document.activeElement?.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".artifact-viewer .viewer-position")?.textContent?.startsWith("2 of 5") ?? false`,
|
||||
),
|
||||
{ timeout: 10000, what: "ArrowRight to advance the viewer" },
|
||||
);
|
||||
const advanced = await page.evaluate(`(() => {
|
||||
const viewer = document.querySelector(".artifact-viewer");
|
||||
const image = viewer?.querySelector(".viewer-image");
|
||||
return {
|
||||
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
|
||||
position: viewer?.querySelector(".viewer-position")?.textContent ?? "",
|
||||
imageLoaded: !!image && image.complete && image.naturalWidth > 0,
|
||||
};
|
||||
})()`);
|
||||
if (advanced.title !== "shot.png" || !advanced.imageLoaded) {
|
||||
throw new Error(`ArrowRight did not land on the image artifact: ${JSON.stringify(advanced)}`);
|
||||
}
|
||||
console.log(` ArrowRight -> ${advanced.title} (${advanced.position})`);
|
||||
await shot("46-viewer-markdown-next.png");
|
||||
await page.evaluate(
|
||||
`document.activeElement?.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowLeft", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".artifact-viewer .viewer-position")?.textContent?.startsWith("1 of 5") ?? false`,
|
||||
),
|
||||
{ timeout: 10000, what: "ArrowLeft to return the viewer" },
|
||||
);
|
||||
const returned = await page.evaluate(
|
||||
`document.querySelector(".artifact-viewer .viewer-title")?.textContent ?? ""`,
|
||||
);
|
||||
if (returned !== "input.md") throw new Error(`ArrowLeft returned to ${returned}, not input.md`);
|
||||
console.log(" ArrowLeft -> input.md");
|
||||
|
||||
step("R8: the last artifact disables Next and a failed fetch is honest");
|
||||
await page.evaluate(`(() => {
|
||||
for (let i = 0; i < 20; i += 1) {
|
||||
const next = document.querySelector('.viewer-page[data-viewer-focus="next"]');
|
||||
if (!next || next.disabled) break;
|
||||
next.click();
|
||||
}
|
||||
})()`);
|
||||
await page.waitForSelector(".artifact-viewer .viewer-error-message", { timeout: 15000 });
|
||||
const failure = await page.evaluate(`(() => {
|
||||
const viewer = document.querySelector(".artifact-viewer");
|
||||
const external = viewer?.querySelector(".viewer-external");
|
||||
return {
|
||||
title: viewer?.querySelector(".viewer-title")?.textContent ?? "",
|
||||
message: viewer?.querySelector(".viewer-error-message")?.textContent ?? "",
|
||||
externalText: external?.textContent ?? "",
|
||||
externalHref: external?.getAttribute("href") ?? "",
|
||||
nextDisabled: viewer?.querySelector('.viewer-page[data-viewer-focus="next"]')?.disabled ?? null,
|
||||
};
|
||||
})()`);
|
||||
if (failure.title !== "missing.txt" || failure.message.trim() === "") {
|
||||
throw new Error(`the failed fetch did not show an honest message: ${JSON.stringify(failure)}`);
|
||||
}
|
||||
if (
|
||||
failure.externalText !== "Open missing.txt externally" ||
|
||||
!failure.externalHref.endsWith("/test/fixtures/artifacts/missing.txt")
|
||||
) {
|
||||
throw new Error(`the external fallback is wrong: ${JSON.stringify(failure)}`);
|
||||
}
|
||||
if (failure.nextDisabled !== true) throw new Error("Next is not disabled on the last artifact");
|
||||
console.log(` failure: ${failure.message.trim()} · ${failure.externalText}`);
|
||||
await shot("47-viewer-markdown-failure.png");
|
||||
|
||||
step("R8: a click inside the panel keeps the viewer open; the backdrop closes it");
|
||||
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
|
||||
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
|
||||
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
|
||||
await page.evaluate(`document.querySelector('.viewer-page[data-viewer-focus="prev"]').click()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".artifact-viewer .viewer-title")?.textContent === "input.md"`,
|
||||
),
|
||||
{ timeout: 10000, what: "the viewer to return to input.md" },
|
||||
);
|
||||
await page.evaluate(`document.querySelector(".artifact-viewer .viewer-title")?.click()`);
|
||||
if (!(await page.evaluate(`!!document.querySelector(".artifact-viewer")`))) {
|
||||
throw new Error("a click inside the viewer panel closed it");
|
||||
}
|
||||
const closedByBackdrop = await page.evaluate(`(() => {
|
||||
const overlay = document.querySelector(".artifact-viewer");
|
||||
if (!overlay) return false;
|
||||
const rect = overlay.getBoundingClientRect();
|
||||
const target = document.elementFromPoint(rect.left + 3, rect.top + 3);
|
||||
if (!target) return false;
|
||||
target.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
return true;
|
||||
})()`);
|
||||
if (!closedByBackdrop) throw new Error("the backdrop had no point to click");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), {
|
||||
timeout: 10000,
|
||||
what: "the backdrop click to close the viewer",
|
||||
});
|
||||
console.log(" a panel click kept the viewer open; the dimmed backdrop closed it");
|
||||
await shot("48-viewer-markdown-backdrop-closed.png");
|
||||
|
||||
// Drop the fixture intercept so later documents (the shell pass) talk only to
|
||||
// the real server; the init script is removed by navigating away from here.
|
||||
await page.evaluate(`(() => { window.__pipelinesIntercept = null; return true; })()`);
|
||||
}
|
||||
|
||||
try {
|
||||
await mkdir(out, { recursive: true });
|
||||
|
||||
@@ -1862,6 +2153,10 @@ try {
|
||||
await runNotificationChecks();
|
||||
console.log("\nUI SMOKE PASS");
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
} else if (viewerOnly) {
|
||||
await runMarkdownViewerChecks();
|
||||
console.log("\nUI SMOKE PASS");
|
||||
for (const shot of shots) console.log(` ${shot}`);
|
||||
} else if (!scratch) {
|
||||
const pipelineCount = await page.evaluate(
|
||||
`document.querySelectorAll("#pipelineRows button.row").length`,
|
||||
@@ -2549,9 +2844,9 @@ try {
|
||||
shots.push(await page.screenshot(`${out}/19-template-source.png`));
|
||||
|
||||
// Artifact URLs resolve against whatever the URL field holds. Point it at the
|
||||
// real server (the socket stays on the proxy, see the note above) so the tiles
|
||||
// and the viewer load real files rather than proxying a path serve.mjs does
|
||||
// not forward.
|
||||
// page's own proxy origin so tiles and the viewer load real files same-origin:
|
||||
// serve.mjs forwards /artifacts/ to the Pipelines server (the socket stays on
|
||||
// that same proxy too).
|
||||
step("returning to Runs and opening run 430 (Summary tab)");
|
||||
await clickDestination("Settings");
|
||||
await page.waitForSelector("#settingsServerUrl", { timeout: 15000 });
|
||||
@@ -7693,6 +7988,8 @@ try {
|
||||
);
|
||||
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
|
||||
|
||||
await runMarkdownViewerChecks();
|
||||
|
||||
await runShellChecks();
|
||||
|
||||
console.log("\nUI SMOKE PASS");
|
||||
|
||||
Reference in New Issue
Block a user