perf(browser): add lightweight scheduler page for headless mode#952
perf(browser): add lightweight scheduler page for headless mode#952
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fc07c4463
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR optimizes headless browser runs by introducing a lightweight /scheduler.html page (instead of loading the full React container UI), while consolidating shared runtime/channel/RPC typing between the container and scheduler paths.
Changes:
- Add a new
schedulerbuild entry in@rstest/browser-uiand ascheduler.tsruntime that drives hidden runner iframes in headless mode. - Refactor shared browser-ui logic into
core/runtime(URL helpers + reconnect delays) andcore/channel(dispatch + snapshot RPC forwarding). - Update
@rstest/browserhost routing to serve/inject/scheduler.htmland adjust e2e assertions for headless vs headed behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/browser/src/hostController.ts | Adds /scheduler.html handling, injects options into scheduler HTML, and uses scheduler page for headless-only projects. |
| packages/browser-ui/src/types.ts | Adds rpcTimeout and centralizes RPC/payload types used by container + scheduler. |
| packages/browser-ui/src/scheduler.ts | New lightweight scheduler runtime for headless mode with reconnect + hidden runner iframes. |
| packages/browser-ui/src/main.tsx | Switches to shared channel/runtime helpers and shared payload types. |
| packages/browser-ui/src/hooks/useRpc.ts | Uses shared createWebSocketUrl / RECONNECT_DELAYS and shared RPC types. |
| packages/browser-ui/src/core/runtime.ts | New shared helpers for runner/ws URLs and reconnect backoff constants. |
| packages/browser-ui/src/core/channel.ts | New shared dispatch parsing + snapshot RPC forwarding utilities. |
| packages/browser-ui/rsbuild.config.ts | Adds scheduler entry so rsbuild emits scheduler.html + bundle. |
| e2e/browser-mode/basic.test.ts | Updates coverage to assert headless uses /scheduler.html while headed does not. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2fc07c4 to
5c1533a
Compare
Summary
perf diff (running under examples/browser-react):
before
after
This PR introduces a lightweight scheduler page for headless browser runs and avoids loading the full React container UI in that mode. It also consolidates duplicated scheduler/container plumbing by moving shared runtime and channel logic into
@rstest/browser-uicore helpers with unified RPC types. On the host side,@rstest/browsernow serves injectedscheduler.htmlfrom browser-ui dist (with fallback), and e2e coverage is updated for both headless and headed paths.Behavior diff:
Changes:
schedulerbuild entry in rsbuild; emittedscheduler.html+ JS bundleHostRPC/ContainerRPCand payload types inbrowser-ui/src/types.ts/scheduler.htmlserve/injection path inhostController; e2e assertions for headless vs headed behaviorRelated Links
Checklist