From 559eadfdcbacb9e3a1bbe0cba6f3aa6e5d62aa66 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Thu, 12 Nov 2026 07:20:21 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20Close=20Two=20Input=20Ti?= =?UTF-8?q?ming=20Gaps=20Behind=20Intermittent=20Tool=20Timer=20and=20Pinn?= =?UTF-8?q?ed=20Drag=20Failures=20(#18074)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ⏱️ test: Let the Composer Palette Finish Closing Before the Tool Timer Freezes the Clock `tool-timer.spec.ts` closes the composer palette with Escape and then calls `page.clock.setFixedTime`, which installs Playwright's clock. From that point every timer the page starts is run by the clock, one callback per task, and the agent stream that follows queues a zero-delay timeout for each query-cache notification, so the clock runs seconds behind. The palette is still closing when the clock is installed. Its popover unmounts from a 123 ms leave timer that is started two animation frames after Escape. When the install lands inside those two frames the timer belongs to the clock and waits behind the notification backlog: the popover stays mounted at zero opacity over the transcript and takes the click meant for the tool disclosure for the five seconds the tool runs. The disclosure then leaves with the tool and the click waits out the test's 120 s timeout. Wait for the palette dialog to unmount before reading the start time and freezing the clock. * 🧲 test: Deliver a Hover Frame Before a Pinned Row Drag Is Released `dragRowOnto` sends its whole pointer path, release included, in about 25 ms. react-dnd's HTML5 backend delivers hover to drop targets once per animation frame, and a target's hover callback reads the pointer offset the previous hover recorded, so a release is judged against where the pointer was when a frame last ran. When no frame runs between the pointer crossing the hovered row's midpoint and the release, the last recorded offset is the one from entering the row, in its lower half: the swap is refused and the list keeps its order. Only the reorder in `a pinned chat cannot be dragged through a pinned model` depends on that reading. The other drags in the file end in a drop handler that reads no offset. Wait for an animation frame after each of the three settling moves, so the hover carrying the final position has been delivered before the release. --- e2e/specs/mock/scenarios/pinned.helpers.ts | 13 ++++++++++++- e2e/specs/mock/scenarios/tool-timer.spec.ts | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/e2e/specs/mock/scenarios/pinned.helpers.ts b/e2e/specs/mock/scenarios/pinned.helpers.ts index d87a18584b..1c351732a1 100644 --- a/e2e/specs/mock/scenarios/pinned.helpers.ts +++ b/e2e/specs/mock/scenarios/pinned.helpers.ts @@ -105,6 +105,10 @@ export async function removePins(pins: SeededPin[]): Promise { await deleteConversations(pins.map((pin) => pin.conversationId)); } +/** Resolves once the page has run the animation frame after this call. */ +const nextAnimationFrame = (page: Page): Promise => + page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => resolve()))); + /** * Drags one row onto a point inside another and releases there. * @@ -151,9 +155,16 @@ export async function dragRowOnto( * decides a swap reads the offset at the moment it fires. A pointer that * arrived in one last jump gets a single reading, taken while React may still * be rendering the previous one; a real hand keeps sending events. These - * repeats are that, bounded. */ + * repeats are that, bounded. + * + * react-dnd delivers hover once per animation frame, and judges the release + * against the offset the last delivered hover recorded. Every move here can + * land inside a single frame, which leaves the release judged against where + * the pointer was a frame earlier: short of the row's midpoint, and so no + * swap. Each repeat therefore waits for the frame that delivers it. */ for (let settle = 0; settle < 3; settle += 1) { await page.mouse.move(endX, endY + settle - 1, { steps: 2 }); + await nextAnimationFrame(page); } await page.mouse.up(); } diff --git a/e2e/specs/mock/scenarios/tool-timer.spec.ts b/e2e/specs/mock/scenarios/tool-timer.spec.ts index 2a931815fc..0316e1af0d 100644 --- a/e2e/specs/mock/scenarios/tool-timer.spec.ts +++ b/e2e/specs/mock/scenarios/tool-timer.spec.ts @@ -20,6 +20,12 @@ test('a running tool includes hidden time before and after expansion @scenario:r .getByRole('button', { name: /^E2E Memory\b/ }) .click(); await page.keyboard.press('Escape'); + /** `setFixedTime` hands every timer the page starts from then on to Playwright's clock, which + * runs one per task and falls seconds behind once the stream's cache notifications queue up. + * The palette is still closing here; a leave timer started after the install waits behind + * them, and the invisible popover covers the transcript and takes the click meant for the + * tool row. It unmounts when the leave ends, so wait for that on the page's own clock. */ + await expect(page.getByRole('dialog', { name: 'Attach and tools' })).toHaveCount(0); const start = await page.evaluate(() => Date.now()); await page.clock.setFixedTime(start); await sendMessage(page, `E2E_INTERRUPT_TOOL_REPLY:${label}`);