Skip to content

perf(dashboard): Prefetch a Conversation when its list row is hovered - #2723

Merged
thomasjiangcy merged 2 commits into
mainfrom
feat/dashboard-hover-prefetch
Nov 5, 2026
Merged

thomasjiangcy merged 2 commits into
mainfrom
feat/dashboard-hover-prefetch

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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 useConversationData counts a prefetch that is less than 30s old as the open fetch:

  • The transcript opens at once at the "New" marker, from the prefetched unread page.
  • The open fetch only checks for newer events. That's the mailbox read, then a detail read that is usually a 304.
  • A prefetch that is still running when the reader clicks is shared, as before.

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 useConversationData change, the case fails because the open asks for ?unreadPage=true again.

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]

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]>
@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 9:09am UTC

Request Review

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Show 4 more changed screenshots
Conversation Subagents · Desktop
Conversation Subagents · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed
System Cache Share · Desktop
System Cache Share · Desktop
Changed
System Cache Tokens · Desktop
System Cache Tokens · Desktop
Changed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Nov 5, 2026
@thomasjiangcy
thomasjiangcy merged commit 339db19 into main Nov 5, 2026
42 checks passed
@thomasjiangcy
thomasjiangcy deleted the feat/dashboard-hover-prefetch branch November 5, 2026 09:16
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

1 active deployment
Preview – junior-docs — b8e6282e 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: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant