diff --git a/.changes/prototype/fix-explore-directions-browser-flake-206077b3.md b/.changes/prototype/fix-explore-directions-browser-flake-206077b3.md new file mode 100644 index 0000000000..5cec01d191 --- /dev/null +++ b/.changes/prototype/fix-explore-directions-browser-flake-206077b3.md @@ -0,0 +1,7 @@ +--- +bump: patch +--- + +### Fixed + +- The notes panel no longer drops a click on a note row when the list re-renders while the mouse button is down, for instance when the server pushes a state change. The row is selected and its Edit, Withdraw and Move or resize actions show, where before they stayed hidden. Only a primary-button press holds the re-render, and the hold ends when the pointer leaves the list, a context menu opens or the window loses focus, so the list never freezes after a right-click or a drag into the mockup. diff --git a/lib/ui-feedback/host.mjs b/lib/ui-feedback/host.mjs index 01462bccff..94085670f5 100644 --- a/lib/ui-feedback/host.mjs +++ b/lib/ui-feedback/host.mjs @@ -600,7 +600,21 @@ function copyChosen(m) { else manual(); } +/** A row rebuilt between a press and its release gets no click, so a render during a press in the list waits for the click. */ +let pressed = false, stale = false; +const release = () => { + pressed = false; + if (stale) { stale = false; render(); } +}; +$("notes").addEventListener("pointerdown", (e) => { if (e.button === 0) pressed = true; }); +$("notes").addEventListener("pointerleave", release); +addEventListener("click", release); +addEventListener("pointerup", () => setTimeout(release)); +addEventListener("pointercancel", release); +addEventListener("contextmenu", release); +addEventListener("blur", release); function render() { + if (pressed) { stale = true; return; } const listening = noSession ? "No session: the notes server is not answering. Your notes stay on this page; Copy all notes makes a block to paste to Claude." : { listening: "Claude is listening.", reading: "Claude is reading your notes." }[last.listening] diff --git a/plugins/prototype/notes-bridge/host.mjs b/plugins/prototype/notes-bridge/host.mjs index a460dbf7cf..097812b970 100644 --- a/plugins/prototype/notes-bridge/host.mjs +++ b/plugins/prototype/notes-bridge/host.mjs @@ -602,7 +602,21 @@ function copyChosen(m) { else manual(); } +/** A row rebuilt between a press and its release gets no click, so a render during a press in the list waits for the click. */ +let pressed = false, stale = false; +const release = () => { + pressed = false; + if (stale) { stale = false; render(); } +}; +$("notes").addEventListener("pointerdown", (e) => { if (e.button === 0) pressed = true; }); +$("notes").addEventListener("pointerleave", release); +addEventListener("click", release); +addEventListener("pointerup", () => setTimeout(release)); +addEventListener("pointercancel", release); +addEventListener("contextmenu", release); +addEventListener("blur", release); function render() { + if (pressed) { stale = true; return; } const listening = noSession ? "No session: the notes server is not answering. Your notes stay on this page; Copy all notes makes a block to paste to Claude." : { listening: "Claude is listening.", reading: "Claude is reading your notes." }[last.listening] diff --git a/plugins/prototype/skills/explore-directions/scripts/notes-history-browser-take.js b/plugins/prototype/skills/explore-directions/scripts/notes-history-browser-take.js index 6a961db07f..c99c39659a 100644 --- a/plugins/prototype/skills/explore-directions/scripts/notes-history-browser-take.js +++ b/plugins/prototype/skills/explore-directions/scripts/notes-history-browser-take.js @@ -99,6 +99,17 @@ async page => { await until(() => rows.nth(0).getAttribute("aria-current"), (v) => v === "true"); ok("clicking marker 1 selects row 1, as clicking the row does", (await rows.nth(0).getAttribute("aria-current")) === "true"); ok("and keeps note 1's variant with its box drawn", (await shownVariant()) === "A" && (await box("selected", ROW)).on, await shownVariant()); + + await page.click("#view-sep"); + const name = await rows.nth(1).locator(".name").boundingBox(); + await page.mouse.move(name.x + 4, name.y + 4); + await page.mouse.down(); + await frame.evaluate(() => parent.postMessage({ type: "named", names: [] }, "*")); + await page.waitForTimeout(200); + await page.mouse.up(); + await until(() => rows.nth(1).getAttribute("aria-current"), (v) => v === "true"); + ok("a click on row 2 selects it and shows its actions when the list re-renders mid-press", + (await rows.nth(1).getAttribute("aria-current")) === "true" && await rows.nth(1).locator('[data-key^="edit-"]').isVisible()); } catch (err) { R.push("ERROR " + String(err && err.message || err).slice(0, 300)); }