Skip to content

docs(runbooks): local UI render harness, and the capture script it uses - #1739

Merged
lilyshen0722 merged 2 commits into
mainfrom
kai/task042-ui-render-harness
Sep 18, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
kai/task042-ui-render-harness

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

A runbook and a small capture script for the one thing a change can need that nothing in the repo can produce today: before/after evidence from a real browser.

Why this exists

jsdom has no layout engine. A card that still renders the field it is supposed to redact, a flex row that clips, an off-canvas panel that never opens — all pass every render test, and the only way to know is to render the page. PR #1731 needed exactly that evidence, and the recipe for producing it lived in one seat's shell history: the next seat rederived every step of it and spent about an hour on ports, CORS, database credentials and worktree paths that had nothing to do with the change under review.

What it contains

docs/runbooks/local-ui-render-harness.md — the stack (which port, which env var, why), the capture step, the before/after pair recipe, a worked example, a symptom→cause table, and teardown.

scripts/ui-evidence-shot.mjs — one command: log in through the API, inject the JWT into localStorage.token before first paint (where the shell reads it), render a route, write a full-page PNG and a body.innerText dump, and print every non-2xx response and console error. Playwright comes from the root node_modules; no new dependency.

Measured, not read off the code

Every gotcha in the runbook was hit on this machine while writing it:

  • CORS is FRONTEND_URL (backend/server.ts:98). Serving the frontend on an origin that is not in that list produces Access to XMLHttpRequest … blocked by CORS policy + Network Error + net::ERR_FAILED — which reads as a broken app, not a missing allow-list entry. Measured with :5173 (the repo's own e2e default port).
  • REACT_APP_API_URL is compiled in via an explicit define (frontend/vite.config.ts), so it must be set when vite starts; the served-from-localhost fallback is :5000, which AirPlay Receiver occupies on some machines. Port 5000 was free here, port 5050 was used anyway so the recipe is correct either way.
  • The repo .env is the source of truth for the database user the container was initialised with. Passing the compose defaults (postgres/postgres) authenticates as a role that does not own the database: the API answers, /api/health reports degraded, and message paths fail quietly. Measured: password authentication failed for user "postgres".
  • A worktree before/after needs server.fs.allow covering both the worktree root (as a realpath — /tmp is /private/tmp, and vite reports the resolved path) and the checkout the symlinked node_modules point at. With only one, either every webfont 403s (screenshots differ for a reason unrelated to the change) or index.html itself is refused.
  • A local boot rewrites the skills index unless SKILLS_CATALOG_PATH is pointed elsewhere; with it pointed at /tmp, git status stays clean after a full run.
  • The viewer is the test. The integration's creator sees the routing state in both revisions; a pod member who is not the creator sees the fix. Capture as the wrong one and the pair comes back identical, looking like a clean pass.

The worked example is a run of this harness

Base 5d067f45 versus head cda51208, same route, same seeded connector, viewer = pod member not the creator:

--- /tmp/before.txt
+++ /tmp/after.txt
 Telegram
 1 connected

-Chat -1001234567890
+Telegram chat connected

and the same viewer's GET /api/integrations/<podId>:

Revision config.chatId config.linkedUserId config.linked
base 5d067f45 -1001234567890 6aace2…ae43 (absent)
head cda51208 (absent) (absent) true

Both artifacts are in the repo's PR #1731 record; this runbook is how the next person reproduces them in one sitting.

Scope and what this is not

  • Docs plus one script. No product code, no new dependency, no CI job.
  • Not a CI tier. CLAUDE.md's standing call is that the Playwright CI layout tier gets built when a second person is shipping UI regularly; this is the manual habit that holds the line until then, and the runbook says so.
  • Not the hosted-demo walkthrough — that is docs/demo-verification.md.
  • scripts/ is outside both packages the version guard covers (cli/src, commonly-mcp/src), so no version bump is implied.

Follow-up I did not do unilaterally

CLAUDE.md's knowledge-discipline rule asks for a pointer from the slim anchor to a new deep doc. I left that out of this PR: the runbook category line already exists, and a pointer line is the doc owner's edit, not mine. Say the word and I will add one.

samxu01 pushed a commit that referenced this pull request Sep 18, 2026
…g it

Vera, on #1739: `.env` is not tracked, only `.env.example` is. That is right, and
it made the first command in the runbook fail on a fresh clone while the prose
pointed the reader at a file that does not exist ("the repo .env", "already in
.env").

- new step 0: `[ -f .env ] || cp .env.example .env`, plus the grep that shows
  the values it needs to carry. `-f` rather than a bare `cp` because this
  machine already had a `.env` and a plain copy would have clobbered a
  developer's local secrets;
- `.env.example` is named as the file those values actually live in;
- `LOCAL_DEV_LOGIN_ENABLED=1` corrected to `=true` (the value in
  `.env.example`), with the reader cited (`localDevLoginService.ts:44`);
- the base-worktree block says out loud that it sources the same local `.env`,
  since the worktree does not contain one;
- gotchas row and See-also updated.

Verified by running it, not by reading: copy `.env.example` to a temp `.env`,
source it, `PG_USER=commonly PG_PASSWORD=password PG_DATABASE=commonly
LOCAL_DEV_LOGIN_ENABLED=true [email protected]
FRONTEND_URL=http://localhost:3000`. All seven bash blocks pass `bash -n`.

Also tightened the Node bullet to what was actually measured (the 34/369 unit
suites that die under the v26 on PATH) and noted that the capture script is not
one of them — it resolves playwright from the root node_modules and launches
chromium under v26.
A change whose acceptance is visual has no tier today: jsdom has no layout
engine, so a card that still shows the field it should redact and a flex bug
that clips a row both pass every render test. PR #1731 needed before/after
evidence for exactly that and the recipe lived in one seat's shell history.

The runbook records the path that cost real time to rederive, all of it
measured on this machine rather than read off the code:

- the backend's CORS allow-list IS FRONTEND_URL, so every frontend port you
  serve must be in it or the app looks broken (CORS + net::ERR_FAILED rather
  than a layout bug);
- REACT_APP_API_URL is baked in via an explicit vite `define` — no env var at
  runtime will move it — and it must be set because the localhost fallback is
  :5000, which AirPlay owns on some machines;
- the repo `.env` is the source of truth for the PG user the container was
  initialised with; the compose defaults authenticate as a role that does not
  own the DB and the API answers `degraded` rather than failing;
- a before/after pair needs the base revision in a worktree, and that worktree
  needs `server.fs.allow` covering BOTH the worktree root (realpath — /tmp is
  /private/tmp) and the checkout the symlinked node_modules point at, or every
  webfont 403s and the two screenshots differ for the wrong reason;
- which viewer you capture as is the test: the integration's creator sees the
  routing state in both revisions, a member who is not the creator sees the fix.

scripts/ui-evidence-shot.mjs writes a full-page PNG and a body.innerText dump,
and prints non-2xx responses and console errors. The text dump is the evidence
— a text-only agent cannot read the PNG — and the worked example is a one-line
diff plus a three-field payload table.

Docs plus one script; no product code.
…g it

Vera, on #1739: `.env` is not tracked, only `.env.example` is. That is right, and
it made the first command in the runbook fail on a fresh clone while the prose
pointed the reader at a file that does not exist ("the repo .env", "already in
.env").

- new step 0: `[ -f .env ] || cp .env.example .env`, plus the grep that shows
  the values it needs to carry. `-f` rather than a bare `cp` because this
  machine already had a `.env` and a plain copy would have clobbered a
  developer's local secrets;
- `.env.example` is named as the file those values actually live in;
- `LOCAL_DEV_LOGIN_ENABLED=1` corrected to `=true` (the value in
  `.env.example`), with the reader cited (`localDevLoginService.ts:44`);
- the base-worktree block says out loud that it sources the same local `.env`,
  since the worktree does not contain one;
- gotchas row and See-also updated.

Verified by running it, not by reading: copy `.env.example` to a temp `.env`,
source it, `PG_USER=commonly PG_PASSWORD=password PG_DATABASE=commonly
LOCAL_DEV_LOGIN_ENABLED=true [email protected]
FRONTEND_URL=http://localhost:3000`. All seven bash blocks pass `bash -n`.

Also tightened the Node bullet to what was actually measured (the 34/369 unit
suites that die under the v26 on PATH) and noted that the capture script is not
one of them — it resolves playwright from the root node_modules and launches
chromium under v26.
@samxu01
samxu01 force-pushed the kai/task042-ui-render-harness branch from 867c5db to 1dfa927 Compare September 18, 2026 10:15
@lilyshen0722
lilyshen0722 merged commit 8b154ef into main Sep 18, 2026
13 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.

1 participant