diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c47c3c..dbfa834 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,9 @@ repos: - id: check-yaml exclude: '^mkdocs\.yml$' - id: check-json + # Every commit, not only during a merge: a resolution committed later still carries markers. + - id: check-merge-conflict + args: ["--assume-in-merge"] - id: check-added-large-files args: ["--maxkb=2000"] diff --git a/demo/check-reset.mjs b/demo/check-reset.mjs index 69de321..59cd756 100644 --- a/demo/check-reset.mjs +++ b/demo/check-reset.mjs @@ -59,12 +59,25 @@ const controls = () => // A DOM click, because some controls move the panel over the page's own buttons. const press = (label) => page.evaluate((name) => [...document.querySelectorAll(".try button")].find((b) => b.textContent === name).click(), label); -// Nothing navigates any more, so a load state says nothing: wait, then for the run. +// Settled once the chat is idle and its text has held still briefly, or held still for longer +// while a run waits on an approval; a fixed sleep per step made the check take minutes. const settle = async () => { - await page.waitForTimeout(2500); - await page - .waitForFunction(() => document.querySelector("ag-ui-chat")?.running === false, null, { timeout: 15000 }) - .catch(() => {}); + const started = Date.now(); + let last = null; + let since = Date.now(); + while (Date.now() - started < 15000) { + await page.waitForTimeout(150); + const now = await page.evaluate(() => { + const chat = document.querySelector("ag-ui-chat"); + return `${chat?.running}|${chat?.shadowRoot?.textContent?.length}|${location.pathname}`; + }); + if (now !== last) { + last = now; + since = Date.now(); + } + const quiet = Date.now() - since; + if ((now.startsWith("false|") && quiet >= 700) || quiet >= 2500) return; + } }; // A marker on window outlives every mount and dies with the document. const stayed = async (step) => {