Merge branch 'main' into web-notify

This commit is contained in:
2026-10-19 14:11:46 +01:00
6 changed files with 1329 additions and 75 deletions
+356 -23
View File
@@ -2,7 +2,9 @@
// 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] [--scratch]
// node test/ui-smoke.mjs [--port PORT] [--pipelines 127.0.0.1:8080] [--out DIR] [--scratch]
//
// Without --port the OS picks a free port, so concurrent checks do not collide.
//
// 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
@@ -57,7 +59,12 @@ function flag(argv, name, fallback) {
return i !== -1 && argv[i + 1] ? argv[i + 1] : fallback;
}
const port = Number(flag(process.argv, "--port", process.env.WEB_UI_PORT ?? 8091));
// No fixed default port: an explicit --port/WEB_UI_PORT still wins, but otherwise
// each run asks the OS for a free one. Concurrent checks (parallel pipeline items)
// therefore never collide on 8091 — the earlier fixed default made a second
// simultaneous UI stage fail with EADDRINUSE.
const explicitPort = flag(process.argv, "--port", process.env.WEB_UI_PORT);
const port = explicitPort ? Number(explicitPort) : await freePort();
const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET ?? "127.0.0.1:8080");
const out = resolve(
flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")),
@@ -166,6 +173,16 @@ async function openRunDetail(runId) {
}
}
// Open one chat row's Chat actions menu (the row's management items live behind
// it since C13: Rename… / Close chat… or Reopen / Hide on this device).
async function openChatRowMenu(sessionId) {
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
await page.waitForSelector(
`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel`,
{ timeout: 10000 },
);
}
// --- 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,
@@ -1703,6 +1720,9 @@ try {
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Graph");
await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 });
// The run can stop (or be reported `running` with no stage in flight) between
// the list read and this graph, so treat the halo as the best effort its
// comment promises rather than failing the whole run on a race.
const live = await eventually(
async () =>
page.evaluate(`(() => {
@@ -1715,11 +1735,15 @@ try {
};
})()`),
{ timeout: 15000, what: "the live run's active stage" },
);
if (!live.badge) throw new Error(`the active stage showed no elapsed badge: ${JSON.stringify(live)}`);
console.log(` live run ${liveRunId}: active stage ${live.activeKey} (pulsing=${live.pulsing}), badge ${live.badge}`);
await page.rect(".run-detail .graph-viewport");
shots.push(await page.screenshot(`${out}/31-run-live-graph.png`));
).catch(() => null);
if (!live) {
console.log(` -- run ${liveRunId} shows no stage in flight; skipped the live graph halo capture`);
} else {
if (!live.badge) throw new Error(`the active stage showed no elapsed badge: ${JSON.stringify(live)}`);
console.log(` live run ${liveRunId}: active stage ${live.activeKey} (pulsing=${live.pulsing}), badge ${live.badge}`);
await page.rect(".run-detail .graph-viewport");
shots.push(await page.screenshot(`${out}/31-run-live-graph.png`));
}
}
// The Output empty state, on the running run that has not produced output yet.
@@ -2622,7 +2646,8 @@ try {
title: row.querySelector(".chat-row-title")?.textContent ?? "",
chips: [...row.querySelectorAll(".chip")].map((chip) => chip.textContent),
meta: row.querySelector(".chat-row-meta")?.textContent ?? "",
close: !!row.querySelector(".chat-close"),
menu: !!row.querySelector(".chat-menu-button"),
menuLabel: row.querySelector(".chat-menu-button")?.getAttribute("aria-label") ?? "",
})),
}))()`);
if (chatList.label !== "Search chats") throw new Error(`chat search label: ${chatList.label}`);
@@ -2632,7 +2657,9 @@ try {
if (!chatList.rows[0].chips.includes("Operator")) {
throw new Error(`chat kind chip: ${chatList.rows[0].chips.join(", ")}`);
}
if (!chatList.rows[0].close) throw new Error("the open chat row offers no Close chat action");
if (!chatList.rows[0].menu || chatList.rows[0].menuLabel !== "Chat actions") {
throw new Error(`the open chat row's Chat actions menu: ${JSON.stringify(chatList.rows[0])}`);
}
console.log(
` chat list: ${chatList.rows.length} session(s); "${chatList.rows[0].title}" ` +
`[${chatList.rows[0].chips.join(", ")}] — ${chatList.rows[0].meta}`,
@@ -2640,9 +2667,11 @@ try {
await shot("44-chat-sessions.png");
// The row's own Close chat… action with NO conversation open: the list offers
// it on every open row, so the confirm must still appear. Shown and dismissed
// with Cancel; no chat_close is ever sent for the operator's live session.
await page.click(`#chatRows .chat-row[data-session="${chatList.rows[0].id}"] .chat-close`);
// it on every open row (behind the Chat actions menu), so the confirm must
// still appear. Shown and dismissed with Cancel; no chat_close is ever sent for
// the operator's live session.
await openChatRowMenu(chatList.rows[0].id);
await page.click(`#chatRows .chat-row[data-session="${chatList.rows[0].id}"] .chat-menu-close`);
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
const listClose = await page.evaluate(
`document.querySelector(".confirm-chat-close .confirm-message")?.textContent ?? ""`,
@@ -2682,6 +2711,12 @@ try {
const candidates = [
...new Set([...(preferred ? [preferred.id] : []), ...openRows, ...chatList.rows.map((r) => r.id)]),
];
// Record the frames the page sends from before the first genuine open. With
// more than one row the test switches away and re-opens, so the assertion below
// sees that fresh open; with a server that lists only one session the first
// click is itself the fresh open (clicking it again would early-return), and
// clearing here would throw that real request away.
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
let openedId = null;
for (const candidate of candidates) {
await page.click(`#chatRows .chat-row[data-session="${candidate}"]`);
@@ -2702,15 +2737,17 @@ try {
}
// Leave the discovered session first: the loop above already opened it, and
// openChatSession keeps a loaded thread, so clicking it again would early-return
// and send nothing. Opening a different row restores a genuine fresh open.
// and send nothing. Opening a different row restores a genuine fresh open. With
// only one listed session there is no other row, so the loop's own open above is
// the fresh-open proof.
const otherRow = candidates.find((id) => id !== openedId);
if (otherRow) {
await page.click(`#chatRows .chat-row[data-session="${otherRow}"]`);
await new Promise((resolve) => setTimeout(resolve, 600));
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
} else {
console.log(" -- the server lists one session, so the first open above is the fresh-open proof");
}
// Record the frames the page sends, so the C11 chat_shells fetch on open is
// asserted rather than assumed.
await page.evaluate(`(() => { window.__pipelinesSentTypes = []; return true; })()`);
await page.click(`#chatRows .chat-row[data-session="${openedId}"]`);
await page.waitForSelector("#chatTranscript", { timeout: 25000 });
await eventually(
@@ -3184,7 +3221,8 @@ try {
if (!beforeDialog || beforeDialog.top == null || beforeDialog.top === 0) {
throw new Error(`the transcript was not mid-scroll before the dialog: ${JSON.stringify(beforeDialog)}`);
}
await page.click(`#chatRows .chat-row[data-session="${openedId}"] .chat-close`);
await openChatRowMenu(openedId);
await page.click(`#chatRows .chat-row[data-session="${openedId}"] .chat-menu-close`);
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
const closeDialog = await page.evaluate(`(() => ({
title: document.querySelector(".confirm-chat-close .confirm-title")?.textContent ?? "",
@@ -3603,10 +3641,11 @@ try {
// (e) `/new` creates a fresh throwaway session (C2's chat_create, sent directly
// until C2 lands) and opens it. The operator's session is left untouched. The
// throwaway is created EPHEMERAL: this check drives the real page, so without it
// every run would leave a permanent "New chat" in the operator's chat list (the
// server writes no operator-registry row for an ephemeral create).
await page.evaluate(`window.__pipelinesEphemeralChat = true`);
// throwaway must stay a listed server session: C12's notice check switches away
// to another row and back to it, and C13 reads its row for the device-local
// rename; an ephemeral create (2fe6301's `__pipelinesEphemeralChat`) is hidden
// from `chat_sessions`, so it is deliberately NOT used here. The session is
// closed again in cleanup, like the New-marker throwaway C13 creates itself.
await page.fill("#chatInput", "/new");
await page.evaluate(
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
@@ -3823,15 +3862,31 @@ try {
),
{ timeout: 15000, what: "the throwaway session to show as closed" },
);
await openChatRowMenu(throwawayId);
const closedRow = await page.evaluate(`(() => {
const row = document.querySelector('.chat-row[data-session="${throwawayId}"]');
row?.scrollIntoView({ block: "center" });
return {
closed: !!row?.querySelector(".chat-closed-chip"),
hasClose: !!row?.querySelector(".chat-close"),
hasReopen: !!row?.querySelector(".chat-reopen"),
items: [...row.querySelectorAll(".chat-menu-panel .chat-menu-item")].map((b) => b.textContent),
hasClose: !!row?.querySelector(".chat-menu-close"),
hasReopen: !!row?.querySelector(".chat-menu-reopen"),
};
})()`);
if (!closedRow.closed || !closedRow.hasReopen || closedRow.hasClose) {
throw new Error(`the closed row's Chat actions menu: ${JSON.stringify(closedRow)}`);
}
if (closedRow.items.join("|") !== "Rename…|Reopen|Hide on this device") {
throw new Error(`the closed row's menu items and order: ${JSON.stringify(closedRow.items)}`);
}
// Close the menu again (a second press on its own button toggles it shut).
await page.evaluate(
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-menu-button')?.click()`,
);
await eventually(
() => page.evaluate(`!document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-menu-panel')`),
{ timeout: 5000, what: "the closed row's menu to close" },
);
// Closing finishes the session: the conversation leaves the pane (back to the
// list with the select hint) and no row stays selected, as Android's
// finishSession does.
@@ -5221,6 +5276,284 @@ try {
);
console.log(" chat_shells re-fetched after the stream reconnect (real request)");
// C13: this device's own chat changes — a local rename that wins over the
// server's title, the hide + Undo report, and the seen/New marker. Every
// action here is device-local (localStorage): nothing is sent to the server for
// a rename or a hide, and the closed throwaway session from C8 is the row used
// for the rename/hide captures so the operator's live session is never hidden
// in a way the run leaves behind (Hide is undone before the marker step).
step("C13: local rename/hide, the hide snackbar and the seen/New marker");
await ensureConnected();
await page.evaluate(`(() => {
const tab = [...document.querySelectorAll("nav.tabs button.tab")].find((b) => b.textContent.trim() === "Chat");
if (tab) tab.click();
return !!tab;
})()`);
await page.waitForSelector("#chatRows .chat-row", { timeout: 25000 });
// (a) Rename… opens the dialog: its exact title, the field label, the pre-fill
// and the helper, and Save disabled while the trimmed value is blank.
await openChatRowMenu(throwawayId);
await page.click(`#chatRows .chat-row[data-session="${throwawayId}"] .chat-menu-rename`);
await page.waitForSelector(".confirm-chat-rename", { timeout: 10000 });
await page.waitForSelector("#chatRenameInput", { timeout: 5000 });
const renameDialog = await page.evaluate(`(() => ({
title: document.querySelector(".confirm-chat-rename .confirm-title")?.textContent ?? "",
label: document.querySelector(".confirm-chat-rename .chat-rename-label")?.textContent ?? "",
value: document.querySelector("#chatRenameInput")?.value ?? null,
helper: document.querySelector(".confirm-chat-rename .chat-rename-helper")?.textContent ?? "",
save: document.querySelector(".chat-rename-save")?.textContent ?? "",
cancel: document.querySelector(".chat-rename-cancel")?.textContent ?? "",
}))()`);
if (renameDialog.title !== "Rename chat") throw new Error(`rename title: ${renameDialog.title}`);
if (renameDialog.label !== "Name") throw new Error(`rename field label: ${renameDialog.label}`);
if (renameDialog.value !== "New chat") throw new Error(`rename pre-fill: ${JSON.stringify(renameDialog.value)}`);
if (
renameDialog.helper !==
"The server has no rename for a chat, so this name is kept on this device."
) {
throw new Error(`rename helper: ${renameDialog.helper}`);
}
if (renameDialog.save !== "Save" || renameDialog.cancel !== "Cancel") {
throw new Error(`rename buttons: ${JSON.stringify(renameDialog)}`);
}
// Typing toggles Save in place: blank (whitespace) disables it, a real value
// enables it, with no re-render of the transcript underneath.
await page.fill("#chatRenameInput", " ");
await eventually(
() => page.evaluate(`document.querySelector(".chat-rename-save")?.disabled === true`),
{ timeout: 5000, what: "Save to disable while the name is blank" },
);
console.log(` rename dialog: "${renameDialog.title}" / "${renameDialog.label}" pre-filled "${renameDialog.value}"; Save disabled while blank`);
await shot("72-chat-rename-dialog.png");
// (b) Save a locally-titled name; the row shows it now and after a server list
// refresh, and the overrides JSON is in localStorage under its own key.
await page.fill("#chatRenameInput", "Local capture chat");
await eventually(
() => page.evaluate(`document.querySelector(".chat-rename-save")?.disabled === false`),
{ timeout: 5000, what: "Save to enable for a non-blank name" },
);
await page.click(".chat-rename-save");
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-rename")`), {
timeout: 5000,
what: "the rename dialog to close on Save",
});
const renamedTitle = await eventually(
async () => {
const value = await page.evaluate(
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-row-title')?.textContent ?? ""`,
);
return value === "Local capture chat" ? value : false;
},
{ timeout: 8000, what: "the renamed row to show its local title" },
);
console.log(` row ${throwawayId} shows the local title "${renamedTitle}"`);
// Refresh the list from the server (the same header Refresh the page offers);
// the local title must still win over the server's own.
await page.clickText("nav.tabs button.ghost", "Refresh");
await eventually(
() =>
page.evaluate(
`document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-row-title')?.textContent === "Local capture chat"`,
),
{ timeout: 15000, what: "the local title to survive a server list refresh" },
);
const storedOverrides = await page.evaluate(`localStorage.getItem("pipelines.web.chatOverrides.v1")`);
const overridesJson = JSON.parse(storedOverrides ?? "{}");
if (overridesJson.titles?.[throwawayId] !== "Local capture chat") {
throw new Error(`the local title was not persisted: ${storedOverrides}`);
}
console.log(` after a server list refresh the row still reads "${renamedTitle}"; localStorage ${storedOverrides}`);
await shot("73-chat-renamed-row.png");
// The final row's menu must not be clipped by the list's rounded-corner
// overflow: assert the Hide item's own centre is the element a real click
// would hit (the review measured the panel cut off at the list's bottom edge
// on the last rows). The menu is closed again without acting on it.
const lastRowId = await page.evaluate(
`(() => { const rows = [...document.querySelectorAll("#chatRows .chat-row")]; return rows.at(-1)?.dataset.session ?? ""; })()`,
);
if (!lastRowId) throw new Error("C13: no last row to test the menu against");
await page.evaluate(`document.querySelector('.chat-row[data-session="${lastRowId}"]')?.scrollIntoView({ block: "center" })`);
await openChatRowMenu(lastRowId);
const lastMenuHit = await page.evaluate(`(() => {
const button = document.querySelector('.chat-row[data-session="${lastRowId}"] .chat-menu-hide');
if (!button) return { found: false };
const rect = button.getBoundingClientRect();
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
const hit = document.elementFromPoint(x, y);
return {
found: true,
label: button.textContent,
hit: hit === button || button.contains(hit),
rect: { top: rect.top, bottom: rect.bottom },
viewport: window.innerHeight,
listBottom: document.querySelector(".chat-list")?.getBoundingClientRect().bottom ?? null,
};
})()`);
if (!lastMenuHit.found || !lastMenuHit.hit) {
throw new Error(`C13: the last row's menu item is not clickable: ${JSON.stringify(lastMenuHit)}`);
}
console.log(
` last row ${lastRowId}: "${lastMenuHit.label}" is hit-testable at its centre (menu bottom ${Math.round(lastMenuHit.rect.bottom)}, viewport ${lastMenuHit.viewport})`,
);
await page.click(`#chatRows .chat-row[data-session="${lastRowId}"] .chat-menu-button`);
await eventually(
() => page.evaluate(`!document.querySelector('.chat-row[data-session="${lastRowId}"] .chat-menu-panel')`),
{ timeout: 5000, what: "the last row's menu to close again" },
);
// (c) Hide the row the conversation is open on: it disappears, its conversation
// closes, and one snackbar carries the exact message and Undo. Undo puts the
// row back and leaves the server untouched.
const activeBeforeHide = await page.evaluate(
`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`,
);
if (!activeBeforeHide) throw new Error("C13: no conversation was open before the hide");
await openChatRowMenu(activeBeforeHide);
await page.click(`#chatRows .chat-row[data-session="${activeBeforeHide}"] .chat-menu-hide`);
await page.waitForSelector(".chat-snackbar", { timeout: 10000 });
const hiddenState = await page.evaluate(`(() => ({
row: !!document.querySelector('.chat-row[data-session="${activeBeforeHide}"]'),
snackbars: document.querySelectorAll(".chat-snackbar").length,
message: document.querySelector(".chat-snackbar-message")?.textContent ?? "",
undo: document.querySelector(".chat-snackbar-undo")?.textContent ?? "",
hint: document.querySelector(".chat-detail .empty .muted")?.textContent ?? "",
composer: !!document.querySelector("#chatComposer"),
hidden: JSON.parse(localStorage.getItem("pipelines.web.chatOverrides.v1") ?? "{}").hidden ?? [],
}))()`);
if (hiddenState.row) throw new Error(`C13: the hidden row is still listed: ${JSON.stringify(hiddenState)}`);
if (hiddenState.snackbars !== 1) throw new Error(`C13: expected one snackbar, got ${hiddenState.snackbars}`);
if (hiddenState.message !== "Hidden on this device; the chat stays on the server.") {
throw new Error(`C13: snackbar message ${JSON.stringify(hiddenState.message)}`);
}
if (hiddenState.undo !== "Undo") throw new Error(`C13: snackbar action ${JSON.stringify(hiddenState.undo)}`);
if (hiddenState.composer || hiddenState.hint !== "Select a chat to open it.") {
throw new Error(`C13: hiding the open conversation did not close it: ${JSON.stringify(hiddenState)}`);
}
if (!hiddenState.hidden.includes(activeBeforeHide)) {
throw new Error(`C13: the hidden id was not persisted: ${JSON.stringify(hiddenState.hidden)}`);
}
console.log(
` hid ${activeBeforeHide}: row gone, conversation closed, one snackbar "${hiddenState.message}" with "${hiddenState.undo}"`,
);
await shot("74-chat-hide-snackbar.png");
// Undo restores the row (and only here: the conversation stays closed, exactly
// as Android's undoRemove does) and clears the hidden list.
await page.click(".chat-snackbar-undo");
await eventually(
() =>
page.evaluate(
`!!document.querySelector('.chat-row[data-session="${activeBeforeHide}"]') && !document.querySelector(".chat-snackbar")`,
),
{ timeout: 8000, what: "Undo to restore the hidden row and clear the snackbar" },
);
const afterUndo = await page.evaluate(
`JSON.parse(localStorage.getItem("pipelines.web.chatOverrides.v1") ?? "{}").hidden ?? []`,
);
if (afterUndo.includes(activeBeforeHide)) {
throw new Error(`C13: Undo left the id hidden: ${JSON.stringify(afterUndo)}`);
}
console.log(` Undo restored ${activeBeforeHide}; hidden ids now ${JSON.stringify(afterUndo)}`);
// (d) The "New" marker, honestly: the restart rule. A fresh throwaway is
// prompted and stopped, and the page is then reloaded — its threads are empty
// while the persisted watermark predates the turn, so the non-active row reads
// New after the reconnect. First reopen the operator conversation so `/new`
// has a directory.
await page.evaluate(`document.querySelector('.chat-row[data-session="${sessionId}"]')?.click()`);
await page.waitForSelector("#chatTranscript", { timeout: 20000 });
await page.fill("#chatInput", "/new");
await page.evaluate(
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
);
const newMarkerId = await eventually(
async () => {
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`);
return id && id !== sessionId && id !== throwawayId ? id : false;
},
{ timeout: 25000, what: "the fresh throwaway session to open for the New-marker step" },
);
await page.waitForSelector("#chatInput", { timeout: 10000 });
// The watermark for this session is seeded at its creation recency; a real
// prompt then advances the server's updated_at past it.
await page.fill("#chatInput", "Reply with exactly one word: hi");
await page.evaluate(
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
);
await page.waitForSelector("#chatStop", { timeout: 20000 });
await page.click("#chatStop");
await eventually(
() =>
page.evaluate(
`[...document.querySelectorAll(".chat-command-notice-text")].some((n) => n.textContent === "Stopping the running turn…")`,
),
{ timeout: 15000, what: "the New-marker throwaway turn to be interrupted" },
);
const watermarkBefore = await page.evaluate(
`JSON.parse(localStorage.getItem("pipelines.web.chatSeen.v1") ?? "{}").seenAt?.[${JSON.stringify(newMarkerId)}] ?? 0`,
);
// A reload empties the page's threads and re-reads the server list: the row is
// no longer active, and its server recency has moved past the stored watermark.
await page.evaluate(`location.reload()`);
await page.waitForSelector("#url", { timeout: 15000 });
// A reload starts idle: open the configured endpoint through the header's own
// control (the same connect-only path the Settings destination uses).
await page.evaluate(`(() => {
const control = document.querySelector("#reconnectBtn") || document.querySelector("#connectBtn");
if (control) control.click();
return !!control;
})()`);
await ensureConnected(30000);
await page.clickText("nav.tabs button.tab", "Chat");
await page.waitForSelector("#chatRows .chat-row", { timeout: 25000 });
const newMarker = await eventually(
async () => {
const value = await page.evaluate(`(() => {
const row = document.querySelector('.chat-row[data-session="${newMarkerId}"]');
const word = row?.querySelector(".chat-activity-new .chat-activity-word")?.textContent ?? "";
return { word, selected: !!row?.classList.contains("selected") };
})()`);
return value.word === "New" ? value : false;
},
{ timeout: 15000, what: "the non-active row to carry the New marker after the reload" },
);
const watermarkAfter = await page.evaluate(
`JSON.parse(localStorage.getItem("pipelines.web.chatSeen.v1") ?? "{}").seenAt?.[${JSON.stringify(newMarkerId)}] ?? 0`,
);
console.log(
` after the reload, non-active ${newMarkerId} carries the New marker ` +
`(watermark before the turn ${watermarkBefore}, after the reload ${watermarkAfter})`,
);
await shot("75-chat-new-marker.png");
// Cleanup: open the New-marker throwaway and /close it, so the run leaves no
// open session of its own (the rename override on the earlier throwaway is
// device-local and the browser profile is temporary).
await page.evaluate(`document.querySelector('.chat-row[data-session="${newMarkerId}"]')?.click()`);
await page.waitForSelector("#chatInput", { timeout: 20000 });
await page.fill("#chatInput", "/close");
await page.evaluate(
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
);
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
await page.click(".confirm-chat-close .confirm-accept");
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
timeout: 15000,
what: "the New-marker throwaway to close",
});
await eventually(
() =>
page.evaluate(
`!!document.querySelector('.chat-row[data-session="${newMarkerId}"] .chat-closed-chip')`,
),
{ timeout: 15000, what: "the New-marker throwaway to show as closed" },
);
console.log(` cleanup: /close closed the New-marker throwaway ${newMarkerId}`);
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);
}