Skip to content

fix(keyboard): wait for queued macrotasks before returning - #2521

Open
sx4im wants to merge 2 commits into
vercel-labs:mainfrom
sx4im:fix-2510-key-sequence-macrotasks
Open

sx4im wants to merge 2 commits into
vercel-labs:mainfrom
sx4im:fix-2510-key-sequence-macrotasks

Conversation

@sx4im

@sx4im sx4im commented Nov 10, 2026

Copy link
Copy Markdown

A key sequence returned as soon as Chrome dispatched the key events, so a click issued right after could land before a setTimeout(0) the keys scheduled had fired (MUI ClickAwayListener arming on mount, in the reporter's case).

press, type, keyboard type, keyboard inserttext, and inserttext now wait for one animation frame and one macrotask before returning. Raw single-event dispatch (keydown, keyup) is unchanged, and the settle probe is best-effort so a page with no script context cannot fail a press whose keys already went out.

Verified: cargo check on the binary target passes and cargo fmt is clean. The new e2e test e2e_press_waits_for_queued_macrotasks covers the regression, but I could not build the test binary locally (repeated out-of-memory kills), so the test run is CI's verdict.

Fixes #2510

A key sequence returned as soon as Chrome dispatched the key events, so a click issued right after could land before a setTimeout(0) the keys scheduled had fired.

press, type, keyboard type, keyboard inserttext, and inserttext now wait for one animation frame and one macrotask before returning. Raw single-event dispatch (keydown, keyup) is unchanged.

Adds e2e_press_waits_for_queued_macrotasks.

Fixes vercel-labs#2510
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@sx4im is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread cli/src/native/interaction.rs Resolved
A key handler that opens a confirm or prompt dialog in an animation-frame
callback wedged the new settle probe: the dialog pauses the page timers,
so neither the frame callback nor the five-second fallback can fire and the
evaluation hung until the 30s CDP timeout.

wait_for_settle now bails out as soon as a JavaScript dialog opens on the
settling session, and the whole probe is capped at 6s so a dialog that is
already open when the settle starts cannot wedge it either. The dialog
stays open for the agent to handle with the dialog command.

Adds e2e_press_returns_promptly_when_key_opens_dialog.

Addresses vercel[bot] review 5837358512 on vercel-labs#2521.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A key sequence returns before the page has run the macrotasks the keys scheduled

1 participant