Date: 2026-12-05
Status: historical experiment; see CONCEPTS.md for the current architecture.
Scope: exploratory test of replacing the Playwright browser path with lighter HTTP/DOM tooling for text extraction.
The existing CI text snapshots come from cp-livive-net/scripts/screenshots.py.
For each view, Playwright:
document.body.innerText and writes a plain-text DOM snapshot.The text snapshots are written to artifacts/text/*.txt and included in
report.md only. index.html and report.pdf remain screenshot-based.
cp-livive-net/scripts/report.py also uses Playwright Chromium to render
index.html into report.pdf.
The question for this experiment was not how to replace that script. The goal was to use the existing workflow as a test case for distillation: how much tooling can be removed, and how much output fidelity survives.
| Component | Approximate installed size |
|---|---|
| Playwright Chromium | 377 MB |
| Playwright Chromium headless shell | 206 MB |
| happy-dom | 18 MB |
The Playwright browser cache is roughly 583 MB on this machine. happy-dom is roughly 18 MB after installation.
Environment notes:
better-sqlite3 11.x does not build on Node 26.python3 was 3.9.6.screenshots.py uses PEP 604 union syntax (str | None) and therefore
requires Python 3.10+.Requested the production Vite preview at /login and /admin with curl.
Both routes returned the same SPA shell:
<!doctype html>
<html lang="en">
<head>
...
<script type="module" crossorigin src="/assets/index-CTKtd__A.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CYu2h78v.css">
</head>
<body>
<div id="root"></div>
</body>
</html>
/login and /admin are byte-for-byte the same shell. The actual page content
is produced by React after the JavaScript bundle runs.
curl, httpx, or any non-JavaScript HTTP client can retrieve the shell, but not the rendered page text. There is no server-side HTML for individual routes.
lynx was not installed in the test environment, so it was not run directly.
Its architectural limitation is the same as curl: it does not execute
JavaScript. Against this SPA it would receive the same <div id="root"></div>
shell.
For this application, a text browser is in the same category as an HTTP client
with respect to page text: it cannot produce the innerText snapshots the
current workflow records.
Started a seeded backend on a non-default port and drove the API with httpx.
Sequence tested:
POST /auth/login
GET /auth/me
GET /jobs
GET /users?role=customer
GET /users?role=technician
GET /jobs/1
GET /jobs/1/messages
GET /jobs/1/quote
GET /jobs/1/invoice
Non-GET requests included X-Requested-With: XMLHttpRequest, matching the
frontend CSRF convention.
The backend issues the session cookie as Secure:
Set-Cookie: sid=...; Path=/; HttpOnly; Secure; SameSite=Lax
Over plain http://127.0.0.1, httpx correctly declines to send a Secure
cookie. The first authenticated request therefore returned 401.
The workaround used in the experiment was to extract sid from the
Set-Cookie header and re-add it as a normal cookie. This is the same class of
workaround already present in screenshots.py for Chromium over plain HTTP.
With the cookie re-injected, all requests succeeded:
| Endpoint | Result |
|---|---|
POST /auth/login |
200, returned Admin Owner |
GET /auth/me |
200 |
GET /jobs |
200, 3 jobs |
GET /users?role=customer |
200, 3 customers |
GET /users?role=technician |
200, 2 technicians |
GET /jobs/1 |
200, job + customer + technician + messages |
GET /jobs/1/messages |
200, 4 messages |
GET /jobs/1/quote |
200, 3 line items, status approved |
GET /jobs/1/invoice |
200, 3 line items, status draft |
Representative response data:
jobs:
Stair Runner Installation pending Client Three / Tech One
Bedroom Carpet Replacement scheduled Client Two / Tech Two
Living Room & Hallway Carpet in_progress Client One / Tech One
job 1:
address: 123 Maple Street, Springfield
customer: Client One (client1@cp.livive.net)
technician: Tech One (tech1@cp.livive.net)
messages:
Client One shared Hi! What time will the installer arrive on Monday?
Admin Owner shared Tech One will arrive between 9 and 10am on Monday.
Admin Owner internal Subfloor is uneven near the hallway — bring extra padding.
Tech One shared On my way, ETA about 15 minutes.
quote:
approved
Carpet — living room 180 sq ft $3.50
Carpet — hallway 60 sq ft $3.50
Installation labor 1 job $450.00
invoice:
draft
total: $1,290.00
httpx can reproduce the login sequence, role selection, job/quote/invoice/ message retrieval, and the data shown on the six captured pages.
httpx cannot retrieve the page text itself. To produce text snapshots, the renderer has to be recreated in Python:
Admin dashboard, New Job, All jobs, form labels, etc.)toLocaleStringIntl.NumberFormatThat is a parallel implementation of the React view layer. It is feasible, but the fidelity depends on maintaining that second renderer as the UI changes.
Instead of duplicating the view layer, the built Vite bundle was executed in
happy-dom:
fetch.happy-dom window at the target route.window.fetch to add the sid cookie and strip the /api prefix.document.body.innerText / textContent.The /api prefix has to be stripped because Vite normally proxies /api/* to
the backend, while the backend mounts routes at the root.
All six views rendered content:
login
admin-dashboard
admin-job-detail
technician-dashboard
customer-dashboard
customer-quote
Admin dashboard output from the happy-dom run:
cp.livive.net
Admin OwnerAdminBuild reportLog out
Admin dashboard
New Job
TitleAddressDescriptionCustomerSelect customer…
Client One (client1@cp.livive.net)
Client Two (client2@cp.livive.net)
Client Three (client3@cp.livive.net)TechnicianUnassigned
Tech One (tech1@cp.livive.net)
Tech Two (tech2@cp.livive.net)Statuspending
scheduled
in progress
completed
Create job
All jobs
Stair Runner Installation789 Pine Road, Springfield
PendingClient Three · Tech OneDec 5, 2026, 03:30 AM
Bedroom Carpet Replacement456 Oak Avenue, Springfield
ScheduledClient Two · Tech TwoDec 5, 2026, 03:30 AM
Living Room & Hallway Carpet Install123 Maple Street, Springfield
In ProgressClient One · Tech OneDec 5, 2026, 03:30 AM
A crude token-overlap comparison was run against the existing Playwright text snapshots:
| View | happy-dom chars | saved snapshot chars | saved-token coverage |
|---|---|---|---|
| login | 146 | 194 | 57.9% |
| admin-dashboard | 703 | 764 | 63.5% |
| admin-job-detail | 1190 | 1313 | 64.5% |
| technician-dashboard | 300 | 353 | 67.6% |
| customer-dashboard | 167 | 214 | 70.4% |
| customer-quote | 954 | 1067 | 69.8% |
The metric is crude and understates content fidelity. Observed causes of mismatch:
innerText does not insert the same block-level line breaks as
Chromium. Inline elements fuse together (EmailPasswordSign in,
Admin OwnerAdminBuild reportLog out).The rendered content itself was present for all six views.
Rendering the real bundle without Chromium required:
window, document, navigator, location, history, storage, and
fetch shims./api paths.The test printed all six results, then the Node process remained alive until
the command timeout because React’s message polling timer kept the event loop
open. A production harness would need explicit window.close() or timer
cleanup.
happy-dom can execute the real application and produce page text without a browser binary. It preserves component structure and avoids duplicating the React templates.
It does not reproduce Chromium’s layout-aware innerText exactly. Some form of
DOM walker or normalization would be needed for close parity.
| Approach | Login/data workflow | Rendered page text | Screenshots | Browser binary | Main source of drift | |
|---|---|---|---|---|---|---|
| Playwright | Yes | Yes, layout-aware innerText |
Yes | Yes | Chromium | Browser dependency |
| curl / httpx → frontend | No | No | No | No | No | SPA does not server-render |
| lynx | No | No | No | No | No | No JavaScript execution |
| httpx → API | Yes | Only by recreating React views | No | No | No | Parallel view renderer |
| happy-dom + built bundle | Yes | Yes, with whitespace differences | No | No | No | DOM/layout emulation differences |
The application is a client-rendered SPA. The server returns one HTML shell for every route. HTTP clients and text browsers cannot see page text.
The API is fully accessible without a browser. httpx reproduced the
sign-in and data-retrieval sequence after handling the Secure cookie
manually.
API access is not equivalent to page text. Text snapshots require the presentation layer: labels, ordering, conditionals, formatting, and role- specific panels.
happy-dom can render the actual bundle without Chromium. Content was present for all six views, and the real React code was exercised.
happy-dom is not a layout engine. Its text output differs from Chromium
innerText, especially around inline/block boundaries. Exact parity needs
additional normalization.
The browser is still on the critical path for other outputs. Playwright
is currently used for screenshots and for rendering report.pdf. Removing
it from text extraction alone would not remove it from the CI toolchain.
Size reduction is substantial but not free. The browser cache is roughly 583 MB; happy-dom is roughly 18 MB. The smaller stack trades browser installation for a Node-based DOM harness and its compatibility quirks.
The simplest HTTP path has the largest fidelity cost. httpx needs no JavaScript runtime, but matching the current text output means maintaining a second renderer for the UI.
screenshots.py, report.py, or CI.Temporary prototypes were run outside the repository:
No repository files were changed by the experiment itself. The only file added
for this write-up is browser_reduction.md.