Repository navigation
perf(dashboard): Prefetch a Conversation when its list row is hovered - #2723
Merged
Merged
Conversation
A resting pointer or focus on a sidebar or home list row fetches the detail as the open would, with the mailbox and the unread page. The next visit uses that fetch as its open fetch, so it opens at once and at the New marker, and only checks for newer events. Co-Authored-By: Thomas Jiang <[email protected]> Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
10 screenshot changes — 10 changed · 0 added · 0 removed Review screenshots in Frameshift |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ffd7419. Configure here.
The open fetch compares its ETag with the prefetched one, so it cannot see a change that the prefetch already brought. Run the same ETag check in the prefetch.
thomasjiangcy
approved these changes
Nov 5, 2026
BYK
added a commit
that referenced
this pull request
Nov 5, 2026
…#2764) 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 - I rebased this onto main after #2757 (`perf/dashboard-static-css`) merged, and resolved the conflict in the shell `<head>`. Inline Tailwind is gone and the script sits before the new stylesheet link. - Hover prefetch (#2723) and the open refetch work as before. A client-side navigation never takes the early response, because the shell only sets it on a full page load. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Adcae193f23dc8c1589b3fb8e4e36e0c1 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3Adcae193f23dc8c1589b3fb8e4e36e0c1/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Opening a Conversation from the sidebar or the home list waits for the detail fetch before the transcript shows. This change starts that fetch when the pointer rests on a row for 150ms, or when the row gets focus. A pointer that moves across the list fetches nothing. Touch is skipped, because a tap opens the row at once. The open Conversation is skipped, because it already polls.
The prefetch sends the same request as the open: one request with the mailbox and, in the default "open at unread" mode, the unread page. It sends no version header, so it can't get a 304 that drops the unread page.
Every visit still fetches once at open, so it doesn't miss messages that arrived while the reader was away. Before this change, a cached copy from a prefetch would not count as the visit's open fetch. The open would ask for the unread page again, the version header would get a 304, and the transcript would read the page around the read position in its own request. So in the default mode, a prefetch would have made opens slower to reach the "New" marker. Now
useConversationDatacounts a prefetch that is less than 30s old as the open fetch:A visit removes the prefetch mark when it ends, because the read position can move during the visit. The mark is removed without changing the fetch time, so the copy goes stale on its normal schedule.
The new read-position e2e case covers a fast pointer move, a resting hover, and an open from the prefetch. Without the
useConversationDatachange, the case fails because the open asks for?unreadPage=trueagain.Possible follow-up: on a reopen from a non-prefetched cache, the server's 304 check ignores
unreadPage, so the unread page always comes in a separate request. That is unchanged here.via @thomasjiangcy.
--
View Session [Sentry]