Merge branch 'main' into web-chat-local
Resolve the C11/C12 vs C13 overlap in the chat work:
- PARITY: keep main's done C11/C12 rows and this branch's done C13 row.
- app.js/chat tests: keep both import/helper sets (notices and overrides/seen).
- ui-smoke: keep main's C11 background-task bar, C12 notice checks and the
shared composer throwaway, and C13's row-menu rename/hide/seen checks.
The composer throwaway stays a listed server session: C12 switches away
and back to it and C13 reads its row, which an ephemeral create (2fe6301)
deliberately hides from chat_sessions. The live-run graph halo check is
best effort as its own comment says, so a run with no stage in flight at
capture time skips instead of failing the whole smoke.
This commit is contained in:
@@ -9,7 +9,10 @@ import {
|
||||
BACKGROUND_TASK_VISIBLE_ROWS,
|
||||
CHAT_ACTIONS_LABEL,
|
||||
CHAT_COMMANDS,
|
||||
CHAT_COMMAND_DISMISS_LABEL,
|
||||
CHAT_COMMAND_FAILED_LABEL,
|
||||
CHAT_COMMAND_GLYPH,
|
||||
CHAT_COMMAND_LABEL,
|
||||
CHAT_FOLLOW_THRESHOLD_PX,
|
||||
CHAT_HIDE_ACTION,
|
||||
CHAT_QUEUED_NOTICE,
|
||||
@@ -58,6 +61,7 @@ import {
|
||||
TURN_PHASE_TOOL,
|
||||
TURN_PHASE_WAITING,
|
||||
TURN_THINKING_WINDOW_MILLIS,
|
||||
appendChatNotice,
|
||||
applyChatEvent,
|
||||
applyChatOverrides,
|
||||
applyChatPermission,
|
||||
@@ -77,6 +81,7 @@ import {
|
||||
chatFollowsAt,
|
||||
chatHeaderMeta,
|
||||
chatNoMatchMessage,
|
||||
chatNoticeLabel,
|
||||
chatOpensAtNewest,
|
||||
chatSeenWatermark,
|
||||
chatShowJumpToLatest,
|
||||
@@ -91,6 +96,7 @@ import {
|
||||
decodeChatSeen,
|
||||
deltaPartId,
|
||||
directoryLabel,
|
||||
dismissChatNotice,
|
||||
emptyChatOverrides,
|
||||
emptyChatSeen,
|
||||
encodeChatOverrides,
|
||||
@@ -102,6 +108,7 @@ import {
|
||||
historyResync,
|
||||
isChatSessionUnseen,
|
||||
lineDiff,
|
||||
makeChatNotice,
|
||||
markChatUnseen,
|
||||
mergeHistoryPage,
|
||||
mergeShellFrame,
|
||||
@@ -134,6 +141,7 @@ import {
|
||||
shellCommandSummary,
|
||||
shellOutputState,
|
||||
shellsLoaded,
|
||||
takeChatNoticeOffer,
|
||||
threadElapsedMillis,
|
||||
threadPhase,
|
||||
threadRunningTools,
|
||||
@@ -858,6 +866,103 @@ test("a command notice carries one terminal glyph for both states", () => {
|
||||
assert.equal(CHAT_COMMAND_GLYPH, ">_");
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Local command notices (C12) — ChatStore.kt notice/dismissNotice/takeNoticeOffer
|
||||
// and ChatCommandUi.kt's labels
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("chatNoticeLabel names a command and its failure", () => {
|
||||
assert.equal(CHAT_COMMAND_LABEL, "Command");
|
||||
assert.equal(CHAT_COMMAND_FAILED_LABEL, "Command failed");
|
||||
assert.equal(chatNoticeLabel(false), "Command");
|
||||
assert.equal(chatNoticeLabel(true), "Command failed");
|
||||
// Anything that is not the literal failed flag keeps the ordinary label.
|
||||
assert.equal(chatNoticeLabel(undefined), "Command");
|
||||
assert.equal(chatNoticeLabel("failed"), "Command");
|
||||
});
|
||||
|
||||
test("the offerless notice's dismiss control has an accessible name", () => {
|
||||
assert.equal(CHAT_COMMAND_DISMISS_LABEL, "Dismiss command notice");
|
||||
});
|
||||
|
||||
test("makeChatNotice keeps the id, text, failure flag and offer", () => {
|
||||
assert.deepEqual(makeChatNotice("notice-1", "No turn is running in this chat."), {
|
||||
id: "notice-1",
|
||||
text: "No turn is running in this chat.",
|
||||
failed: false,
|
||||
offer: null,
|
||||
});
|
||||
assert.deepEqual(
|
||||
makeChatNotice("notice-2", "Started a new session.", { failed: true, offer: "/nope" }),
|
||||
{ id: "notice-2", text: "Started a new session.", failed: true, offer: "/nope" },
|
||||
);
|
||||
});
|
||||
|
||||
test("appendChatNotice appends one notice and preserves order", () => {
|
||||
const first = makeChatNotice("notice-1", "Command one");
|
||||
const second = makeChatNotice("notice-2", "Command two", { failed: true });
|
||||
const afterFirst = appendChatNotice([], first);
|
||||
const afterSecond = appendChatNotice(afterFirst, second);
|
||||
assert.deepEqual(afterSecond, [first, second]);
|
||||
// The previous list is never mutated.
|
||||
assert.deepEqual(afterFirst, [first]);
|
||||
assert.deepEqual(appendChatNotice(undefined, first), [first]);
|
||||
});
|
||||
|
||||
test("dismissChatNotice removes exactly the named notice", () => {
|
||||
const first = makeChatNotice("notice-1", "Command one");
|
||||
const second = makeChatNotice("notice-2", "Command two", { failed: true });
|
||||
const third = makeChatNotice("notice-3", "Command three");
|
||||
assert.deepEqual(dismissChatNotice([first, second, third], "notice-2"), [first, third]);
|
||||
// An unknown id leaves the list as it was.
|
||||
assert.deepEqual(dismissChatNotice([first, third], "notice-9"), [first, third]);
|
||||
assert.deepEqual(dismissChatNotice(undefined, "notice-1"), []);
|
||||
});
|
||||
|
||||
test("takeChatNoticeOffer removes the notice and returns its draft", () => {
|
||||
const offerless = makeChatNotice("notice-1", "Command one");
|
||||
const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
|
||||
const taken = takeChatNoticeOffer([offerless, offered], "notice-2");
|
||||
assert.equal(taken.offer, "/nope");
|
||||
assert.deepEqual(taken.notices, [offerless]);
|
||||
});
|
||||
|
||||
test("takeChatNoticeOffer returns null and leaves the list for a stale or offerless notice", () => {
|
||||
const offerless = makeChatNotice("notice-1", "Command one");
|
||||
const offered = makeChatNotice("notice-2", "Not a command.", { failed: true, offer: "/nope" });
|
||||
for (const id of ["notice-1", "notice-9"]) {
|
||||
const taken = takeChatNoticeOffer([offerless, offered], id);
|
||||
assert.equal(taken.offer, null);
|
||||
assert.deepEqual(taken.notices, [offerless, offered]);
|
||||
}
|
||||
// A second take of an already-taken id is stale and sends nothing.
|
||||
const firstTake = takeChatNoticeOffer([offered], "notice-2");
|
||||
const secondTake = takeChatNoticeOffer(firstTake.notices, "notice-2");
|
||||
assert.equal(secondTake.offer, null);
|
||||
assert.deepEqual(secondTake.notices, []);
|
||||
});
|
||||
|
||||
test("notice lists are scoped per conversation and never share state", () => {
|
||||
// Two conversations' notice lists are independent arrays: appending or
|
||||
// dismissing in one cannot touch the other (the app keeps one per thread).
|
||||
const operator = [];
|
||||
const throwaway = [];
|
||||
const operatorNotice = makeChatNotice("notice-1", "Operator command");
|
||||
const throwawayNotice = makeChatNotice("notice-2", "Throwaway command", { failed: true });
|
||||
const operatorAfter = appendChatNotice(operator, operatorNotice);
|
||||
const throwawayAfter = appendChatNotice(throwaway, throwawayNotice);
|
||||
assert.deepEqual(operatorAfter, [operatorNotice]);
|
||||
assert.deepEqual(throwawayAfter, [throwawayNotice]);
|
||||
assert.deepEqual(dismissChatNotice(operatorAfter, "notice-1"), []);
|
||||
assert.deepEqual(throwawayAfter, [throwawayNotice]);
|
||||
const taken = takeChatNoticeOffer(
|
||||
appendChatNotice(throwawayAfter, makeChatNotice("notice-3", "Offer", { offer: "/help" })),
|
||||
"notice-3",
|
||||
);
|
||||
assert.equal(taken.offer, "/help");
|
||||
assert.deepEqual(operatorAfter, [operatorNotice]);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Slash commands (C9)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
+364
-50
@@ -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
|
||||
@@ -51,7 +53,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")),
|
||||
@@ -102,6 +109,19 @@ const showComposer = () =>
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)));
|
||||
})`);
|
||||
|
||||
// Show the foot of an open conversation without scrolling the whole document.
|
||||
// The session list can be taller than the chat pane (the smoke leaves closed
|
||||
// throwaway rows behind), so scrolling to the document bottom would push the
|
||||
// conversation above the viewport and capture an empty pane. The transcript is
|
||||
// the only scroller that needs to move for a command-notice capture.
|
||||
const showChatNotice = () =>
|
||||
page.evaluate(`new Promise((resolve) => {
|
||||
window.scrollTo(0, 0);
|
||||
const transcript = document.querySelector("#chatTranscript");
|
||||
if (transcript) transcript.scrollTop = transcript.scrollHeight;
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)));
|
||||
})`);
|
||||
|
||||
// The shared live server can drop a long-lived socket while the earlier screens
|
||||
// are captured (observed as a spurious 1006 mid-run). A capture step must not
|
||||
// depend on an unasserted connection, so this nudges the page's own recovery —
|
||||
@@ -432,6 +452,14 @@ try {
|
||||
}
|
||||
if (frame) {
|
||||
(window.__pipelinesSentTypes = window.__pipelinesSentTypes || []).push(frame.type);
|
||||
// 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.
|
||||
if (frame.type === "chat_prompt") {
|
||||
(window.__chatPromptTexts = window.__chatPromptTexts || []).push(
|
||||
frame.chat_prompt?.text ?? "",
|
||||
);
|
||||
}
|
||||
if (frame.type === "chat_reply") {
|
||||
const requestId = frame.chat_reply && frame.chat_reply.request_id;
|
||||
if (window.__suppressChatReplyIds.includes(requestId)) {
|
||||
@@ -1461,6 +1489,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(`(() => {
|
||||
@@ -1473,11 +1504,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.
|
||||
@@ -3022,36 +3057,7 @@ try {
|
||||
await ensureConnected();
|
||||
await page.waitForSelector("#chatInput", { timeout: 15000 });
|
||||
|
||||
// (a) `/new` creates a fresh throwaway session (C2's chat_create, sent directly
|
||||
// until C2 lands) and opens it. Every composer state below is exercised on this
|
||||
// idle session rather than the operator's own, whose live turn may be running
|
||||
// (the list's activity word is honest about it but must not fail this stage).
|
||||
await page.fill("#chatInput", "/new");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
const throwawayId = await eventually(
|
||||
async () => {
|
||||
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.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}`);
|
||||
throwawaySessionId = throwawayId;
|
||||
const startedNotice = await page.evaluate(
|
||||
`document.querySelector(".chat-command-notice .chat-command-notice-text")?.textContent ?? ""`,
|
||||
);
|
||||
if (!startedNotice.startsWith("Started a new session “")) {
|
||||
throw new Error(`/new notice: ${startedNotice}`);
|
||||
}
|
||||
console.log(` /new opened throwaway session ${throwawayId} ("${throwawayTitle}") — ${startedNotice}`);
|
||||
await showComposer();
|
||||
await shot("62-chat-new-session.png");
|
||||
|
||||
// (b) A draft: the placeholder, Send present and enabled, Stop absent.
|
||||
// (a) A draft: the placeholder, Send present and enabled, Stop absent.
|
||||
await page.fill("#chatInput", "A draft from the smoke");
|
||||
const draftState = await page.evaluate(`(() => ({
|
||||
placeholder: document.querySelector("#chatInput")?.getAttribute("placeholder") ?? "",
|
||||
@@ -3128,27 +3134,116 @@ try {
|
||||
throw new Error(`prefix filter: ${JSON.stringify(narrowedCommands)}`);
|
||||
}
|
||||
|
||||
// (c) An unknown command: its notice with the exact wording and the offer, then
|
||||
// Cancel. The composer is driven without submitting, so no prompt is sent.
|
||||
await page.fill("#chatInput", "/nope");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
// (c) C12: local command notices on this (read-only) conversation. A `/help`
|
||||
// success line and an unknown command's failed line render full width after the
|
||||
// turns, never as message bubbles; both are local, so the recorded send
|
||||
// assertions below must show no chat_prompt for either. The failed one keeps
|
||||
// Android's `Send as message` / `Cancel` pair; an offerless line is dismissible
|
||||
// by its own `Dismiss` control (the browser completion recorded in PARITY).
|
||||
await page.evaluate(`(() => {
|
||||
window.__pipelinesSentTypes = [];
|
||||
window.__chatPromptTexts = [];
|
||||
return true;
|
||||
})()`);
|
||||
const runSlashDraft = async (text) => {
|
||||
await page.fill("#chatInput", text);
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
};
|
||||
|
||||
await runSlashDraft("/help");
|
||||
const helpNotice = await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const node = [...document.querySelectorAll("#chatTranscript .chat-command-notice:not(.chat-command-notice-failed)")]
|
||||
.find((n) => (n.querySelector(".chat-command-notice-text")?.textContent ?? "").includes("/help — List every command"));
|
||||
if (!node) return null;
|
||||
node.scrollIntoView({ block: "center" });
|
||||
const transcript = document.querySelector("#chatTranscript");
|
||||
const children = [...transcript.children];
|
||||
const index = children.indexOf(node);
|
||||
const lastTurn = children.reduce(
|
||||
(last, child, i) => (child.matches(".chat-turn-user, .chat-turn-agent") ? i : last),
|
||||
-1,
|
||||
);
|
||||
return {
|
||||
id: node.dataset.noticeId ?? "",
|
||||
label: node.querySelector(".chat-command-notice-label")?.textContent ?? "",
|
||||
glyph: node.querySelector(".chat-command-notice-glyph")?.textContent ?? "",
|
||||
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
|
||||
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
|
||||
dismissLabel: node.querySelector(".chat-command-dismiss")?.getAttribute("aria-label") ?? "",
|
||||
bubble:
|
||||
node.classList.contains("chat-turn-user") ||
|
||||
node.classList.contains("chat-turn-agent") ||
|
||||
!!node.closest(".chat-bubble"),
|
||||
width: Math.round(node.getBoundingClientRect().width),
|
||||
contentWidth: Math.round(transcript.clientWidth - 24),
|
||||
afterTurns: index > lastTurn,
|
||||
turns: children.filter((child) => child.matches(".chat-turn-user, .chat-turn-agent")).length,
|
||||
};
|
||||
})()`),
|
||||
{ timeout: 10000, what: "the /help command notice" },
|
||||
);
|
||||
if (helpNotice.label !== "Command") throw new Error(`/help notice label: ${helpNotice.label}`);
|
||||
if (helpNotice.glyph !== ">_") throw new Error(`/help notice glyph: ${helpNotice.glyph}`);
|
||||
if (!helpNotice.text.startsWith("/new — Start a fresh session in this directory")) {
|
||||
throw new Error(`/help notice text: ${helpNotice.text}`);
|
||||
}
|
||||
if (!helpNotice.text.includes("/help — List every command")) {
|
||||
throw new Error(`/help notice is missing its last command line: ${helpNotice.text}`);
|
||||
}
|
||||
if (helpNotice.buttons.join("|") !== "Dismiss") {
|
||||
throw new Error(`offerless notice controls: ${JSON.stringify(helpNotice.buttons)}`);
|
||||
}
|
||||
if (helpNotice.dismissLabel !== "Dismiss command notice") {
|
||||
throw new Error(`dismiss accessible name: ${helpNotice.dismissLabel}`);
|
||||
}
|
||||
if (helpNotice.bubble || !helpNotice.afterTurns || helpNotice.turns < 1) {
|
||||
throw new Error(
|
||||
`the /help line is not a full-width transcript line after the turns: ${JSON.stringify(helpNotice)}`,
|
||||
);
|
||||
}
|
||||
if (helpNotice.width < helpNotice.contentWidth - 3) {
|
||||
throw new Error(
|
||||
`the /help line is not full width: ${helpNotice.width}px of ${helpNotice.contentWidth}px`,
|
||||
);
|
||||
}
|
||||
const promptless = await page.evaluate(
|
||||
`({ types: window.__pipelinesSentTypes || [], texts: window.__chatPromptTexts || [] })`,
|
||||
);
|
||||
if (promptless.types.includes("chat_prompt") || promptless.texts.length !== 0) {
|
||||
throw new Error(`/help reached the prompt path: ${JSON.stringify(promptless)}`);
|
||||
}
|
||||
console.log(
|
||||
` /help: "${helpNotice.label}" line (${helpNotice.width}px of ${helpNotice.contentWidth}px, ` +
|
||||
`${helpNotice.turns} turn(s) above it), no bubble; only a Dismiss control; no chat_prompt sent`,
|
||||
);
|
||||
await showChatNotice();
|
||||
await shot("72-chat-command-notice.png");
|
||||
|
||||
// The unknown command's failed line: the app's wording, the shared terminal
|
||||
// glyph and the error tint, with the offer's exact control pair.
|
||||
await runSlashDraft("/nope");
|
||||
await page.waitForSelector(".chat-command-notice-failed", { timeout: 10000 });
|
||||
const notice = await page.evaluate(`(() => {
|
||||
const node = document.querySelector(".chat-command-notice-failed");
|
||||
node.scrollIntoView({ block: "center" });
|
||||
return {
|
||||
id: node.dataset.noticeId ?? "",
|
||||
label: node.querySelector(".chat-command-notice-label")?.textContent ?? "",
|
||||
glyph: node.querySelector(".chat-command-notice-glyph")?.textContent ?? "",
|
||||
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
|
||||
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
|
||||
failed: node.classList.contains("chat-command-notice-failed"),
|
||||
draft: document.querySelector("#chatInput")?.value ?? null,
|
||||
send: !!document.querySelector("#chatSend"),
|
||||
stop: !!document.querySelector("#chatStop"),
|
||||
};
|
||||
})()`);
|
||||
if (notice.label !== "Command failed") throw new Error(`notice label: ${notice.label}`);
|
||||
if (notice.glyph !== ">_") throw new Error(`failed notice glyph: ${notice.glyph}`);
|
||||
if (
|
||||
notice.text !==
|
||||
"“/nope” is not a command, so nothing was sent to the agent. Send it as a message, or cancel."
|
||||
@@ -3158,14 +3253,79 @@ try {
|
||||
if (notice.buttons.join("|") !== "Send as message|Cancel") {
|
||||
throw new Error(`unknown-command offer buttons: ${JSON.stringify(notice.buttons)}`);
|
||||
}
|
||||
if (!notice.failed) throw new Error("the failed notice does not carry the error styling class");
|
||||
if (notice.draft !== "") throw new Error(`the command did not consume the draft: ${JSON.stringify(notice.draft)}`);
|
||||
const tint = await page.evaluate(`(() => {
|
||||
const failedNode = document.querySelector('.chat-command-notice-failed[data-notice-id="${notice.id}"]');
|
||||
const okNode = document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]');
|
||||
return {
|
||||
failedBorder: failedNode ? getComputedStyle(failedNode).borderColor : "",
|
||||
okBorder: okNode ? getComputedStyle(okNode).borderColor : "",
|
||||
};
|
||||
})()`);
|
||||
if (!tint.failedBorder || tint.failedBorder === tint.okBorder) {
|
||||
throw new Error(`the failed notice is not tinted differently from a command line: ${JSON.stringify(tint)}`);
|
||||
}
|
||||
const stillPromptless = await page.evaluate(`window.__chatPromptTexts || []`);
|
||||
if (stillPromptless.length !== 0) {
|
||||
throw new Error(`an unknown command reached the prompt path: ${JSON.stringify(stillPromptless)}`);
|
||||
}
|
||||
console.log(` unknown command: "${notice.text}" (offer: ${notice.buttons.join(" / ")})`);
|
||||
console.log(
|
||||
` both command lines stayed local: no chat_prompt was sent (recorded types: ${JSON.stringify(
|
||||
(await page.evaluate(`window.__pipelinesSentTypes || []`)).filter((type) => type.startsWith("chat_")),
|
||||
)})`,
|
||||
);
|
||||
await showChatNotice();
|
||||
await shot("59-chat-command-unknown.png");
|
||||
await page.clickText(".chat-command-notice-failed button", "Cancel");
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".chat-command-notice-failed")`), {
|
||||
timeout: 5000,
|
||||
what: "the unknown-command notice to be dismissed",
|
||||
});
|
||||
await showChatNotice();
|
||||
await shot("73-chat-command-failed-offer.png");
|
||||
|
||||
// Dismissal removes exactly the named notice: the offerless `/help` line goes,
|
||||
// the failed offer notice stays with its draft and controls.
|
||||
const dismissed = await page.evaluate(`(() => {
|
||||
const help = document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]');
|
||||
const idsBefore = [...document.querySelectorAll("#chatTranscript .chat-command-notice")].map(
|
||||
(node) => node.dataset.noticeId,
|
||||
);
|
||||
help?.querySelector(".chat-command-dismiss")?.click();
|
||||
return { idsBefore, clicked: !!help };
|
||||
})()`);
|
||||
if (!dismissed.clicked || !dismissed.idsBefore.includes(helpNotice.id)) {
|
||||
throw new Error(`the /help notice was not dismissed: ${JSON.stringify(dismissed)}`);
|
||||
}
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!document.querySelector('.chat-command-notice[data-notice-id="${helpNotice.id}"]')`,
|
||||
),
|
||||
{ timeout: 5000, what: "the dismissed /help notice to be gone" },
|
||||
);
|
||||
const noticeRemoval = await page.evaluate(`(() => ({
|
||||
ids: [...document.querySelectorAll("#chatTranscript .chat-command-notice")].map((node) => node.dataset.noticeId),
|
||||
failed: document.querySelector('.chat-command-notice-failed[data-notice-id="${notice.id}"] .chat-command-notice-text')?.textContent ?? "",
|
||||
buttons: [...document.querySelectorAll('.chat-command-notice-failed[data-notice-id="${notice.id}"] .chat-command-notice-actions button')].map((b) => b.textContent),
|
||||
}))()`);
|
||||
if (
|
||||
noticeRemoval.ids.includes(helpNotice.id) ||
|
||||
!noticeRemoval.ids.includes(notice.id) ||
|
||||
noticeRemoval.ids.length !== dismissed.idsBefore.length - 1 ||
|
||||
noticeRemoval.failed !== notice.text ||
|
||||
noticeRemoval.buttons.join("|") !== "Send as message|Cancel"
|
||||
) {
|
||||
throw new Error(`dismissing one notice changed the wrong ones: ${JSON.stringify({ dismissed, noticeRemoval })}`);
|
||||
}
|
||||
console.log(
|
||||
` dismissed only ${helpNotice.id} (${dismissed.idsBefore.length} -> ${noticeRemoval.ids.length} notices; ` +
|
||||
`${notice.id} and its offer remain)`,
|
||||
);
|
||||
await showChatNotice();
|
||||
await shot("74-chat-command-dismissed.png");
|
||||
await page.clickText(`.chat-command-notice-failed[data-notice-id="${notice.id}"] button`, "Cancel");
|
||||
await eventually(
|
||||
() => page.evaluate(`!document.querySelector('.chat-command-notice[data-notice-id="${notice.id}"]')`),
|
||||
{ timeout: 5000, what: "the unknown-command notice to be dismissed" },
|
||||
);
|
||||
|
||||
// (d) Attachment chips: a small file with its size, and a file over the 25 MiB
|
||||
// limit with its error. Driving the real file input (a DataTransfer) exercises
|
||||
@@ -3248,9 +3408,163 @@ try {
|
||||
});
|
||||
await page.fill("#chatInput", "");
|
||||
|
||||
// (f) The throwaway created at the start is still open and idle (the palette,
|
||||
// notice and attachment probes above never submitted anything). Prompt it for
|
||||
// the real running-turn state; the operator's session is left untouched.
|
||||
// (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 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 }))`,
|
||||
);
|
||||
const throwawayId = await eventually(
|
||||
async () => {
|
||||
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.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}`);
|
||||
throwawaySessionId = throwawayId;
|
||||
const startedNotice = await page.evaluate(
|
||||
`document.querySelector(".chat-command-notice .chat-command-notice-text")?.textContent ?? ""`,
|
||||
);
|
||||
if (!startedNotice.startsWith("Started a new session “")) {
|
||||
throw new Error(`/new notice: ${startedNotice}`);
|
||||
}
|
||||
console.log(` /new opened throwaway session ${throwawayId} ("${throwawayTitle}") — ${startedNotice}`);
|
||||
await showComposer();
|
||||
await shot("62-chat-new-session.png");
|
||||
|
||||
// C12: notices belong to one conversation and survive switching away and back.
|
||||
// The offer notice is added on this throwaway session (never the operator's),
|
||||
// then the pane switches to the operator session and back. Finally the offer is
|
||||
// taken: the notice is gone before the prompt is sent, a stale second tap sends
|
||||
// nothing, and the draft goes through the ordinary chat_prompt path. The shim
|
||||
// answers that one prompt locally so this step does not add a live turn; the
|
||||
// real prompt below still exercises the live turn and Stop.
|
||||
await page.evaluate(`(() => {
|
||||
window.__pipelinesSentTypes = [];
|
||||
window.__chatPromptTexts = [];
|
||||
return true;
|
||||
})()`);
|
||||
await page.fill("#chatInput", "/nope");
|
||||
await page.evaluate(
|
||||
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
||||
);
|
||||
const offerNotice = await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice-failed');
|
||||
if (!node) return null;
|
||||
return {
|
||||
id: node.dataset.noticeId ?? "",
|
||||
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
|
||||
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
|
||||
};
|
||||
})()`),
|
||||
{ timeout: 10000, what: "the throwaway command notice" },
|
||||
);
|
||||
if (offerNotice.buttons.join("|") !== "Send as message|Cancel") {
|
||||
throw new Error(`throwaway notice controls: ${JSON.stringify(offerNotice.buttons)}`);
|
||||
}
|
||||
const throwawayPromptless = await page.evaluate(`window.__chatPromptTexts || []`);
|
||||
if (throwawayPromptless.length !== 0) {
|
||||
throw new Error(`the unknown command on the throwaway reached the prompt path: ${JSON.stringify(throwawayPromptless)}`);
|
||||
}
|
||||
|
||||
await page.evaluate(`document.querySelector('#chatRows .chat-row[data-session="${openedId}"]')?.click()`);
|
||||
await page.waitForSelector(`#chatTranscript[data-session="${openedId}"]`, { timeout: 25000 });
|
||||
const leaked = await page.evaluate(
|
||||
`!!document.querySelector('.chat-command-notice[data-notice-id="${offerNotice.id}"]')`,
|
||||
);
|
||||
if (leaked) throw new Error("the throwaway's notice leaked into the operator's conversation");
|
||||
await page.evaluate(`document.querySelector('#chatRows .chat-row[data-session="${throwawayId}"]')?.click()`);
|
||||
await page.waitForSelector(`#chatTranscript[data-session="${throwawayId}"]`, { timeout: 25000 });
|
||||
const survived = await eventually(
|
||||
() =>
|
||||
page.evaluate(`(() => {
|
||||
const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]');
|
||||
if (!node) return null;
|
||||
return {
|
||||
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
|
||||
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
|
||||
};
|
||||
})()`),
|
||||
{ timeout: 15000, what: "the throwaway notice after switching away and back" },
|
||||
);
|
||||
if (survived.text !== offerNotice.text || survived.buttons.join("|") !== "Send as message|Cancel") {
|
||||
throw new Error(`the notice did not survive the switch: ${JSON.stringify({ offerNotice, survived })}`);
|
||||
}
|
||||
console.log(
|
||||
` the notice survived a switch away and back on ${throwawayId} (absent from the operator's conversation)`,
|
||||
);
|
||||
|
||||
const offerClicked = await page.evaluate(`(() => {
|
||||
const node = document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]');
|
||||
const button = node?.querySelector(".chat-command-send-as-message") ?? null;
|
||||
window.__staleOfferButton = button;
|
||||
window.__promptCountBeforeOffer = (window.__pipelinesSentTypes || []).length;
|
||||
window.__pipelinesIntercept = (frame) =>
|
||||
frame.type === "chat_prompt" ? { id: frame.id, type: "chat_prompt", chat_queued: false } : null;
|
||||
button?.click();
|
||||
return !!button;
|
||||
})()`);
|
||||
if (!offerClicked) throw new Error("the throwaway notice has no Send as message control");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!document.querySelector('#chatTranscript[data-session="${throwawayId}"] .chat-command-notice[data-notice-id="${offerNotice.id}"]')`,
|
||||
),
|
||||
{ timeout: 10000, what: "the taken offer notice to be removed" },
|
||||
);
|
||||
const offeredSend = await page.evaluate(`(() => {
|
||||
const types = (window.__pipelinesSentTypes || []).slice(window.__promptCountBeforeOffer);
|
||||
return { chatPrompts: types.filter((type) => type === "chat_prompt").length, texts: window.__chatPromptTexts || [] };
|
||||
})()`);
|
||||
if (offeredSend.chatPrompts !== 1 || offeredSend.texts.length !== 1 || offeredSend.texts[0] !== "/nope") {
|
||||
throw new Error(`the offer did not take the ordinary prompt path: ${JSON.stringify(offeredSend)}`);
|
||||
}
|
||||
const staleTap = await page.evaluate(`(() => {
|
||||
const before = (window.__pipelinesSentTypes || []).length;
|
||||
window.__staleOfferButton?.click();
|
||||
return {
|
||||
before,
|
||||
after: (window.__pipelinesSentTypes || []).length,
|
||||
texts: (window.__chatPromptTexts || []).length,
|
||||
};
|
||||
})()`);
|
||||
if (staleTap.after !== staleTap.before || staleTap.texts !== 1) {
|
||||
throw new Error(`a stale Send as message tap sent something: ${JSON.stringify(staleTap)}`);
|
||||
}
|
||||
console.log(
|
||||
" Send as message removed the notice first, then sent /nope once through chat_prompt; " +
|
||||
"a stale second tap sent nothing",
|
||||
);
|
||||
// Settle the (locally answered) prompt so the real turn below starts from Send,
|
||||
// and drop the one-shot prompt interceptor.
|
||||
const settledOffer = await page.evaluate(`(() => {
|
||||
const ws = window.__pipelinesSocket;
|
||||
if (!ws || typeof ws.onmessage !== "function") return false;
|
||||
ws.onmessage({
|
||||
data: JSON.stringify({
|
||||
type: "chat_event",
|
||||
chat_event: { session_id: "${throwawayId}", kind: "step", step: { status: "ended" } },
|
||||
}),
|
||||
});
|
||||
return true;
|
||||
})()`);
|
||||
if (!settledOffer) throw new Error("the socket shim did not expose the live socket to settle the offered prompt");
|
||||
await eventually(() => page.evaluate(`!document.querySelector("#chatStop")`), {
|
||||
timeout: 10000,
|
||||
what: "the offered prompt's running state to settle",
|
||||
});
|
||||
await page.evaluate(`(() => { window.__pipelinesIntercept = null; return true; })()`);
|
||||
|
||||
// A real prompt to the throwaway session turns the Send control into Stop.
|
||||
await page.fill("#chatInput", "Reply with exactly one word: hi");
|
||||
await page.evaluate(
|
||||
|
||||
Reference in New Issue
Block a user