🧪 test: Close Two Input Timing Gaps Behind Intermittent Tool Timer and Pinned Drag Failures (#18074)

* ⏱️ 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.
This commit is contained in:
Danny Avila 2026-11-12 07:20:21 -05:00 • committed by GitHub
parent fd0ea884e0
commit 559eadfdcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -105,6 +105,10 @@ export async function removePins(pins: SeededPin[]): Promise<void> {
await deleteConversations(pins.map((pin) => pin.conversationId));
}
/** Resolves once the page has run the animation frame after this call. */
const nextAnimationFrame = (page: Page): Promise<void> =>
page.evaluate(() => new Promise<void>((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();
}

View file

@ -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}`);