Skip to content

feat(core): add custom initial page readiness hook - #3133

Open
xiong35 wants to merge 6 commits into
mainfrom
feat/custom-wait-for-ready
Open

xiong35 wants to merge 6 commits into
mainfrom
feat/custom-wait-for-ready

Conversation

@xiong35

@xiong35 xiong35 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Navigation completion and fixed delays do not guarantee that an application's initial data and rendering are ready. Developers previously had no shared Agent option to define this readiness condition.

Add waitForInitialPageReady: { handler, timeoutMs } to let developers control when the Agent can first read or operate on the page.

  • Run the handler once per Agent, before its first screenshot, query, assertion, or action, including cached workflows.
  • Share the initialization result across concurrent calls. Navigation, reloads, and page switches do not rerun the handler.
  • Fail initialization on rejection or timeout, retaining the failure for subsequent calls. The default timeout is 10 seconds.
  • Provide an AbortSignal for cleanup on timeout or Agent destruction.
  • Support the option across Agent platforms. The Puppeteer launcher awaits it after navigation in place of its initial network-idle wait.
  • Preserve existing post-action waiting behavior and defaults for Agents without the hook.
  • Add bilingual documentation explaining the hook and the roles of existing waiting APIs.

Validation

91 unit tests passed across the selected Core and Web suites. Core and Web builds passed.

pnpm run lint --vcs-enabled=true --vcs-client-kind=git --vcs-use-ignore-file=true
pnpm exec nx test @midscene/core -- tests/unit-test/initial-page-ready.test.ts tests/unit-test/agent-initial-page-ready.test.ts tests/unit-test/agent-custom-model.test.ts
pnpm exec nx build @midscene/web
pnpm exec nx test @midscene/web -- tests/unit-test/puppeteer/agent-launcher.test.ts tests/unit-test/playwright-ai-fixture-options.test.ts

@codex summary and review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026

Copy link
Copy Markdown

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: 92c8f63
Status: ✅  Deploy successful!
Preview URL: https://76a29da7.midscene.pages.dev
Branch Preview URL: https://feat-custom-wait-for-ready.midscene.pages.dev

View logs

@yuyutaotao
yuyutaotao marked this pull request as draft September 10, 2026 07:51
@xiong35
xiong35 marked this pull request as ready for review September 11, 2026 03:28
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.

1 participant