feat: Playwright fallback extractor for JS-heavy URL ingestion#1392
Merged
SorraTheOrc merged 4 commits intomainfrom Apr 5, 2026
Merged
Conversation
8 tasks
Implements: - src/lib/ingestion/extractor.ts: Extractor interface + ExtractResult type - src/lib/ingestion/extractor-fetch.ts: fast-path HTTP fetch extractor - src/lib/ingestion/extractor-playwright.ts: PlaywrightExtractor (opt-in, dynamic import, fresh context per run, configurable timeout, graceful degradation) - src/lib/ingestion/service.ts: IngestionService with primary + fallback orchestration, telemetry emission, OB_PLAYWRIGHT_FALLBACK env var support - src/cli/commands/add.ts: 'ob add <url>' CLI command - package.json: playwright as optional peer dependency - 47 unit tests (no real browser required in CI) - tests/fixtures/playwright-fallback/: HTML fixtures for documentation Agent-Logs-Url: https://github.com/TheWizardsCode/ContextHub/sessions/511715b4-dc90-4fe1-8664-cd673580f894 Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
- extractor-fetch.ts: fix bad-tag-filter (allow spaces before closing >) and double-escaping (use single-pass entity decoder) - extractor-playwright.ts: replace globalThis any cast with typed interface, add explanatory comment for the optional-peer-dep import cast - add-command.test.ts: rename s -> chunk for clarity Agent-Logs-Url: https://github.com/TheWizardsCode/ContextHub/sessions/511715b4-dc90-4fe1-8664-cd673580f894 Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
- extractor-fetch.ts: use [^>]* in script/style closing tag regex to handle any attributes (fixes CodeQL bad-tag-filter); document numeric entity limitation - add.ts: add parsePositiveInt helper with validation and user-friendly error messages for --min-content-length and --timeout options Agent-Logs-Url: https://github.com/TheWizardsCode/ContextHub/sessions/511715b4-dc90-4fe1-8664-cd673580f894 Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Playwright fallback retrieval for OpenBrain
feat: Playwright fallback extractor for JS-heavy URL ingestion
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JS-rendered pages return empty content from the fast-path HTTP extractor, causing
ob add <url>to ingest nothing useful. This adds an opt-in Playwright fallback that fires only when primary extraction falls below a configurable content-length threshold.New modules
src/lib/ingestion/extractor.ts—Extractorinterface +ExtractResulttype shared by all extractorssrc/lib/ingestion/extractor-fetch.ts— Fast-path primary extractor (fetch + HTML-to-text strip)src/lib/ingestion/extractor-playwright.ts—PlaywrightExtractor: headless Chromium/Firefox/WebKit, fresh context per run (no credential leakage), configurable timeout, graceful degradation if playwright is absent or launch failssrc/lib/ingestion/service.ts—IngestionServiceorchestrating primary → fallback with structured telemetry on every invocationsrc/cli/commands/add.ts—ob add <url>CLI entry pointOpt-in / threshold behaviour
Fallback only runs when
primaryResult.text.length < minContentLength(default 200). Without the flag, no browser process is ever spawned.Dependency
playwrightdeclared as an optional peer dependency — existing installs are unaffected. The import is guarded by a dynamicimport()at runtime; a missing package logs a warning and falls through to the primary result.Testing
47 unit tests using constructor-injected stub browser objects — no real browser, no network. Playwright's
loadPlaywrightFnis injectable via the constructor to sidestep ESM module spy limitations.Telemetry shape emitted on every
ingest()call:Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh issue create --repo TheWizardsCode/ContextHub --title Sample --body-file -(http block)/usr/bin/gh gh issue create --repo TheWizardsCode/ContextHub --title Sample --body-file - /wt k/ContextHub/Conrev-parse bash i/mo�� show-toplevel /tmp/wl-wt-err-wo4xgR/local-repo/.worklog/tmp-worktree-W2QQZD/wt in/bash -z --show-toplevel i/mock-bin/bash bash(http block)If you need me to access, download, or install something from one of these locations, you can either: