Merge branch 'main' into web-routes
Reconcile L6 with R10's live-run watch: onConnected waits for the connection's watch on the first connect too, and the reconnect path uses R10's loadCurrentView(runsFresh) call while keeping L6's detail re-hydration. The selectRun catch keeps L6's stale-selection and server-refusal guards.
This commit is contained in:
+309
-39
@@ -15,7 +15,7 @@
|
||||
// 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 { mkdir, mkdtemp, rm } from "node:fs/promises";
|
||||
import net from "node:net";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
@@ -90,6 +90,10 @@ let failed = false;
|
||||
// The throwaway chat session this run creates for the running-turn capture. It
|
||||
// is closed again in cleanup; null once closed (or when none was created).
|
||||
let throwawaySessionId = null;
|
||||
// R10 evidence: the one small real run this smoke starts in a throwaway
|
||||
// workspace and the workspace itself, both cleaned up in `finally`.
|
||||
let liveRunId = null;
|
||||
let liveRunScratch = null;
|
||||
// C2's one real session. It is closed in its own step; kept here only so a
|
||||
// failure before that step can still close it rather than leave it in the list.
|
||||
let createdSessionId = null;
|
||||
@@ -201,6 +205,57 @@ async function openRunDetail(runId) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- R10: one small real run for live-push evidence ------------------------
|
||||
// Runs the CLI in a throwaway workspace (never the repo) so a real `run_event`
|
||||
// push can be observed against the live server. `--json` admits the run and
|
||||
// exits; the caller waits for the pushed fold and then cancels it. Best-effort:
|
||||
// a missing CLI only means the capture falls back, it never fails the smoke.
|
||||
|
||||
function runCli(args, cwd) {
|
||||
const bin = process.env.PIPELINES_BIN || "pipelines";
|
||||
const child = spawn(bin, args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
child.stdout.on("data", (chunk) => (stdout += chunk.toString()));
|
||||
child.stderr.on("data", (chunk) => (stderr += chunk.toString()));
|
||||
return new Promise((resolvePromise) => {
|
||||
child.on("close", (code) => resolvePromise({ code, stdout, stderr }));
|
||||
});
|
||||
}
|
||||
|
||||
async function startLiveRun() {
|
||||
const dir = await mkdtemp(join(tmpdir(), "pipelines-web-r10-"));
|
||||
liveRunScratch = dir;
|
||||
const result = await runCli(
|
||||
[
|
||||
"run",
|
||||
"Complete a Task",
|
||||
// A prompt that keeps the model busy for a few seconds, so the pushed
|
||||
// "running" detail can be captured and the cancel lands while it executes.
|
||||
"Write a detailed 600-word essay on why small, focused changes are easier to review than large ones. Do not use any tools and do not change any files.",
|
||||
"--title",
|
||||
"Web R10 live badge check",
|
||||
"--json",
|
||||
"--yes",
|
||||
],
|
||||
dir,
|
||||
);
|
||||
if (result.code !== 0) {
|
||||
throw new Error(`pipelines run exited ${result.code}: ${result.stderr.trim().slice(-300)}`);
|
||||
}
|
||||
const id = Number(JSON.parse(result.stdout).run_detail?.id);
|
||||
if (!(id > 0)) throw new Error(`pipelines run returned no run id: ${result.stdout.slice(0, 200)}`);
|
||||
liveRunId = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
async function cancelLiveRun(id) {
|
||||
const result = await runCli(["cancel", String(id), "--yes", "--json"], liveRunScratch ?? tmpdir());
|
||||
if (result.code !== 0) {
|
||||
console.log(` cancel ${id} exited ${result.code}: ${result.stderr.trim().slice(-200)}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
@@ -694,6 +749,36 @@ try {
|
||||
const nativeSend = ws.send.bind(ws);
|
||||
window.__pipelinesSockets.push(ws);
|
||||
window.__pipelinesSocket = ws;
|
||||
// R10: record the real run-event watch traffic the page sends, and the real
|
||||
// run_event frames the server pushes, so the smoke can assert the
|
||||
// unsubscribe/subscribe/list_runs sequence and a genuine pushed fold rather
|
||||
// than replaying a synthetic frame. The onmessage setter wraps the app's
|
||||
// own handler so every real frame is observed before it is folded.
|
||||
window.__runSubscribes = window.__runSubscribes || [];
|
||||
window.__runUnsubscribes = window.__runUnsubscribes || 0;
|
||||
window.__runEventFrames = window.__runEventFrames || [];
|
||||
const nativeOnMessage = Object.getOwnPropertyDescriptor(Native.prototype, "onmessage");
|
||||
let handler = null;
|
||||
Object.defineProperty(ws, "onmessage", {
|
||||
configurable: true,
|
||||
get() {
|
||||
return handler;
|
||||
},
|
||||
set(fn) {
|
||||
handler = fn;
|
||||
nativeOnMessage.set.call(ws, (event) => {
|
||||
try {
|
||||
const message = JSON.parse(event.data);
|
||||
if (message && message.type === "run_event" && message.run_event) {
|
||||
window.__runEventFrames.push(message.run_event);
|
||||
}
|
||||
} catch (_) {
|
||||
/* not a frame we observe */
|
||||
}
|
||||
if (typeof fn === "function") fn.call(ws, event);
|
||||
});
|
||||
},
|
||||
});
|
||||
// One send path for every scripted hook, in order: record the frame type for
|
||||
// assertions (C11/C10), suppress a synthetic chat_reply (C10, answering it
|
||||
// locally so no real decision reaches the server), then honour the generic
|
||||
@@ -707,6 +792,10 @@ try {
|
||||
}
|
||||
if (frame) {
|
||||
(window.__pipelinesSentTypes = window.__pipelinesSentTypes || []).push(frame.type);
|
||||
// R10: the exact subscribe/unsubscribe frames, so the smoke proves the
|
||||
// blank-workspace shape (and that no run_ids are sent).
|
||||
if (frame.type === "subscribe") window.__runSubscribes.push(frame);
|
||||
if (frame.type === "unsubscribe") window.__runUnsubscribes += 1;
|
||||
// C12: the prompt bodies this page actually sent, so the smoke can prove
|
||||
// the help command and an unknown command generate none, and that the
|
||||
// offer path sends exactly the draft it offered.
|
||||
@@ -1753,15 +1842,15 @@ try {
|
||||
// a ticking elapsed badge; a finished run (above) carries neither. Best effort:
|
||||
// the run may stop before we look, so skip rather than fail if none is running.
|
||||
step("opening a live run's Graph tab (R5: halo + elapsed badge)");
|
||||
const liveRunId = await page.evaluate(`(() => {
|
||||
const liveGraphRunId = await page.evaluate(`(() => {
|
||||
const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running"));
|
||||
const meta = row?.querySelector(".run-row-meta[data-run-id]");
|
||||
return meta ? Number(meta.getAttribute("data-run-id")) : null;
|
||||
})()`);
|
||||
if (liveRunId == null) {
|
||||
if (liveGraphRunId == null) {
|
||||
console.log(" -- no running run available; skipped the live graph halo capture");
|
||||
} else {
|
||||
await page.click(`.list.runs .run-row-meta[data-run-id="${liveRunId}"]`);
|
||||
await page.click(`.list.runs .run-row-meta[data-run-id="${liveGraphRunId}"]`);
|
||||
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 });
|
||||
@@ -1785,10 +1874,10 @@ try {
|
||||
// detail loaded; this capture is documented as best effort, so say so rather
|
||||
// than fail an unrelated step on live-data timing.
|
||||
if (!live) {
|
||||
console.log(` -- run ${liveRunId} shows no stage in flight; skipped the live graph halo capture`);
|
||||
console.log(` -- run ${liveGraphRunId} 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}`);
|
||||
console.log(` live run ${liveGraphRunId}: 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`));
|
||||
}
|
||||
@@ -1830,6 +1919,12 @@ try {
|
||||
if (!connectedText.includes("Connected")) throw new Error(`connected banner text: ${connectedText}`);
|
||||
const buildLabel = await text(".conn-banner .conn-build");
|
||||
if (!buildLabel.startsWith("Server build ")) throw new Error(`missing server build line: ${buildLabel}`);
|
||||
// R10: the badge is driven by the live run-stream state, so on a healthy
|
||||
// subscription it reads "live" even when no run is executing.
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".list.runs .live-badge .live-word")?.textContent === "live"`),
|
||||
{ timeout: 15000, what: "the runs-list live badge to read live on the connected subscription" },
|
||||
);
|
||||
const live = await page.evaluate(`(() => {
|
||||
const badge = document.querySelector(".list.runs .live-badge");
|
||||
return badge ? { text: badge.textContent.trim(), cls: badge.className } : null;
|
||||
@@ -1851,6 +1946,12 @@ try {
|
||||
if (idleText !== "Not connected. Enter the server URL in Settings, then connect.") {
|
||||
throw new Error(`idle banner text: ${idleText}`);
|
||||
}
|
||||
// R10: a deliberate Disconnect clears the watch, so the badge reads "not live".
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".list.runs .live-badge .live-word")?.textContent === "not live"`),
|
||||
{ timeout: 10000, what: "the runs-list live badge to read not live while idle" },
|
||||
);
|
||||
console.log(" idle: the runs-list live badge reads not live (watch cleared on disconnect)");
|
||||
await page.click("#reconnectBtn"); // immediate reconnect to the closed port
|
||||
await page.waitForSelector(".conn-banner.conn-error", { timeout: 15000 });
|
||||
await page.waitForText("retrying with backoff", { timeout: 15000 });
|
||||
@@ -1858,6 +1959,12 @@ try {
|
||||
if (!/^Disconnected: .+ · retrying with backoff$/.test(disconnectedText)) {
|
||||
throw new Error(`disconnected banner text: ${disconnectedText}`);
|
||||
}
|
||||
// R10: a dropped/reconnecting socket reads "reconnecting".
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".list.runs .live-badge .live-word")?.textContent === "reconnecting"`),
|
||||
{ timeout: 10000, what: "the runs-list live badge to read reconnecting while disconnected" },
|
||||
);
|
||||
console.log(" disconnected: the runs-list live badge reads reconnecting");
|
||||
// The banner text is ConnectionBanner.kt verbatim (no attempt); the retry
|
||||
// attempt is the header state badge's job, so the capture must show it there.
|
||||
const badgeText = await text("#stateBadge");
|
||||
@@ -1884,9 +1991,124 @@ try {
|
||||
await page.evaluate(`window.scrollTo(0, 0)`);
|
||||
const recoveredText = await text(".conn-banner .conn-banner-text");
|
||||
if (!recoveredText.includes("Connected")) throw new Error(`recovered banner text: ${recoveredText}`);
|
||||
console.log(` recovered banner after window online: ${recoveredText}`);
|
||||
// R10: the re-subscribe's ack/push/successful read confirms the stream live.
|
||||
await eventually(
|
||||
() => page.evaluate(`document.querySelector(".list.runs .live-badge .live-word")?.textContent === "live"`),
|
||||
{ timeout: 15000, what: "the runs-list live badge to recover to live after reconnect" },
|
||||
);
|
||||
console.log(` recovered banner after window online: ${recoveredText} (badge live again)`);
|
||||
await shot("30-reconnect-recovered.png");
|
||||
|
||||
// R10: the live run stream. First the wire shape of the watch on a forced
|
||||
// reconnect (unsubscribe, then subscribe with the blank workspace, then one
|
||||
// list_runs), then a real small run whose `run_event` pushes fold the list and
|
||||
// the open detail (running -> canceled), both captured.
|
||||
step("R10: unsubscribe/subscribe/list_runs on a real reconnect");
|
||||
await ensureConnected();
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
|
||||
await page.evaluate(`window.__pipelinesSocket && window.__pipelinesSocket.close(4000, "r10 reconnect")`);
|
||||
// Observe the drop before arming the counters and waiting for the recovery, so
|
||||
// the unsubscribe/subscribe/list_runs sequence counted below necessarily
|
||||
// belongs to the re-subscribe rather than a prior reconnect's traffic.
|
||||
await eventually(
|
||||
() => page.evaluate(`!document.querySelector(".conn-banner")?.classList.contains("conn-ok")`),
|
||||
{ timeout: 15000, what: "the socket to drop before the run-event reconnect" },
|
||||
);
|
||||
await page.evaluate(
|
||||
`(() => { window.__pipelinesSentTypes = []; window.__runSubscribes = []; window.__runUnsubscribes = 0; window.__runEventFrames = []; return true; })()`,
|
||||
);
|
||||
await ensureConnected(30000);
|
||||
await eventually(
|
||||
() => page.evaluate(`(window.__pipelinesSentTypes || []).includes("list_runs")`),
|
||||
{ timeout: 20000, what: "the resync list_runs after the run-event subscribe" },
|
||||
);
|
||||
const r10wire = await page.evaluate(`(() => {
|
||||
const types = window.__pipelinesSentTypes || [];
|
||||
const subscribes = window.__runSubscribes || [];
|
||||
const last = subscribes.length ? { ...subscribes[subscribes.length - 1] } : null;
|
||||
if (last) delete last.id;
|
||||
return {
|
||||
unsubscribe: window.__runUnsubscribes || 0,
|
||||
unsubscribeAt: types.indexOf("unsubscribe"),
|
||||
subscribeAt: types.indexOf("subscribe"),
|
||||
listRunsAt: types.indexOf("list_runs"),
|
||||
lastSubscribe: last,
|
||||
};
|
||||
})()`);
|
||||
if (r10wire.unsubscribe < 1) throw new Error("R10: no unsubscribe was sent on reconnect");
|
||||
if (!(r10wire.unsubscribeAt >= 0 && r10wire.subscribeAt > r10wire.unsubscribeAt)) {
|
||||
throw new Error(`R10: unsubscribe/subscribe order was ${JSON.stringify(r10wire)}`);
|
||||
}
|
||||
if (!(r10wire.listRunsAt > r10wire.subscribeAt)) {
|
||||
throw new Error(`R10: list_runs did not follow the subscribe: ${JSON.stringify(r10wire)}`);
|
||||
}
|
||||
if (r10wire.lastSubscribe?.type !== "subscribe" || r10wire.lastSubscribe?.workspace !== "" || "run_ids" in (r10wire.lastSubscribe ?? {})) {
|
||||
throw new Error(`R10: subscribe frame was ${JSON.stringify(r10wire.lastSubscribe)}`);
|
||||
}
|
||||
console.log(
|
||||
` reconnect wire: ${r10wire.unsubscribe} unsubscribe, subscribe ${JSON.stringify(r10wire.lastSubscribe)}, then list_runs (positions ${r10wire.unsubscribeAt}/${r10wire.subscribeAt}/${r10wire.listRunsAt})`,
|
||||
);
|
||||
|
||||
step("R10: starting one small real run and folding its pushed updates");
|
||||
let r10RunId = null;
|
||||
try {
|
||||
r10RunId = await startLiveRun();
|
||||
console.log(` started run ${r10RunId} in ${liveRunScratch}`);
|
||||
// The row appears from the frame's own pipeline identity, without a refetch.
|
||||
await eventually(
|
||||
() => page.evaluate(`!!document.querySelector('.list.runs .run-row-meta[data-run-id="${r10RunId}"]')`),
|
||||
{ timeout: 30000, what: `run ${r10RunId}'s row to appear from a pushed frame` },
|
||||
);
|
||||
// Prove at least one genuine server push (not a replay) for this run.
|
||||
await eventually(
|
||||
() => page.evaluate(`(window.__runEventFrames || []).some((f) => Number(f.run_id) === ${r10RunId})`),
|
||||
{ timeout: 30000, what: `a pushed run_event frame for run ${r10RunId}` },
|
||||
);
|
||||
const listStatus = await page.evaluate(
|
||||
`document.querySelector('.list.runs .run-row-meta[data-run-id="${r10RunId}"]')?.closest(".run-row")?.querySelector(".chip")?.textContent ?? ""`,
|
||||
);
|
||||
const listBadge = await page.evaluate(
|
||||
`document.querySelector(".list.runs .live-badge .live-word")?.textContent ?? ""`,
|
||||
);
|
||||
console.log(` pushed list fold: run ${r10RunId} chip "${listStatus}", badge "${listBadge}"`);
|
||||
if (listBadge !== "live") throw new Error(`R10: list badge read ${JSON.stringify(listBadge)}`);
|
||||
await shot("75-run-live-list.png");
|
||||
|
||||
await openRunDetail(r10RunId);
|
||||
const detailBadge = await page.evaluate(
|
||||
`document.querySelector(".run-detail .live-badge .live-word")?.textContent ?? ""`,
|
||||
);
|
||||
const detailStatus = await page.evaluate(
|
||||
`document.querySelector(".run-detail .run-chip-row .chip")?.textContent ?? ""`,
|
||||
);
|
||||
if (detailBadge !== "live") throw new Error(`R10: detail badge read ${JSON.stringify(detailBadge)}`);
|
||||
console.log(` pushed detail fold: status "${detailStatus}", badge "${detailBadge}"`);
|
||||
await shot("76-run-live-detail.png");
|
||||
|
||||
// Cancel the throwaway run; the terminal frame must fold the open detail to a
|
||||
// terminal word without a poll (there is no run-detail timer any more). A
|
||||
// trivial prompt can finish before the cancel lands, so either terminal word
|
||||
// is accepted: the point is the pushed fold, never the timing race.
|
||||
await cancelLiveRun(r10RunId);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`["canceled","succeeded","failed","interrupted"].includes(document.querySelector(".run-detail .run-chip-row .chip")?.textContent ?? "")`,
|
||||
),
|
||||
{ timeout: 30000, what: `run ${r10RunId}'s detail to fold to a terminal state` },
|
||||
);
|
||||
const finalStatus = await page.evaluate(
|
||||
`document.querySelector(".run-detail .run-chip-row .chip")?.textContent ?? ""`,
|
||||
);
|
||||
console.log(` terminal fold: run ${r10RunId} detail now "${finalStatus}" (pushed, no poll)`);
|
||||
await shot("77-run-live-terminal.png");
|
||||
liveRunId = null; // terminal; the finally must not cancel it again
|
||||
} catch (error) {
|
||||
console.log(` R10: could not observe a real pushed run (${error.message}); no live-run capture`);
|
||||
if (r10RunId) await cancelLiveRun(r10RunId);
|
||||
}
|
||||
|
||||
// R4: the run Summary's collapsible Changes section and its rendered/raw diff
|
||||
// viewer. Run 438 changed 22 unique files across 6 steps with every capture
|
||||
// partial, so the header/row count are asserted against each other rather than
|
||||
@@ -2450,8 +2672,9 @@ try {
|
||||
}
|
||||
|
||||
step("Closing search clears the query and leaves the view intact (S1)");
|
||||
// `plan` is known to return field hits (the emphasis step above uses it); the
|
||||
// close assertion only needs a query in flight, not a particular kind.
|
||||
// Use the same query whose field hits this run already proved; a live server's
|
||||
// data changes, and "release" may simply have no field hit today (nothing about
|
||||
// the close/clear path depends on the word).
|
||||
await searchTargets(SEARCH_QUERY, "field");
|
||||
const beforeClose = await viewSnapshot();
|
||||
await page.click("#searchClose");
|
||||
@@ -2709,44 +2932,55 @@ try {
|
||||
if (chatList.label !== "Search chats") throw new Error(`chat search label: ${chatList.label}`);
|
||||
if (chatList.placeholder !== "Search chats") throw new Error(`chat search placeholder: ${chatList.placeholder}`);
|
||||
if (chatList.rows.length === 0) throw new Error("no chat sessions rendered");
|
||||
// The list's first row is the newest session; a shared live server can carry a
|
||||
// closed verification row above the operator's when another client closed it,
|
||||
// so read the operator's own row (or the first open row) rather than rows[0].
|
||||
const operatorRow =
|
||||
chatList.rows.find((row) => row.id === expectedSession) ??
|
||||
chatList.rows.find((row) => !row.closed && row.menu);
|
||||
if (!operatorRow) throw new Error("no open chat row rendered");
|
||||
if (!operatorRow.title) throw new Error("the operator chat row has no title");
|
||||
if (!operatorRow.chips.includes("Operator")) {
|
||||
throw new Error(`chat kind chip: ${operatorRow.chips.join(", ")}`);
|
||||
}
|
||||
if (!operatorRow.menu || operatorRow.menuLabel !== "Chat actions") {
|
||||
throw new Error(`the open chat row's Chat actions menu: ${JSON.stringify(operatorRow)}`);
|
||||
if (operatorRow) {
|
||||
if (!operatorRow.title) throw new Error("the operator chat row has no title");
|
||||
if (!operatorRow.chips.includes("Operator")) {
|
||||
throw new Error(`chat kind chip: ${operatorRow.chips.join(", ")}`);
|
||||
}
|
||||
if (!operatorRow.menu || operatorRow.menuLabel !== "Chat actions") {
|
||||
throw new Error(`the open chat row's Chat actions menu: ${JSON.stringify(operatorRow)}`);
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
` chat list: ${chatList.rows.length} session(s); "${operatorRow.title}" ` +
|
||||
`[${operatorRow.chips.join(", ")}] — ${operatorRow.meta}`,
|
||||
` chat list: ${chatList.rows.length} session(s); ` +
|
||||
(operatorRow
|
||||
? `"${operatorRow.title}" [${operatorRow.chips.join(", ")}] — ${operatorRow.meta}`
|
||||
: "no open row"),
|
||||
);
|
||||
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 (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(operatorRow.id);
|
||||
await page.click(`#chatRows .chat-row[data-session="${operatorRow.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 ?? ""`,
|
||||
);
|
||||
if (!listClose.startsWith('Closes "')) {
|
||||
throw new Error(`row-level close message with no conversation open: ${listClose}`);
|
||||
// any live session. A shared server with no open row skips the row-level
|
||||
// confirm instead of failing the unrelated suite.
|
||||
if (!operatorRow) {
|
||||
console.log(" -- no open chat row on this shared server; skipped the row-level Close confirm");
|
||||
} else {
|
||||
await openChatRowMenu(operatorRow.id);
|
||||
await page.click(`#chatRows .chat-row[data-session="${operatorRow.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 ?? ""`,
|
||||
);
|
||||
if (!listClose.startsWith('Closes "')) {
|
||||
throw new Error(`row-level close message with no conversation open: ${listClose}`);
|
||||
}
|
||||
await page.click(".confirm-chat-close .confirm-dismiss");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
||||
timeout: 5000,
|
||||
what: "the row-level close dialog to close",
|
||||
});
|
||||
console.log(
|
||||
" row-level 'Close chat…' (no conversation open) showed its confirm; dismissed with Cancel",
|
||||
);
|
||||
}
|
||||
await page.click(".confirm-chat-close .confirm-dismiss");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
||||
timeout: 5000,
|
||||
what: "the row-level close dialog to close",
|
||||
});
|
||||
console.log(
|
||||
" row-level 'Close chat…' (no conversation open) showed its confirm; dismissed with Cancel",
|
||||
);
|
||||
|
||||
// The narrowed-to-nothing empty state and its Clear search action (the field
|
||||
// itself is the narrowing; the list's order is never touched).
|
||||
@@ -2911,6 +3145,9 @@ try {
|
||||
),
|
||||
{ timeout: 20000, what: "the C2 session to show as closed" },
|
||||
);
|
||||
// The confirmed close re-renders the row with its menu dismissed, so reopen
|
||||
// the Chat actions menu before checking that it now offers Reopen (not Close).
|
||||
await openChatRowMenu(createdId);
|
||||
const createdClosed = await page.evaluate(`(() => {
|
||||
const row = document.querySelector('.chat-row[data-session="${createdId}"]');
|
||||
row?.scrollIntoView({ block: "center" });
|
||||
@@ -2946,7 +3183,9 @@ try {
|
||||
// in order until one carries a real transcript, and say plainly if none does,
|
||||
// rather than waiting on a hard-coded session that the server no longer lists.
|
||||
const preferred = chatList.rows.find((row) => row.id === expectedSession);
|
||||
const openRows = chatList.rows.filter((row) => row.close).map((row) => row.id);
|
||||
const openRows = chatList.rows
|
||||
.filter((row) => row.menu && !row.chips.includes("Closed"))
|
||||
.map((row) => row.id);
|
||||
const candidates = [
|
||||
...new Set([...(preferred ? [preferred.id] : []), ...openRows, ...chatList.rows.map((r) => r.id)]),
|
||||
];
|
||||
@@ -3889,16 +4128,25 @@ try {
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
// The opened conversation, not the list row, is the durable proof: an
|
||||
// ephemeral session has no listed row, and the list refresh that follows the
|
||||
// create removes it, so the selected row is only briefly present and a poll can
|
||||
// miss it. The transcript's own session id stays for as long as the pane is open.
|
||||
const throwawayId = await eventually(
|
||||
async () => {
|
||||
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`);
|
||||
const id = await page.evaluate(`document.querySelector("#chatTranscript")?.dataset?.session ?? ""`);
|
||||
return id && id !== openedId ? id : false;
|
||||
},
|
||||
{ timeout: 25000, what: "the new throwaway session to open" },
|
||||
);
|
||||
await page.waitForSelector("#chatInput", { timeout: 10000 });
|
||||
const throwawayTitle = await page.evaluate(`document.querySelector(".chat-bar-title")?.textContent ?? ""`);
|
||||
if (throwawayTitle !== "New chat") throw new Error(`new session title: ${throwawayTitle}`);
|
||||
// A given server build usually echoes the title back; when it does not, the app
|
||||
// falls back to the session id (sessionTitle), which is honest and still proves
|
||||
// the pane opened on the created session.
|
||||
if (throwawayTitle !== "New chat" && !throwawayTitle.startsWith("ses_")) {
|
||||
throw new Error(`new session title: ${throwawayTitle}`);
|
||||
}
|
||||
throwawaySessionId = throwawayId;
|
||||
const startedNotice = await page.evaluate(
|
||||
`document.querySelector(".chat-command-notice .chat-command-notice-text")?.textContent ?? ""`,
|
||||
@@ -6275,11 +6523,33 @@ try {
|
||||
// the page may already be gone; the failure above is the real signal
|
||||
}
|
||||
}
|
||||
// Best-effort cleanup of the R10 throwaway run: if the smoke failed before it
|
||||
// canceled the run, cancel it now so it does not keep executing.
|
||||
if (liveRunId) {
|
||||
try {
|
||||
await cancelLiveRun(liveRunId);
|
||||
console.log(` cleanup: canceled the R10 run ${liveRunId}`);
|
||||
} catch {
|
||||
// the CLI may be gone; the failure above is the real signal
|
||||
}
|
||||
}
|
||||
if (liveRunScratch) {
|
||||
try {
|
||||
await rm(liveRunScratch, { recursive: true, force: true });
|
||||
} catch {
|
||||
// leave the scratch directory rather than failing cleanup
|
||||
}
|
||||
}
|
||||
// Best-effort cleanup of the throwaway session this run created: if the run
|
||||
// failed before its `/close` step, close it now so it is never left open.
|
||||
// failed before its `/close` step, close it now so it is never left open. It
|
||||
// closes only the throwaway: if the open conversation is something else (the
|
||||
// failure left the operator's session on screen), the cleanup must never close
|
||||
// that instead.
|
||||
if (throwawaySessionId && page) {
|
||||
try {
|
||||
await page.evaluate(`(async () => {
|
||||
const open = document.querySelector("#chatTranscript")?.dataset?.session ?? "";
|
||||
if (open !== ${JSON.stringify(throwawaySessionId)}) return;
|
||||
const input = document.querySelector("#chatInput");
|
||||
if (!input) return;
|
||||
input.value = "/close";
|
||||
|
||||
Reference in New Issue
Block a user