Skip to content

feat(web-integration): expose keyboard type delay via WebPageOpt#2485

Open
quanru wants to merge 1 commit into
mainfrom
feat/web-keyboard-type-delay
Open

feat(web-integration): expose keyboard type delay via WebPageOpt#2485
quanru wants to merge 1 commit into
mainfrom
feat/web-keyboard-type-delay

Conversation

@quanru
Copy link
Copy Markdown
Collaborator

@quanru quanru commented May 18, 2026

Summary

  • Make the per-character delay used by keyboard.type configurable instead of being hard-coded to 80ms in packages/web-integration/src/puppeteer/base-page.ts.
  • Add a new keyboardTypeDelay?: number option on WebPageOpt, plumbed through PuppeteerAgent / PlaywrightAgent to the underlying Page constructor.
  • Introduce a shared DEFAULT_KEYBOARD_TYPE_DELAY = 80 constant in @midscene/shared/constants as the fallback default, preserving current behavior when the option is omitted.

Motivation

Some users need to slow down typing (flaky/legacy inputs that lose characters) or speed it up to near-zero (high-throughput automation / CI). Until now this required forking the package. With this change the delay can be tuned per agent instance:

new PuppeteerAgent(page, { keyboardTypeDelay: 0 });    // instant
new PlaywrightAgent(page, { keyboardTypeDelay: 150 }); // slower
// omit to keep the current 80ms default

Test plan

  • pnpm run lint
  • npx vitest --run tests/unit-test/web-actions-navigation.test.ts tests/unit-test/yaml/input-mode-typeonly.test.ts tests/unit-test/yaml/input-mode-typeonly-e2e.test.ts (all keyboard.type-related unit tests pass)
  • Manually verify with a Puppeteer agent that keyboardTypeDelay: 0 and keyboardTypeDelay: 200 are observed end-to-end

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 18, 2026

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2228b2d
Status: ✅  Deploy successful!
Preview URL: https://d373d8f8.midscene.pages.dev
Branch Preview URL: https://feat-web-keyboard-type-delay.midscene.pages.dev

View logs

Previously the per-character delay for `keyboard.type` was hard-coded
to 80ms. Add a `keyboardTypeDelay` option on `WebPageOpt` so callers
can tune typing speed (e.g. `0` for instant input, larger values for
slower environments). Falls back to the new `DEFAULT_KEYBOARD_TYPE_DELAY`
constant (80ms) when not specified.
@quanru quanru force-pushed the feat/web-keyboard-type-delay branch from a2ce68c to 2228b2d Compare May 19, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant