Merge branch 'main' into web-chat-live

This commit is contained in:
2026-10-19 07:01:39 +01:00
9 changed files with 583 additions and 3 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu
| P2 | Filter + sort (status/name/updated) | client-side | done — Filter menu (name contains, Runs Any/Has runs/No runs, Last run status over the 7 server states, Clear filters) + Sort menu (Server order default, Name A–Z/Z–A, Most recent run, Fewest/Most stages, Reset); server order preserved |
| P3 | Pipeline detail: stages, graph, versions, last run, content hash | `get_pipeline` | done — Summary/Graph/Source tabs; Summary shows content hash (monospace), latest version (`v{n}` or blank), created/updated, and a collapsed-by-default Versions section. Graph tab shows the browser guidance note plus the rendered workflow graph (P6) |
| P4 | Templates gallery + template detail | `list_templates`, `validate` | done |
| P5 | Create pipeline from a template (validate then submit) | `validate`, `submit` | todo |
| P5 | Create pipeline from a template (validate then submit) | `validate`, `submit` | done — a template detail offers the action `Create pipeline from this template`; its dialog's title is `Create from {name}` (a blank name falling back to the template key), it has one required field labelled `New pipeline name (required)`, the note `Creates a new draft pipeline on the server from this template's source; it is not run.`, and Create/Cancel buttons (Cancel reads `Close` after a success). Create is disabled while the name is blank (whitespace counts) or while sending, and the field locks while sending and after a success. Submitting validates the template's source first (`validate`); a validation refusal shows the server's own error in the still-open dialog and sends no `submit`. A passing validate submits exactly `{type:'submit',name:<trimmed>,source:<template source>,create_only:true}`, shows `Created "{name}". It is in the Pipelines list.` and refreshes `list_pipelines` so the new row is visible; a `submit` refusal shows the server's error in the still-open dialog. The pure helpers and both request shapes are unit-tested (`test/templates.test.mjs`, `test/repository.test.mjs`). Captured against a **scratch server with its own throwaway database** (never the live one): `captures/51-template-create-dialog.png` (blank name, Create disabled), `captures/52-template-created.png` (the exact success line; Cancel now `Close`) and `captures/53-pipeline-created-list.png` (the created pipeline shown in that scratch server's Pipelines list). **The live server's pipeline list was not modified**: the create flow runs only under `ui-smoke.mjs`'s explicit `--scratch` flag, the default run sends no `submit`, and the scratch server was stopped and its database deleted afterwards |
| P6 | Workflow graph rendering (nodes, edges, stage panes) | `get_pipeline` | done (captured 2026-10-19: nodes + labelled outcome edges + success/failure terminals, an opened stage definition pane and the expanded view — `captures/08-pipeline-graph.png`, `captures/08a-pipeline-graph-stage-pane.png`, `captures/08b-pipeline-graph-expanded.png`). Reusable `src/graph.js` (`mount` + pure helpers: layout, edges, `error*`, lanes, fit/clamp/zoom, hit-test, stage-definition fields); the definition view (every route executed, no legend) plus, since R5, a run-mode view driven by `runState` (executed/not-executed stages and routes, the Executed / Not executed legend, the live halo/elapsed badge). Pane labels match the app's own vocabulary (`Outcomes`, `Tools`) rather than the checklist's category words |
## Runs
+213
View File
@@ -78,6 +78,15 @@ import {
runFiltersActiveCount,
} from "./runs.js";
import {
CREATE_ACTION_LABEL,
CREATE_NAME_LABEL,
CREATE_NOTE,
createConfirmLabel,
createDismissLabel,
createFormTitle,
createFormValid,
createSuccessMessage,
createdPipelineName,
effectiveStageType,
templateCard,
templateDetailName,
@@ -334,6 +343,16 @@ const state = {
templateGraphs: new Map(),
selectedTemplateKey: null,
templateTab: "summary",
// The create-from-template dialog (P5): whether it is open, the name being
// typed, whether a validate+submit is in flight, the server's refusal text and
// the created pipeline's name (null until a success, which is also what makes
// Cancel read Close and the field lock). The dialog validates the template's
// source first, then submits it create-only; nothing runs.
templateCreateOpen: false,
templateCreateName: "",
templateCreateSending: false,
templateCreateError: "",
templateCreateCreated: null,
loading: false,
error: "",
runFilters: defaultRunFilters(),
@@ -1318,6 +1337,7 @@ function renderTemplateDetail() {
return pane;
}
const graph = templateGraphFor(entry.key);
pane.append(renderTemplateDetailActions());
pane.append(
h(
"div",
@@ -1330,9 +1350,190 @@ function renderTemplateDetail() {
if (state.templateTab === "graph") pane.append(renderTemplateGraphTab(graph));
else if (state.templateTab === "source") pane.append(renderTemplateSourceTab(entry, graph));
else pane.append(renderTemplateSummaryTab(entry, graph));
if (state.templateCreateOpen) pane.append(renderTemplateCreateDialog(entry));
return pane;
}
/**
* The template detail's action row: the one "Create pipeline from this
* template" action (P5), matching the app's top-bar add action. It opens the
* dialog; it never submits on its own.
*/
function renderTemplateDetailActions() {
return h(
"div",
{ class: "detail-actions" },
h("button", {
class: "ghost template-create-open",
type: "button",
text: CREATE_ACTION_LABEL,
onclick: () => openTemplateCreateDialog(),
}),
);
}
/** Open the create dialog with a fresh, empty name; nothing is sent until Create. */
function openTemplateCreateDialog() {
state.templateCreateOpen = true;
state.templateCreateName = "";
state.templateCreateSending = false;
state.templateCreateError = "";
state.templateCreateCreated = null;
renderContent();
document.querySelector(".template-create-name")?.focus();
}
/** Dismiss the create dialog (never while a validate+submit is in flight). */
function closeTemplateCreateDialog() {
if (state.templateCreateSending) return;
state.templateCreateOpen = false;
state.templateCreateName = "";
state.templateCreateError = "";
state.templateCreateCreated = null;
renderContent();
}
/**
* The create dialog (P5): the title, the one required name field, the note, the
* server's refusal text or the success line, and Create/Cancel (Cancel reads
* Close after a success). Create is disabled while the name is blank or while
* sending; the field locks while sending and after a success. Every server
* string is set with textContent.
*/
function renderTemplateCreateDialog(entry) {
const title = createFormTitle(entry);
const overlay = h("div", {
class: "template-create-dialog",
role: "dialog",
"aria-modal": "true",
"aria-label": title,
});
overlay.addEventListener("click", (event) => {
if (event.target === overlay) closeTemplateCreateDialog();
});
const panel = h("div", { class: "template-create-panel" });
panel.append(h("h2", { class: "template-create-title", text: title }));
const field = h("label", { class: "template-create-field" });
field.append(h("span", { class: "template-create-label", text: CREATE_NAME_LABEL }));
field.append(
h("input", {
class: "template-create-name",
type: "text",
value: state.templateCreateName,
spellcheck: "false",
autocomplete: "off",
disabled: state.templateCreateSending || state.templateCreateCreated != null,
oninput: (event) => {
// Update in place (no re-render) so the field keeps focus and its caret;
// only the confirm button's enabled state depends on the name.
state.templateCreateName = event.target.value;
const confirm = overlay.querySelector(".template-create-confirm");
if (confirm) {
confirm.disabled = !createFormValid(state.templateCreateName, {
sending: state.templateCreateSending,
created: state.templateCreateCreated,
});
}
},
}),
);
panel.append(field);
panel.append(h("p", { class: "template-create-note muted", text: CREATE_NOTE }));
if (state.templateCreateError) {
panel.append(h("div", { class: "template-create-error bad", text: state.templateCreateError }));
}
if (state.templateCreateCreated != null) {
panel.append(
h("div", {
class: "template-create-success",
text: createSuccessMessage(state.templateCreateCreated),
}),
);
}
const actions = h("div", { class: "template-create-actions" });
actions.append(
h("button", {
class: "ghost template-create-cancel",
type: "button",
text: createDismissLabel(state.templateCreateCreated),
disabled: state.templateCreateSending,
onclick: closeTemplateCreateDialog,
}),
);
actions.append(
h("button", {
class: "template-create-confirm",
type: "button",
text: createConfirmLabel(state.templateCreateSending),
disabled: !createFormValid(state.templateCreateName, {
sending: state.templateCreateSending,
created: state.templateCreateCreated,
}),
onclick: () => createFromTemplate(entry),
}),
);
panel.append(actions);
overlay.append(panel);
return overlay;
}
/**
* The P5 submit flow, exactly the app's: validate the template's source first
* and, when the server refuses to parse it, show its own error in the dialog and
* send nothing; otherwise submit the source create-only with the chosen name. On
* success remember the created name, refresh the pipeline list so the new row is
* visible and leave the dialog open (Cancel now reads Close); on failure show
* the server's error without closing.
*/
async function createFromTemplate(entry) {
if (
!createFormValid(state.templateCreateName, {
sending: state.templateCreateSending,
created: state.templateCreateCreated,
})
) {
return;
}
const name = state.templateCreateName;
state.templateCreateSending = true;
state.templateCreateError = "";
renderContent();
try {
await repo.validate(entry.source);
} catch (error) {
state.templateCreateSending = false;
state.templateCreateError = describeError(error);
renderContent();
return;
}
try {
const detail = await repo.submit(name, entry.source);
state.templateCreateSending = false;
state.templateCreateCreated = createdPipelineName(detail, name);
await refreshPipelines();
} catch (error) {
state.templateCreateSending = false;
state.templateCreateError = describeError(error);
}
renderContent();
}
/**
* Refresh just the pipeline summaries after a create so the new row appears when
* the operator returns to the Pipelines list. A failed refresh keeps the created
* name and is surfaced through the banner rather than discarded.
*/
async function refreshPipelines() {
try {
state.pipelines = await repo.listPipelines();
state.pipelinesLoaded = true;
} catch (error) {
state.error = describeError(error);
}
}
function templateTabButton(tab, label) {
return h("button", {
class: `minitab${state.templateTab === tab ? " active" : ""}`,
@@ -4932,6 +5133,13 @@ async function validateTemplate(entry) {
function selectTemplate(key) {
state.selectedTemplateKey = key;
state.templateTab = "summary";
// A different template reseeds the create dialog, so a name typed for one
// template can never be submitted against another.
state.templateCreateOpen = false;
state.templateCreateName = "";
state.templateCreateSending = false;
state.templateCreateError = "";
state.templateCreateCreated = null;
renderContent();
}
@@ -5155,6 +5363,11 @@ document.addEventListener("keydown", (event) => {
return;
}
if (document.querySelector(".artifact-viewer") || document.querySelector(".change-viewer")) return;
if (state.templateCreateOpen) {
event.preventDefault();
closeTemplateCreateDialog();
return;
}
if (state.actionError) {
event.preventDefault();
dismissActionError();
+6
View File
@@ -16,6 +16,12 @@ export const Protocol = Object.freeze({
VALIDATE: "validate",
VALIDATED: "validated",
// Publishing a new create-only draft from a source (internal/protocol/message.go
// Submit/Submitted; mirrors PipelinesRepository.createPipeline). The reply
// carries the new pipeline `detail`.
SUBMIT: "submit",
SUBMITTED: "submitted",
LIST_RUNS: "list_runs",
RUNS: "runs",
GET_RUN: "get_run",
+23
View File
@@ -60,6 +60,29 @@ export class PipelinesRepository {
return response.graph;
}
/**
* Creates a new pipeline from a definition `source` (the `submit` command),
* create-only, mirroring `PipelinesRepository.createPipeline`: the name must
* not already exist, so this can only ever add a draft and never overwrite a
* retained pipeline. A blank name is refused before anything is sent, exactly
* like the Android client; the sent name is trimmed. No run is started.
*/
async submit(name, source) {
if (!String(name ?? "").trim()) {
throw new ProtocolError("Enter a pipeline name.");
}
const response = await this.#client.call({
type: Protocol.SUBMIT,
name: String(name).trim(),
source,
create_only: true,
});
if (!response.detail) {
throw new ProtocolError("The server returned no pipeline detail.");
}
return response.detail;
}
async listRuns() {
const response = await this.#client.call({ type: Protocol.LIST_RUNS });
return { runs: response.runs ?? [], usage: response.usage ?? null };
+65
View File
@@ -91,3 +91,68 @@ export function templateStageSummary(graph) {
export function templateGraphNote(graph) {
return graph == null ? TEMPLATE_UNPARSED_GRAPH_NOTE : TEMPLATE_GRAPH_NOTE;
}
// --- Create a pipeline from this template (P5) -----------------------------
// The wording, verbatim from android/.../TemplateDetailScreen.kt's
// CreateFromTemplateDialog. The dialog validates the template's source first,
// then submits it create-only; nothing runs and an existing name is never
// overwritten.
/** The template-detail action that opens the create dialog. */
export const CREATE_ACTION_LABEL = "Create pipeline from this template";
/** The dialog's single required field label. */
export const CREATE_NAME_LABEL = "New pipeline name (required)";
/** The dialog's explanatory note (verbatim; states that nothing runs). */
export const CREATE_NOTE =
"Creates a new draft pipeline on the server from this template's source; it is not run.";
/** The confirm button's idle label. */
export const CREATE_CONFIRM = "Create";
/** The confirm button's in-flight label. */
export const CREATE_SENDING = "Creating…";
/** The dismiss button's label before a success. */
export const CREATE_CANCEL = "Cancel";
/** The dismiss button's label after a success. */
export const CREATE_CLOSE = "Close";
/** The dialog's title: `Create from {name}`, a blank name falling back to the key. */
export function createFormTitle(entry) {
return `Create from ${templateDetailName(entry)}`;
}
/**
* Whether the dialog can submit: not while sending, not once a pipeline has
* been created, and never with a blank (or whitespace-only) name.
*/
export function createFormValid(name, { sending = false, created = null } = {}) {
return !sending && created == null && String(name ?? "").trim() !== "";
}
/** The confirm button's label: "Creating…" while in flight, else "Create". */
export function createConfirmLabel(sending) {
return sending ? CREATE_SENDING : CREATE_CONFIRM;
}
/** The dismiss button's label: "Close" once a pipeline was created, else "Cancel". */
export function createDismissLabel(created) {
return created != null ? CREATE_CLOSE : CREATE_CANCEL;
}
/** The dialog's success line: `Created "{name}". It is in the Pipelines list.` */
export function createSuccessMessage(created) {
return `Created "${created}". It is in the Pipelines list.`;
}
/**
* The name to report after a successful submit: the created pipeline's own name
* when the server returned one, else the name the operator submitted (trimmed),
* mirroring `created = it.name.ifBlank { name.trim() }`.
*/
export function createdPipelineName(detail, submittedName) {
return String(detail?.name ?? "").trim() || String(submittedName ?? "").trim();
}
+43
View File
@@ -1367,6 +1367,49 @@ code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-
.confirm-accept { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.action-failed-ok { justify-self: end; }
/* Create a pipeline from a template (P5): the detail action and its dialog. */
.detail-actions { display: flex; gap: 8px; align-items: center; padding: 8px 12px 0; }
.template-create-open { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.template-create-dialog {
position: fixed;
inset: 0;
z-index: 40;
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
background: rgba(0, 0, 0, 0.55);
}
.template-create-panel {
display: grid;
gap: 12px;
width: min(460px, 100%);
padding: 16px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.template-create-title { margin: 0; font-size: 16px; }
.template-create-field { display: grid; gap: 4px; }
.template-create-label { font-size: 12px; color: var(--muted); }
.template-create-name {
width: 100%;
padding: 6px 8px;
background: var(--surface-2);
color: var(--text);
border: 1px solid var(--border);
border-radius: 8px;
font: inherit;
}
.template-create-name:focus { outline: none; border-color: var(--accent); }
.template-create-note { margin: 0; line-height: 1.5; font-size: 13px; }
.template-create-error { font-size: 13px; }
.template-create-success { font-size: 13px; color: var(--ok); }
.template-create-actions { display: flex; gap: 8px; justify-content: flex-end; }
.template-create-confirm { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.template-create-confirm:disabled, .template-create-cancel:disabled { opacity: 0.5; }
/* The inline rename control on the Summary title row. */
.run-title-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.run-title-row .run-detail-title { margin: 0; }
+61
View File
@@ -105,6 +105,67 @@ test("validate throws when the reply has no graph", async () => {
await assert.rejects(() => repo.validate("empty"), ProtocolError);
});
/** The new pipeline detail a `submitted` reply carries in these tests. */
const SUBMITTED_DETAIL = { id: 91, name: "Release helper", version: 1 };
test("submit sends exactly {type:'submit',name,source,create_only:true} and returns the detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
const detail = await repo.submit("Release helper", "the source");
assert.deepEqual(lastFrame(ws), {
type: "submit",
name: "Release helper",
source: "the source",
create_only: true,
});
assert.deepEqual(detail, SUBMITTED_DETAIL);
});
test("submit trims the name before sending it", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
await repo.submit(" Release helper ", "the source");
assert.deepEqual(lastFrame(ws), {
type: "submit",
name: "Release helper",
source: "the source",
create_only: true,
});
});
test("submit refuses a blank name without sending anything", async () => {
const { repo, ws } = connected();
ws.reply = () => ({ id: "unused", type: "submitted", detail: SUBMITTED_DETAIL });
await assert.rejects(() => repo.submit(" ", "the source"), {
name: "ProtocolError",
message: "Enter a pipeline name.",
});
assert.equal(ws.sent.length, 0);
});
test("submit rejects a server error envelope with the server's own text", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "error", error: 'a pipeline named "Release helper" already exists' });
await assert.rejects(() => repo.submit("Release helper", "the source"), {
name: "ProtocolError",
message: 'a pipeline named "Release helper" already exists',
});
});
test("submit throws when the reply has no pipeline detail", async () => {
const { repo, ws } = connected();
ws.reply = (frame) => ({ id: frame.id, type: "submitted", name: "Release helper" });
await assert.rejects(() => repo.submit("Release helper", "the source"), {
name: "ProtocolError",
message: "The server returned no pipeline detail.",
});
});
test("search sends exactly {type:'search',search:{query,kind:'',limit:0}} and returns search_results", async () => {
const { repo, ws } = connected();
const payload = { query: "release", results: [{ kind: "run" }], cap: 50, scanned_steps: 3 };
+64
View File
@@ -4,6 +4,18 @@ import { test } from "node:test";
import assert from "node:assert/strict";
import {
CREATE_CANCEL,
CREATE_CLOSE,
CREATE_CONFIRM,
CREATE_NAME_LABEL,
CREATE_NOTE,
CREATE_SENDING,
createConfirmLabel,
createDismissLabel,
createFormTitle,
createFormValid,
createSuccessMessage,
createdPipelineName,
effectiveStageType,
stageCountText,
templateCard,
@@ -85,3 +97,55 @@ test("templateGraphNote picks the unparsed or parsed note", () => {
assert.equal(templateGraphNote(null), TEMPLATE_UNPARSED_GRAPH_NOTE);
assert.equal(templateGraphNote({ stages: [] }), TEMPLATE_GRAPH_NOTE);
});
test("createFormTitle names the template, a blank name falling back to the key", () => {
assert.equal(createFormTitle({ key: "task", name: "Complete a task" }), "Create from Complete a task");
assert.equal(createFormTitle({ key: "task", name: "" }), "Create from task");
assert.equal(createFormTitle({ key: "task", name: " " }), "Create from task");
});
test("createFormValid rejects blank/whitespace, sending and an existing creation", () => {
assert.equal(createFormValid("a pipeline"), true);
assert.equal(createFormValid(""), false);
assert.equal(createFormValid(" "), false);
assert.equal(createFormValid(null), false);
assert.equal(createFormValid("a pipeline", { sending: true }), false);
assert.equal(createFormValid("a pipeline", { created: "a pipeline" }), false);
assert.equal(createFormValid("a pipeline", { created: "" }), false);
// Defaults: a non-blank name with no options is valid.
assert.equal(createFormValid("a pipeline", {}), true);
});
test("createConfirmLabel switches Create / Creating…", () => {
assert.equal(createConfirmLabel(false), CREATE_CONFIRM);
assert.equal(createConfirmLabel(true), CREATE_SENDING);
});
test("createDismissLabel is Cancel until a creation, then Close", () => {
assert.equal(createDismissLabel(null), CREATE_CANCEL);
assert.equal(createDismissLabel(undefined), CREATE_CANCEL);
assert.equal(createDismissLabel("Made"), CREATE_CLOSE);
});
test("createSuccessMessage is the exact success line", () => {
assert.equal(createSuccessMessage("Release helper"), 'Created "Release helper". It is in the Pipelines list.');
});
test("createdPipelineName prefers the returned name, else the trimmed submitted name", () => {
assert.equal(createdPipelineName({ name: "Server name" }, "Typed name"), "Server name");
assert.equal(createdPipelineName({ name: " " }, " Typed name "), "Typed name");
assert.equal(createdPipelineName(null, " Typed name "), "Typed name");
assert.equal(createdPipelineName({}, ""), "");
});
test("the create dialog's fixed wording is the app's", () => {
assert.equal(CREATE_NAME_LABEL, "New pipeline name (required)");
assert.equal(
CREATE_NOTE,
"Creates a new draft pipeline on the server from this template's source; it is not run.",
);
assert.equal(CREATE_CONFIRM, "Create");
assert.equal(CREATE_SENDING, "Creating…");
assert.equal(CREATE_CANCEL, "Cancel");
assert.equal(CREATE_CLOSE, "Close");
});
+107 -2
View File
@@ -2,11 +2,16 @@
// Chrome, connect to a running Pipelines server through the page's own proxy,
// and capture what actually rendered.
//
// node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR]
// node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR] [--scratch]
//
// This is the UI evidence a review stage produces: real screenshots of the
// rendered client, not a claim. It needs a running Pipelines server (the live one
// or a scratch one) and the installed Chrome; it has no npm dependencies.
//
// `--scratch` drives ONLY the P5 create-from-template flow (captures 51/52/53)
// against a scratch server and skips the live suite, which needs the operator's
// real runs and chat session. The default run never sends a `submit`: the live
// server's pipeline list is never mutated.
import { spawn } from "node:child_process";
import { mkdir, rm } from "node:fs/promises";
import net from "node:net";
@@ -38,6 +43,9 @@ const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET
const out = resolve(
flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")),
);
// Scratch mode: only the P5 create-from-template flow runs, against a throwaway
// server with its own database. The default (live) run sends no submit.
const scratch = process.argv.includes("--scratch");
// 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
@@ -109,6 +117,87 @@ async function openRunDetail(runId) {
}
}
// --- P5: create a pipeline from a template (scratch server only) -----------
// The scratch server has no real runs and no live chat, so this is the whole
// point of a `--scratch` run. It opens a template, opens the create action,
// captures the blank/disabled dialog, fills a unique name, creates it, captures
// the success dialog and then the Pipelines list holding the new row. It sends a
// real validate + submit, but only ever against the scratch database.
async function runScratchCreate() {
step("P5: creating a pipeline from a template (scratch server)");
await ensureConnected();
await page.clickText("nav.tabs button.tab", "Templates");
await page.waitForSelector(".cards button.card", { timeout: 25000 });
await page.click(".cards button.card");
await page.waitForSelector(".detail .tabstrip", { timeout: 25000 });
await page.waitForSelector(".template-create-open", { timeout: 15000 });
const actionLabel = await text(".template-create-open");
if (actionLabel !== "Create pipeline from this template") {
throw new Error(`create action label: ${actionLabel}`);
}
await page.click(".template-create-open");
await page.waitForSelector(".template-create-dialog", { timeout: 15000 });
const blank = await page.evaluate(`(() => ({
title: document.querySelector(".template-create-title")?.textContent ?? "",
label: document.querySelector(".template-create-label")?.textContent ?? "",
note: document.querySelector(".template-create-note")?.textContent ?? "",
confirm: document.querySelector(".template-create-confirm")?.textContent ?? "",
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
confirmDisabled: document.querySelector(".template-create-confirm")?.disabled ?? null,
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
}))()`);
if (!blank.title.startsWith("Create from ")) throw new Error(`create dialog title: ${blank.title}`);
if (blank.label !== "New pipeline name (required)") throw new Error(`create field label: ${blank.label}`);
if (blank.note !== "Creates a new draft pipeline on the server from this template's source; it is not run.") {
throw new Error(`create note: ${blank.note}`);
}
if (blank.confirm !== "Create") throw new Error(`create confirm: ${blank.confirm}`);
if (blank.dismiss !== "Cancel") throw new Error(`create dismiss: ${blank.dismiss}`);
if (blank.confirmDisabled !== true) throw new Error("Create was enabled with a blank name");
if (blank.fieldDisabled !== false) throw new Error("the name field started disabled");
console.log(` blank dialog: "${blank.title}" — Create disabled, field enabled, Cancel offered`);
await shot("51-template-create-dialog.png");
const newName = `Scratch create ${Date.now()}`;
await page.fill(".template-create-name", newName);
await eventually(
() => page.evaluate(`!document.querySelector(".template-create-confirm")?.disabled`),
{ timeout: 5000, what: "Create to enable after a non-blank name" },
);
await page.click(".template-create-confirm");
await page.waitForText(`Created "${newName}". It is in the Pipelines list.`, { timeout: 25000 });
const success = await page.evaluate(`(() => ({
text: document.querySelector(".template-create-success")?.textContent ?? "",
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
}))()`);
if (success.text !== `Created "${newName}". It is in the Pipelines list.`) {
throw new Error(`create success line: ${success.text}`);
}
if (success.dismiss !== "Close") throw new Error(`dismiss after success: ${success.dismiss}`);
if (success.fieldDisabled !== true) throw new Error("the name field was not locked after a success");
console.log(` created: ${JSON.stringify(success.text)}; dismiss now reads ${success.dismiss}`);
await shot("52-template-created.png");
// Cancel now reads Close: dismissing it leaves the Templates view, then the
// refreshed Pipelines list must hold the new row.
await page.click(".template-create-cancel");
await eventually(() => page.evaluate(`!document.querySelector(".template-create-dialog")`), {
timeout: 5000,
what: "the create dialog to close",
});
await page.clickText("nav.tabs button.tab", "Pipelines");
await page.waitForText(newName, { timeout: 25000 });
const listed = await page.evaluate(
`document.querySelector("#pipelineRows")?.textContent.includes(${JSON.stringify(newName)}) ?? false`,
);
if (!listed) throw new Error("the created pipeline is not in the Pipelines list");
console.log(" the created pipeline appears in the scratch server's Pipelines list");
await shot("53-pipeline-created-list.png");
}
// --- Omni-search (S1/S2) ---------------------------------------------------
// The page's own search UI drives every one of the helpers below; nothing is
// stubbed. `searchTargets` opens the panel (if it is not already open), types the
@@ -301,8 +390,23 @@ try {
step("connecting the page to the server through its own proxy");
await page.fill("#url", `ws://127.0.0.1:${port}/connect`);
await page.click("#connectBtn");
await page.waitForSelector(".row-title", { timeout: 25000 });
// A scratch server starts with no pipelines at all, so the pipeline row that
// proves the live list rendered is skipped there; the connection banner is
// still awaited either way.
if (!scratch) await page.waitForSelector(".row-title", { timeout: 25000 });
await page.waitForText("connected", { timeout: 25000 });
// Scratch mode runs only the P5 create flow above and skips the live suite,
// which needs the operator's real pipelines, runs and chat session. The guard
// below wraps the live steps without reindenting them, keeping this diff
// reviewable; both branches share this file's cleanup in the `finally`.
if (scratch) {
await runScratchCreate();
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
}
if (!scratch) {
const pipelineCount = await page.evaluate(
`document.querySelectorAll("#pipelineRows button.row").length`,
);
@@ -2908,6 +3012,7 @@ try {
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
}
} catch (error) {
failed = true;
console.error(`\nUI SMOKE FAIL: ${error.message}`);