diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs index f9b56d54..abcd12b4 100644 --- a/web/test/ui-smoke.mjs +++ b/web/test/ui-smoke.mjs @@ -4193,6 +4193,28 @@ try { step("C8/C9: the composer, slash commands and attachments"); await ensureConnected(); await page.waitForSelector("#chatInput", { timeout: 15000 }); + // The previous sections may have left a replayed turn marked running for the + // operator's session. This section tests the composer's default state, so settle + // any such turn once (a real pushed "ended" frame, through the page's own fold) + // rather than asserting against leftover state. + if (await page.evaluate(`!!document.querySelector("#chatStop")`)) { + const settled = await page.evaluate(`(() => { + const ws = window.__pipelinesSocket; + const sessionId = document.querySelector(".chat-row.selected")?.dataset.session ?? ""; + if (!ws || typeof ws.onmessage !== "function" || !sessionId) return false; + ws.onmessage({ data: JSON.stringify({ + type: "chat_event", + chat_event: { session_id: sessionId, kind: "step", step: { status: "ended" } }, + }) }); + return true; + })()`); + if (!settled) throw new Error("C8: could not settle the leftover running turn"); + await eventually(() => page.evaluate(`!document.querySelector("#chatStop")`), { + timeout: 10000, + what: "the leftover turn to settle before the composer checks", + }); + console.log(" settled a leftover running turn before the composer checks"); + } // (a) A draft: the placeholder, Send present and enabled, Stop absent. await page.fill("#chatInput", "A draft from the smoke");