Skip to content

perf(dashboard): Start the first conversation read from the page head - #2764

Merged
BYK merged 1 commit into
mainfrom
perf/dashboard-early-detail
Nov 5, 2026
Merged

BYK merged 1 commit into
mainfrom
perf/dashboard-early-detail

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

On a cold load of /conversations/:id, the first detail read started only after the entry module downloaded and ran. In prod (0.280.0) that was 650–1,100ms after navigation start. An inline head script now starts that read while the browser downloads the client, and the client uses its response.

How it works

  • conversationOpenScript(basePath) (new src/conversation-open.ts) runs in the shell <head>, only on /conversations/<id> (and not new), with the base path removed, using the same match as conversationIdFromPath. It builds the exact path of the client's first read: /api/conversations/<id>?unreadPage=true&mailbox=true, or ?mailbox=true when the start position is latest. It reads the same localStorage key, which now lives in conversation-open.ts so the script and transcriptReadPosition.ts share it.
  • readDashboardResponse takes that response once, and only for the same path and only when it sends no validator. Every other read, including polls that send the detail version, fetches as before. If the path drifts, the result is one extra read, never wrong data. 401 handling, error handling, and recordDashboardServerVersion run on the early response too.
  • ETag/304: the first read has no cached copy, so it sends no validator and can't get a 304. The response still carries the detail version header, so later polls revalidate as before.
  • Auth: it's a same-origin GET with credentials: "same-origin", the same as the client read. The shell is served only to authenticated viewers.
  • CSP: the dashboard shell sends no CSP header and already has inline scripts (theme, Sentry config, error handler), so no nonce is needed.
  • Tracing: the script copies the sentry-trace and baggage meta values onto the request, so the server span stays in the page request's trace.
  • Placement: the script goes after the Sentry meta tags and before the stylesheet link, because an inline script after a stylesheet waits for the CSS. This PR also moves renderSentryHead above the stylesheet for that reason.
  • A rejected early fetch gets a no-op catch, so it can't trigger the page's unhandledrejection error screen before the client takes it. The client still sees the rejection.

I chose this over embedding the detail in the HTML (like #2724) because embedding would hold the HTML response for the detail read, which is p50 216ms for 200s in prod. It would also need its own ETag and mailbox handling on the server.

Timing (Playwright, mock conversations, cold cache, median of 7)

Measured on main at a2ba54556 (with #2757 static assets) before and after this change. Conversation internal:dashboard-qa. Times are ms from navigation start. "Transcript shown" is the first [data-transcript-seq] row in the DOM.

Profile Detail request starts Transcript shown
40ms RTT, 50 Mbps, no CPU throttle 973 → 66 1,383 → 1,211 (−172)
150ms RTT, 12 Mbps, 4× CPU throttle 3,770 → 238 5,120 → 4,885 (−235)

Every run made exactly one detail request. The detail read now finishes about 600ms before the transcript renders, while it competes with the JS downloads for bandwidth. The rest of the cold-open path is client boot.

Tests

  • I extended opens where the reader left off and reports what they read (e2e/conversations-read-position.spec.ts). It holds all client JS and checks that the detail read still arrives. It then checks that the open makes no second read, for both the unread and the latest start positions. This catches a URL drift between the script and readConversationData.
  • I also checked route matching by hand: root and /ops base paths, an encoded local:web: id, /conversations/new, nested paths, and a base-path prefix mismatch.

Checks

  • pnpm test:e2e:dashboard: 100/100 passed.
  • Dashboard typecheck and lint pass. lint-staged passed: file-length, test-architecture and dashboard-style.
  • Dashboard unit tests: 370 passed, 1 failed. The failure is dashboard-output.test.ts, which also fails on clean main in my sandbox (MISSING_EXPORT nitroIntegration from a hoisted @sentry/[email protected]).

Notes

via @BYK.

--

View Session in Sentry

On a cold load of a conversation page, the first detail read waited for
the entry module to download and run. An inline head script now starts
that exact read (same path, mailbox, and unread page) while the client
downloads, and readDashboardResponse takes the response once for the
matching path. A mismatch falls back to a normal fetch.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 5, 2026 6:53pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

6 screenshot changes — 6 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Page · Desktop
Automation Page · Desktop
Changed
Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK merged commit e9ddfa4 into main Nov 5, 2026
43 checks passed
@BYK
BYK deleted the perf/dashboard-early-detail branch November 5, 2026 19:08

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 6e0a6142 Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant