Skip to content

perf(dashboard): Serve styles, fonts, and avatar as hashed static assets - #2757

Merged
BYK merged 2 commits into
mainfrom
perf/dashboard-static-css
Nov 5, 2026
Merged

BYK merged 2 commits into
mainfrom
perf/dashboard-static-css

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

The page shell had the full Tailwind stylesheet (177 KB raw / 28 KB gzip) inline in every no-store HTML response. It also loaded Inter and Outfit through a render-blocking Google Fonts @import, which needs two more origins. The header and transcript avatar was a 76 KB PNG that was not hashed.

  • The client build now bundles src/styles.css (self-hosted fontsource variable fonts + dist/tailwind.css) into styles-[hash].css. The fonts are *-[hash].woff2 files under /_junior/dashboard/assets, the same immutable prefix as the JS from perf(dashboard): Serve dashboard browser files as static assets #2725. Fonts keep font-display: swap.
  • The shell links the stylesheet and preloads the two Latin font files. The other subsets load only when a page uses them. The forbidden page uses the same stylesheet link.
  • The avatar is an 88×88 (2× of size-11) hashed WebP: 3.2 KB. No PNG fallback, because every supported browser decodes WebP. /_junior/dashboard/avatar.png stays for older cached clients and the install icons.
  • Binary public assets are embedded as base64 and served with the content type from their extension.
  • Core no longer copies tailwind.css into server output. Nothing reads it now.

Numbers (/conversations, mock conversations, production build)

before after
HTML raw / gzip / br 189,104 / 31,888 / 24,789 B 11,141 / 2,902 / 2,292 B
Third-party origins fonts.googleapis.com, fonts.gstatic.com none
Render-blocking chain HTML → Google CSS → gstatic woff2 HTML → hashed CSS (fonts preloaded in parallel)
modulepreload links 58 58 (unchanged, see below)
Avatar 76,539 B PNG, revalidated 3,206 B WebP, immutable
Cold first load, same-origin br (HTML + head assets) 498,513 B 580,255 B

On a cold load, the first-load figure goes up because the CSS (23 KB br) and the Latin fonts (48 + 32 KB) now come from our origin instead of Google. The browser fetched about the same font bytes from gstatic before. On every later load, all of that is cached as immutable, so the HTML is the only transfer: 24.8 KB → 2.3 KB br.

Not in this PR: merging small chunks

esbuild has no minimum chunk size and no manual chunk grouping. 37 of the 58 preloaded chunks are under 4 KB, and 19 are under 1 KB. In an experiment, rolldown 1.2.15 with default splitting gave 21 static imports instead of 58 and 419,654 B br instead of 473,724 B, with the route splitting from #2734/#2738 kept. That needs the client build moved from tsup to rolldown and checked at runtime, so it is a separate follow-up.

Screenshots (mock conversations, 1440×900, dark)

The screenshots should look the same. Fonts loaded before: Inter 400/500/600/700, Outfit 500 from Google. After: Inter Variable 100–900, Outfit Variable 100–900 from the assets prefix.

before after
before transcript after transcript
before conversations after conversations

Header avatar at 4× zoom, PNG (left) and WebP (right):

avatar compare

Checks

  • pnpm test:e2e:dashboard (playwright, local chromium): 100 passed
  • pnpm --filter @sentry/junior-dashboard test: 370 passed, 1 failed. The failure is dashboard-output.test.ts. It also fails on clean main in this sandbox: the nitro build reports MISSING_EXPORT nitroIntegration from a hoisted @sentry/[email protected]. CI should run it.
  • nitro-plugin-module.test.ts and app-config.test.ts: 42 passed
  • typecheck (dashboard, core), dashboard and core oxlint, file-length, dashboard-style, test-architecture, package:lint, and the pre-push pnpm lint: pass

via @BYK.

--

View Session in Sentry

The page shell inlined the full Tailwind stylesheet (177 KB) into every
no-store HTML response and loaded Inter and Outfit from Google Fonts
through a render-blocking @import on two extra origins.

The client build now bundles the stylesheet with self-hosted variable
fonts into content-hashed files under /_junior/dashboard/assets. The
shell links the stylesheet and preloads the Latin font files. The avatar
in the header and transcript is now an 88x88 hashed WebP (3 KB instead
of the 76 KB PNG). Core no longer copies tailwind.css into server output.

Co-Authored-By: BYK <[email protected]>
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 5, 2026
…-css

# Conflicts:
#	packages/junior-dashboard/src/client/conversations/TranscriptMessageShell.tsx
@BYK
BYK enabled auto-merge (squash) November 5, 2026 18:14
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Automation Page Light · Desktop
Automation Page Light · Desktop
Changed
Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Conversation Child Agent Drawer · Desktop
Conversation Child Agent Drawer · Desktop
Changed
Conversation Event Log Virtual · Mobile
Conversation Event Log Virtual · Mobile
Changed
Show 12 more changed screenshots
Conversation Fork Dialog · Desktop
Conversation Fork Dialog · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Queue Compact · Desktop
Conversation Queue Compact · Desktop
Changed
Conversation Share Details · Desktop
Conversation Share Details · Desktop
Changed
Conversation Sidebar Review Chip · Desktop
Conversation Sidebar Review Chip · Desktop
Changed
Conversation Sidebar Review Chip Light · Desktop
Conversation Sidebar Review Chip Light · Desktop
Changed
Conversation Unsent Answers · Desktop
Conversation Unsent Answers · Desktop
Changed
Conversations Pinned Light · Desktop
Conversations Pinned Light · Desktop
Changed
Locations · Desktop
Locations · Desktop
Changed
People · Desktop
People · Desktop
Changed
Review Desk Light · Desktop
Review Desk Light · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

2 more changed screenshots in Frameshift.

@BYK
BYK merged commit 6da128c into main Nov 5, 2026
45 checks passed
@BYK
BYK deleted the perf/dashboard-static-css branch November 5, 2026 18:23
@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:29pm UTC

Request Review

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]>
BYK pushed a commit that referenced this pull request Nov 5, 2026
…nks (#2765)

The dashboard head preloads 58 modules, and many of them are under 1 KB.
esbuild (tsup) splits every set of shared modules into its own chunk and
has no minimum chunk size. Rolldown merges shared code into the chunks
that load it, so the client scripts now build with tsdown (rolldown),
which the repo already uses.

Route splitting from #2734/#2738 and the head preloads from #2738 are
unchanged. Every route still loads its page lazily, and the manifest
still lists the entry's static imports for `modulepreload`.

## Changes

- `tsdown.client.config.ts` builds the client JS. It keeps the defines,
the `@sentry/junior-plugin-api` alias and the content-hashed names
(`client-[hash].js`, `chunks/[name]-[hash].js`).
- `failOnWarn` makes an unresolved import, such as server code reaching
`node:fs`, fail the build, as before.
- A small plugin emits the avatar `.webp` with an absolute
`/_junior/dashboard/assets/...` URL. Rolldown's own asset loader gives a
page-relative URL.
- The manifest plugin walks the entry's static imports and finds the
stylesheet and first-paint fonts in `dist/public`.
- `tsup.client.config.ts` → `tsup.styles.config.ts`. esbuild still
builds `styles.css` and the woff2 fonts, because rolldown CSS bundling
is still experimental (`@tsdown/css`). This build runs first and cleans
`dist/public`.
- Hashes are base36 (`hashCharacters: "base36"`), so a hash never
contains `-` or `_`. The asset-name regexes in `public-assets.ts` now
accept lowercase. The stylesheet regex is now one exported constant.
- `build:client` runs tsdown with `--config-loader tsx`, because Node's
loader can't resolve the extensionless imports in `src/public-assets`.
`tsx` is a new dev dependency; it was already in the lockfile.
- Tests: rolldown writes relative chunk imports (`"./chunks/..."`), so
the chunk regex in two dashboard tests changed.

## Numbers

`build:client` output, br quality 11, first load of `/conversations`
(entry + preloads):

| | main | this PR |
|---|---|---|
| `modulepreload` links | 58 | **21** |
| First-load JS files | 59 | 22 |
| First-load raw | 1,702,443 B | 1,672,714 B |
| First-load br | 474,749 B | **419,596 B (−55 KB, −11.6%)** |
| First-load files < 1 KB | 19 | 5 |
| First-load files < 4 KB | 37 | 12 |
| All files / raw | 184 / 6,263,754 B | 153 / 6,203,573 B |

JS loaded in the browser per route, with mock conversations (files, br):

| Route | main | this PR |
|---|---|---|
| `/conversations` | 59, 474.7 KB | 22, 419.6 KB |
| `/conversations/:id` | 62, 652.3 KB | 29, 606.9 KB |
| `/system` | 65, 581.6 KB | 32, 526.6 KB |
| `/code` | 65, 574.9 KB | 30, 511.9 KB |

Largest files:
- main: chunk 626 KB, wasm 622 KB, client 555 KB, chunk 383 KB, chunk
205 KB.
- this PR: client 1,044 KB, cpp grammar 626 KB, wasm 622 KB, chart 324
KB, vue-vine grammar 190 KB.

The entry is larger because rolldown keeps code that the entry always
loads in the entry, instead of in separate preloaded chunks. The
first-load total goes down. The shiki grammars and the oniguruma wasm
stay lazy.

## Screenshots

Mock conversations. The pages look the same; the only pixel differences
are spinners and the "thinking" shimmer.

| | main | this PR |
|---|---|---|
| Conversations |
![before](https://junior-prod.sentry.dev/public/artifacts/52b0b693-2af5-48b4-b1d3-d1321e269a87.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/a2838f0e-8061-4510-8f24-a797c50c1ea6.png)
|
| Transcript |
![before](https://junior-prod.sentry.dev/public/artifacts/c972d9e3-89ee-4d98-b9cf-65b695573c9c.png)
|
![after](https://junior-prod.sentry.dev/public/artifacts/d6171fd6-dfc8-41df-909f-199171c6cd6a.png)
|

The memory API 404 on the transcript page also happens on main.

## Conflicts

This replaces the client build config. Any open PR that changes
`tsup.client.config.ts` or `build:client` will conflict. The static
assets change (#2757) is already merged, and this branch is based on it.

## Checks

- `pnpm test:e2e:dashboard`: 100/100 passed.
- Dashboard unit tests after a full `pnpm build`: 371/371 passed.
- Dashboard `pnpm typecheck`, root `pnpm lint`, prettier on changed
files: pass.
- `pnpm install --frozen-lockfile`: pass.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A596398f356e0f4652790df29aec95726 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A596398f356e0f4652790df29aec95726/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — d9720808 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