# Issue-detail performance baseline Run the repeatable baseline from the repository root: ```sh pnpm exec playwright test --config tests/perf/issue-detail/playwright.config.ts ``` The rig starts an isolated seeded Paperclip instance, runs five samples for each scenario/profile, and writes median-ready raw data plus a Markdown table to `test-results/issue-detail-perf/`. Scenarios: - S1 warm in-app navigation: loads the Issues list, clears the waterfall, and clicks the seeded issue. - S2 cold open: creates a fresh browser context and deep-links to the seeded issue. Profiles: - Unthrottled. - Fast 4G network with 4x CPU slowdown. Override the sample count (minimum five) or port when needed: ```sh PAPERCLIP_ISSUE_PERF_RUNS=7 PAPERCLIP_ISSUE_PERF_PORT=3210 pnpm exec playwright test --config tests/perf/issue-detail/playwright.config.ts ``` S1 clicks as soon as the list row is visible. Set `PAPERCLIP_ISSUE_PERF_LIST_DWELL_MS=1500` to wait on the list first, as a person does. Task lists preload the chat of their top rows after the list's own reads settle, so S1 with a dwell measures a preloaded open and S1 without one measures an open that usually has to read the task. Outputs include `baseline.md`, `baseline.json`, and a Chrome trace for the first run of each scenario/profile. Open `*.trace.json` in Chrome DevTools Performance to inspect the `issue-detail:*` user-timing marks. Set `PAPERCLIP_ISSUE_PERF_PROFILE=1` to capture actual Chrome CPU samples and conversation-readiness transitions in one diagnostic sample per scenario/profile. Import the resulting `*.cpuprofile` in DevTools and inspect `*.readiness.json` for the task, comments, metadata, activity, runs, runtime, plan and transcript gates. Each gate records changes with `detail.ready`; use its last transition before content paint when a gate becomes pending after mount. These diagnostic runs include profiler overhead. Run without the flag for before/after latency claims. Readiness marks stay in the local browser and contain only fixed gate names and booleans; the harness enables them before navigation. For bundle comparisons, build the UI and serve the production assets from an isolated local instance with `PAPERCLIP_UI_DEV_MIDDLEWARE=false`. The default managed server above uses development middleware, which does not reproduce production chunk loading. Keep the server, database, browser profile and sample count the same for both builds, and avoid concurrent builds or test suites while measuring latency. Copy the first run's output outside `test-results/issue-detail-perf`, then reuse its persisted task with `PAPERCLIP_ISSUE_PERF_SEED_FILE=/path/to/before/baseline.json` and `PAPERCLIP_ISSUE_PERF_BASE_URL` pointing to that disposable instance. The harness validates the task identity before measuring. Network spans in the trace use recorded request start/end timestamps relative to task navigation; they include completed requests observed during the sample, even after content paint. ## Cold direct task load (chat bootstrap) A hard load of a task URL starts `GET /api/issues/:ref/chat-bootstrap` from the inline preload script, before the app's JavaScript loads. The chat's first-frame reads share that answer (`ui/src/lib/issue-chat-bootstrap.ts`) and fall back to their own requests when it fails, lacks a field, or stalls. `cold-bootstrap.perf.spec.ts` delays every API response (300 ms by default) so serial request stages show up as wall-clock time. It opens the task by URL in a fresh browser context with the app's JavaScript in the HTTP cache and no app storage. The finish event is the revealed history with the latest saved message and an editable composer. Its request-shape test always runs: one bootstrap request, no per-endpoint first-frame read before the frame, and no such read completing before it. Reads that start after the live socket connects are its catch-up refresh and are excluded. The benchmark is opt-in: ```sh PAPERCLIP_ISSUE_PERF_BASE_URL=http://127.0.0.1:3287 \ PAPERCLIP_ISSUE_PERF_COLD_RUNS=7 PAPERCLIP_ISSUE_PERF_LABEL=candidate \ pnpm exec playwright test --config tests/perf/issue-detail/playwright.config.ts cold-bootstrap -g benchmark ``` It writes `cold-bootstrap-