Repository navigation
Description
Origin: the widget streaming perf effort (PRs #546 #547 #549 #550 #553, plus #554 #555). Everything below is grounded in what that effort actually needed; nothing speculative.
Question
Should the in-page probe that drove the perf lane become a first-class page.* tool, so an agent
debugging jank in a conciv-hosted page gets attribution in one call instead of hand-rolling it?
Evidence it would have paid off
Time accounting of the lane, roughly: ~60% of the probe work was page.evaluate glue that ran
inside the page (rAF frame histogram, MutationObserver over every shadow root with per-container
and per-attribute attribution, LoAF capture with script attribution, window-error capture). The
decisive attribution leaps all came from that data:
- removals were inside
p/li/span, not message rows: killed the useChat-identity hypothesis, pointed
at streamdown (PR fix(solid-streamdown): stable hast identity across streaming updates #546). - 96% of attribute writes were the mascot's gsap per-frame style writes: acquitted the mascot,
found the one real defect (force3D, PR perf(mascot): pin force3D on continuous tweens for stable compositor layers #547). - "is highlighting actually on?" is a 5-line shadow-piercing DOM count; its absence cost hours
(rig charset bug, report.md). - RO-loop errors surface on the window error event, not console: the leak-hunt session could not
reproduce until told the channel (PRs fix: dev hosts no longer echo-loop console.error under agent env #554/fix(ui-kit-chat): virtualized thread stops tripping the ResizeObserver notification loop #555).
Shape (extends the page extension, same patterns it already uses)
The page extension already has page.track (action: start | report, React renders),
page.console (buffered, since), page.inspect, page.dom, page.eval. page.perf slots in
as category read, same start/report action pattern as track:
page.perf {action: 'start'}: install the probe (idempotent). Records: rAF frame deltas,
long-animation-frameentries with script attribution (Chromium only; reportunsupportedon
other engines, never silently empty), MutationObserver over document + every open shadow root
(added/removed/characterData/attribute counts, removed-node kinds, per-container churn, attribute
writes keyed byattr @ tag.class/[data-scope/part], WeakSet re-insertion counter), window
errorevents and console errors/warnings, JSHeap/Nodes samples when the engine exposes them.page.perf {action: 'report', since?}: frame percentiles (p50/p90/p99/max, count over 16.7ms),
long frames with attribution, mutation totals + top churn containers + top attribute bags,
re-insertion count, errors, memory peaks. Windowed bysinceso a caller can bracket a turn.page.perf {action: 'reset'}: zero the counters without reinstalling (the rig needed this at
send-time so pre-turn warmup does not bill to the turn).
Source to start from: the perf lane's Playwright rig probe (an addInitScript installing window.__perf + a shadow-root-walking MutationObserver), which is already the start verb; the rig's post-processing (percentiles, toggle-window slicing) is report. Omri has the rig locally (gitignored scratch).
What it does NOT do (and must say so)
- It does not drive a turn. Measuring a real streaming turn still needs a driver (the rig, or the
user acting). The tool is the probe inside the driver, not the driver. - It does not replace engine-specific profiling (Firefox profiler, CPU profiles); it is the
first-hop attribution that decides whether those are needed. - It cannot see the feel. The clip-path collapse measured best in toggle windows and was rejected
on feel; Recorded so nobody optimizes into that hole again.
Capture hygiene that must ship WITH the tool (else it measures phantoms)
Measurement traps all hit during the lane:
- Agent-launched vite dev hosts: Vite 8 forwardConsole auto-on + devtools console pipe echoed
console errors unboundedly (PR fix: dev hosts no longer echo-loop console.error under agent env #554 fixed the config; until every host has it, scrub
CLAUDECODE/CLAUDE_CODE/AI_AGENT or the probe's error counts are garbage). - Host pages that inline the widget bundle must declare utf-8 or the inline shiki worker mojibakes
and highlighting is silently off in every browser (perf(ui-kit-chat): warm shiki grammars off the main thread #549 host tests). - Window at the right moment: reset at send, not at composer-ready.
- Turn-length variance: compare ratios and per-second rates, never raw totals, across live turns.
- Devtools overlays (TanStack devtools) pollute LoAF attribution on dev hosts; measure verdicts on
the prod bundle, attribute on the dev host.
Acceptance
page.perf start/report/resetexists inpackages/extensions/page, schema-validated, real
browser tests (Playwright, shadow-root traversal proven with the widget's own shadow roots).- Unsupported capabilities are reported as
unsupported, never as zeros. - The perf rig is rewritten to call the tool's probe (one copy of the probe, not two).
- Tool description carries the hygiene notes in one line each so the agent reads them at use time.
Out of scope
CI perf gating (separate effort), always-on monitoring, Firefox-side LoAF equivalents.
Activity