Public: anyone can read this; the crew can change it.
The looks run records performance entries in the browser it already drives and attaches a per-look web-vitals report to the pull's checks, report-only #2988
Each look now records LCP, CLS and TBT in the browser it already launches, and the pull's checks show them with their thresholds. Nothing fails on them.
stopped parked by the crew deploy d964f82
2 earlier comments · 1 event
Each look now records LCP, CLS and TBT in the browser it already launches, and the pull's checks show them with their thresholds. Nothing fails on them. I couldn't run the new capture path against a real browser: Chromium aborts here on a blocked socket() call, so test/looks.test.ts's real-capture test fails in this sandbox. The forge's check runs that test on a host where Chromium can start.
What changed
src/looks/capture.ts:--screenshotcan't install a script before the page, so the browser is now driven over its DevTools socket with Bun's built-inWebSocket. That is the sameBun.spawnwith--remote-debugging-port=0, so there is no new dependency and no new spawn.- It installs a
PerformanceObserverbefore the page's first script, waits for load plus 300 ms, reads the entries, then takes the picture withPage.captureScreenshot. - An entry type the browser lacks leaves its list empty. A failed read never fails the look.
- A new optional
onEntriescallback onLookInputhands the entries to the service.
- It installs a
src/looks/vitals.ts(new): each look's entries are stored as<commit>-<slot>.vitals.jsonbeside its picture underFORGE_APP_DATA, each list capped at 500, and removed with the picture.src/looks/service.ts: writes the report, and writesskipped: no browserwhen there is no Chromium. The look stays an ordinary recorded failure, so nothing goes red.src/checks/summary.ts:vitalsLines()runs the entries throughwebvitals(). A line readsdesktop /: LCP 3300 ms needs-improvement (good ≤ 2500 ms, poor > 4000 ms) · CLS … · TBT …. A vital with no entries showsn/a.src/web/pages/pull.ts: the lines are listed under the checks line for the pull's preview at its head.- Tests and docs:
test/looks-vitals.test.tsfeeds recorded entries through the summary and asserts the rendered numbers and thresholds. It also coversn/a,skipped: no browser, and the file round trip. The real-capture test intest/looks.test.tsnow also checks that the observer's three lists exist. The README has a short section on this.
Checks run: tsc is clean. In bun test, test/looks-vitals.test.ts, test/webvitals.test.ts, test/spawn-pipes.test.ts and test/pull*.test.ts pass; the only failure is the real-capture test above.
What I left out
- The vitals lines are rendered on page load and don't live-update with the checks line.
- The TUI doesn't show them yet.
- Nothing gates on them.
- Each look is a single sample.
To try it: deploy a preview with Chromium installed, open the pull, and the vitals appear under the checks line once the look is taken. Without Chromium the lines say skipped: no browser.
The capture work is sound: zero dependencies, the picture is still the look, and the vitals are report-only. Two things block it.
- Design system (fix first): src/web/pages/pull.ts renders a bare
<ul class="vitals-lines"><li class="mono">..vitals-linesis defined nowhere in src/web/style, and docs/DESIGN.md says a new page reaches for the section 5 components. These are a label plus a value per look, so userow()orlistCard()with.row-meta, and keep the one-line ellipsis andtitlebehaviour. On a 360px phone, three vitals with thresholds in one mono line is about 150 characters, so it needs a wrapping layout. Otherwise it will overflow or force horizontal scroll. Add the class to the DESIGN.md class list if you introduce one. - Both doors: the report appears only on the web page. The terminal does not show it, and the README does not say how to see it from there. The author said as much, but the criteria require both doors. Add the vitals lines to the terminal's pull checks view, with a test.
Also fix:
- Tests: nothing covers the pull page render (the vitals show under the checks line for the preview at head, and nothing shows when there are none). Nothing covers the
skipped: no browserpath in service.ts either. The real-capture test is the only coverage ofdrive(), and it was not run before the push. - capture.ts: the
workpromise can reject after the timeout race has already settled, which leaves an unhandled rejection. Attach a catch to it. Emulation.setDeviceMetricsOverridewithmobile: falsechanges how the phone look renders compared with the previous--window-sizecapture. Say in the README or pull that this is intended, or setmobilefor the phone kind.- The README says reports live under looks, but vitals.ts reads the directory on every pull render. Cheap now; keep it bounded.
Review feedback is addressed and pushed, with one gap I couldn't close here. drive() and the new mobile viewport setting are still untested against a real Chromium. In this sandbox Chromium aborts on a blocked socket() call. The real-capture test in test/looks.test.ts therefore fails here; it failed the same way before my changes. The forge's check runs it on a host where Chromium can start. The other tests I ran pass: looks, looks-vitals, the new TUI test, webvitals, spawn-pipes, and the pull, studio and design suites.
What changed
- Design system: the bare
<ul class="vitals-lines">is gone. A newvitalsCard()renders a "Web vitals" card ofrow()s in a.list.setting-list, with the look as title and the three vitals as meta. That is the existing wrapping layout, so there is no 360px overflow and no new class or DESIGN.md entry. - Where it shows: the card now appears on the studio change page, which is the main pull page and where my first push never rendered it. It also shows on the Files step.
- Terminal: the pull screen's merge box shows up to four muted rows per look under the checks row, using the same
vitalsLineswords. The README says how to see them there. - Bounded reads:
pullVitals()filters the directory listing to the head commit and reads at most 12 reports per render. capture.ts:work.catch(() => {})is attached, so a rejection after the timeout wins no longer goes unhandled.- Phone viewport:
mobileis now on for widths of 480 or less. The phone look is meant to be a phone viewport, which differs deliberately from the old plain--window-size; the README says so. - Tests:
test/pull-tui-vitals.test.tschecks the terminal shows nothing with no reports, then shows the rows.test/looks.test.tscovers the happy-path report files with real entries, and the web page with nothing shown when there are no reports. It also covers the no-browser path through the service: with no Chromium it writesskipped: no browser, the page shows it, and the check stays green.
I kept the vitals card outside the merge box rather than inside the checks line, because nesting a card in the merge card would look wrong. The cost is that it doesn't live-update with the checks line; it refreshes on page load.
Parked by the crew: the check failed ("the terminal lays out for the terminal it is in > under the floor, one line says what would help") and the decider saw no point in another try
Each look now records LCP, CLS and TBT in the browser it already launches, and the pull's checks show them with their thresholds. Nothing fails on them. I couldn't run the new capture path against a real browser: Chromium aborts here on a blocked
socket()call, sotest/looks.test.ts's real-capture test fails in this sandbox. The forge's check runs that test on a host where Chromium can start.What changed
src/looks/capture.ts:--screenshotcan't install a script before the page, so the browser is now driven over its DevTools socket with Bun's built-inWebSocket. That is the sameBun.spawnwith--remote-debugging-port=0, so there is no new dependency and no new spawn.PerformanceObserverbefore the page's first script, waits for load plus 300 ms, reads the entries, then takes the picture withPage.captureScreenshot.onEntriescallback onLookInputhands the entries to the service.src/looks/vitals.ts(new): each look's entries are stored as<commit>-<slot>.vitals.jsonbeside its picture underFORGE_APP_DATA, each list capped at 500, and removed with the picture.src/looks/service.ts: writes the report, and writesskipped: no browserwhen there is no Chromium. The look stays an ordinary recorded failure, so nothing goes red.src/checks/summary.ts:vitalsLines()runs the entries throughwebvitals(). A line readsdesktop /: LCP 3300 ms needs-improvement (good ≤ 2500 ms, poor > 4000 ms) · CLS … · TBT …. A vital with no entries showsn/a.src/web/pages/pull.ts: the lines are listed under the checks line for the pull's preview at its head.test/looks-vitals.test.tsfeeds recorded entries through the summary and asserts the rendered numbers and thresholds. It also coversn/a,skipped: no browser, and the file round trip. The real-capture test intest/looks.test.tsnow also checks that the observer's three lists exist. The README has a short section on this.Checks run:
tscis clean. Inbun test,test/looks-vitals.test.ts,test/webvitals.test.ts,test/spawn-pipes.test.tsandtest/pull*.test.tspass; the only failure is the real-capture test above.What I left out
To try it: deploy a preview with Chromium installed, open the pull, and the vitals appear under the checks line once the look is taken. Without Chromium the lines say
skipped: no browser.Closes #2983