Skip to content

Split browser worker into focused runtime modules - #227

Merged
SSHdotCodes merged 4 commits into
mainfrom
refactor/split-browser-worker
Sep 22, 2026
Merged

SSHdotCodes merged 4 commits into
mainfrom
refactor/split-browser-worker

Conversation

@CuriosityOS

@CuriosityOS CuriosityOS commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Split the browser worker into focused internal modules for realms, sandbox composition, artifacts and recording, snapshots, live view, trusted input, site tools, sessions, and CAPTCHA handling. The entrypoint retains browser lifecycle, RPC wiring, session queues, network guards, execution ordering, downloads, and secret tracking. Factories own subsystem state and use live getters for changing browser/configuration references; ordering contracts are documented in docs/worker-architecture.md.

The browser regressions also fix two existing CAPTCHA bugs: trusted checkbox/Verify clicks scroll their targets into view, and unsuccessful image-grid picks cannot report a still-visible challenge as cleared without a response token.

Test reliability fixes:

  • Credential fixtures wait for child documents before assertions, with a deliberately delayed iframe covering ambiguous forms. Restoring the old navigation helper reproduces the failure.
  • Profile CLI checks share the asynchronous subprocess helper, close stdin, and force termination at the deadline, avoiding synchronous waits that stalled a macOS CI worker.
  • Model-selection and startup checks use temporary homes with daemon startup disabled, preventing interference with saved user settings and persistent sessions.

Checklist

  • bun run release:check passes locally on 286869b, including versions, full-repo lint, typechecks, build, unit tests, declarations, and package smoke.
  • Local browser and Electron guard-proxy behavior is unchanged. Remote-provider exceptions and their documented limits remain unchanged.
  • Credential filling and literal secret redaction remain unchanged; extracted output paths retain redaction.
  • Dependency pins and their mirrors are unchanged. No dependencies added.
  • No public API changes; bun run test:types passes against the existing declarations.
  • Branch-protected CI job names and pinned actions are unchanged.
  • No unit test imports the worker entrypoint. Import-safety tests cover the extracted modules.
  • CHANGELOG.md records the refactor and CAPTCHA fixes; architecture and verification guidance are in docs/worker-architecture.md.
  • No profiles, vaults, artifacts, local reports, or unrelated changes are included.

How it was verified

  • Bun 1.4.0, using the frozen lockfile and the pinned managed BetterChromium.
  • BETTERWRIGHT_REQUIRE_BROWSER=1 BETTERWRIGHT_REQUIRE_RECORDING=1 bun run release:check: 1,345 tests passed, three optional live-provider skips; all static, declaration, build-layout, and package checks passed. Model configuration environment overrides were unset for the test process.
  • Managed-browser phase: 129 passed, zero failures or skips.
  • bun tests/e2e/run.ts --binary bun --binary-arg "$PWD/dist/bin/betterwright.js" --require-all: 102 passed, zero failures or skips, using only committed fixtures. The final follow-up changes test isolation only; the browser runtime is unchanged.
  • Focused CLI/profile checks: 82 passed; startup/model-selection checks: 15 passed. The shared helper's regressions verify stdin EOF, preserved nonzero exit output, and forced termination of a child that ignores SIGTERM.
  • All nine GitHub CI checks passed on the final head, including Linux, macOS, Windows, managed-browser tests, and strict binary E2E.

External CAPTCHA services, paid/remote providers, and Electron attachment were not exercised locally.

@greptile-apps

greptile-apps Bot commented Sep 21, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

Safe to merge based on the completed browser and module coverage.

What we checked:

  • Built and exercised the focused CAPTCHA browser flows on the PR version. T-Rex
  • Observed that a grid challenge in a 320px-high viewport minted its response token after the Verify control was moved below the fold. T-Rex
  • Noted that incorrect grid picks remained unresolved rather than being reported as complete. T-Rex
  • Ran extracted worker-module and import-safety coverage tests; all 28 tests passed. T-Rex
  • Compared baseline by reviewing after vs before logs; after shows all tests passing, while before shows failures in the same CAPTCHA scenarios. T-Rex

Summary

The worker refactor keeps browser CAPTCHA handling working across the tested flows and preserves import-safe extracted runtime modules. No issues were found that need changes before merging.

Reviews (1) · Last reviewed commit: "Split browser worker into focused runtim..."

CuriosityOS and others added 3 commits September 22, 2026 00:21
- Scroll Verify and checkbox controls into view before every trusted
  pointer click, not only image-grid submission.
- Treat any visible challenge widget without a token as unresolved,
  filtering on visibility so dormant provider frames do not mask it.
- Wire the recording-busy helpers into parking and idle reaping; drop
  unused exports from the artifacts, snapshots, and realm factories.
- Share isObjectValue from untrusted-value.ts; type the sandbox
  execution record directly instead of through an untyped parameter.
- Hoist the local widget selector literal.
@SSHdotCodes
SSHdotCodes merged commit cd39e17 into main Sep 22, 2026
9 checks passed
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.

2 participants