Skip to content

perf(browser): add lightweight scheduler page for headless mode#952

Merged
fi3ework merged 1 commit intomainfrom
max/2026-02-09--12-02AM
Feb 9, 2026
Merged

perf(browser): add lightweight scheduler page for headless mode#952
fi3ework merged 1 commit intomainfrom
max/2026-02-09--12-02AM

Conversation

@fi3ework
Copy link
Copy Markdown
Member

@fi3ework fi3ework commented Feb 9, 2026

Summary

perf diff (running under examples/browser-react):

before

hyperfine --warmup 3 --runs 50 "pnpm rstest"
Benchmark 1: pnpm rstest
  Time (mean ± σ):      1.326 s ±  0.044 s    [User: 1.444 s, System: 0.392 s]
  Range (min … max):    1.289 s …  1.580 s    50 runs

after

hyperfine --warmup 3 --runs 50 "pnpm rstest"
Benchmark 1: pnpm rstest
  Time (mean ± σ):     890.5 ms ±  73.7 ms    [User: 1193.6 ms, System: 364.7 ms]
  Range (min … max):   833.8 ms … 1251.4 ms    50 runs

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-ui core helpers with unified RPC types. On the host side, @rstest/browser now serves injected scheduler.html from browser-ui dist (with fallback), and e2e coverage is updated for both headless and headed paths.

Behavior diff:

+------------------------+--------------------------------------------+-----------------------------------------------+
| Scope                  | Before                                     | After                                         |
+------------------------+--------------------------------------------+-----------------------------------------------+
| Headless page route    | `/` container page                         | `/scheduler.html` lightweight scheduler page  |
| Scheduler resilience   | single WebSocket attempt                   | reconnect with exponential backoff            |
| Scheduler asset source | browser package client entry               | browser-ui multi-entry dist asset             |
+------------------------+--------------------------------------------+-----------------------------------------------+

Changes:

  • browser-ui scheduler entry and output wiring
    • scheduler build entry in rsbuild; emitted scheduler.html + JS bundle
  • shared browser-ui core runtime/channel helpers
    • runner/websocket URL helpers; reconnect delays; dispatch + snapshot RPC bridge
  • RPC/type dedup across container and scheduler
    • shared HostRPC/ContainerRPC and payload types in browser-ui/src/types.ts
  • browser host routing and verification updates
    • /scheduler.html serve/injection path in hostController; e2e assertions for headless vs headed behavior

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings February 9, 2026 06:18
@fi3ework fi3ework changed the title feat(browser): add lightweight scheduler page for headless mode perf(browser): add lightweight scheduler page for headless mode Feb 9, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 scheduler build entry in @rstest/browser-ui and a scheduler.ts runtime that drives hidden runner iframes in headless mode.
  • Refactor shared browser-ui logic into core/runtime (URL helpers + reconnect delays) and core/channel (dispatch + snapshot RPC forwarding).
  • Update @rstest/browser host routing to serve/inject /scheduler.html and 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.

@fi3ework fi3ework force-pushed the max/2026-02-09--12-02AM branch from 2fc07c4 to 5c1533a Compare February 9, 2026 07:14
@fi3ework fi3ework requested a review from 9aoy February 9, 2026 07:22
@fi3ework fi3ework merged commit 523ef62 into main Feb 9, 2026
10 checks passed
@fi3ework fi3ework deleted the max/2026-02-09--12-02AM branch February 9, 2026 07:34
@9aoy 9aoy mentioned this pull request Feb 10, 2026
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.

3 participants