Repository navigation
perf(dashboard): Preload first-load chunks and load the drawer on demand - #2738
Merged
Merged
Conversation
The client build writes a manifest of its entry and every chunk the entry imports statically. The page shell emits a modulepreload link for each chunk, so the browser fetches them beside the entry instead of after it. The manifest also names the entry, which replaces the newest-mtime scan. The side drawer opens only after a click, so base-ui's drawer now loads with the first open.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
approved these changes
Nov 5, 2026
BYK
enabled auto-merge (squash)
November 5, 2026 12:30
Contributor
|
5 screenshot changes — 5 changed · 0 added · 0 removed Review screenshots in Frameshift |
BYK
added a commit
that referenced
this pull request
Nov 5, 2026
…ets (#2757) 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 #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 | |---|---| |  |  | |  |  | Header avatar at 4× zoom, PNG (left) and WebP (right):  ### 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 <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Afbc3c9e7ecae9c7dc9aa0a400563ce91 --> -- [View Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3Afbc3c9e7ecae9c7dc9aa0a400563ce91/?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 |  |  | | Transcript |  |  | 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
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.
Follow-up to #2734. That PR split the first load into an entry and 54 chunks, but the browser finds the chunks only after it has downloaded and parsed the 690 KB entry. That costs one more round trip on every load that misses the cache.
Preload hints
tsup.client.config.ts) writesdist/client-manifest.json. It lists the entry and every chunk the entry imports statically, taken from the esbuild metafile.<link rel="modulepreload">in<head>for each chunk. The server build embeds the manifest, and checks that every name in it is indist/public.client-*.js.Drawer on demand
Drawerlazy-loadsDrawerContent, so base-ui's drawer (swipe dismiss, virtual keyboard provider) leaves the first load. A drawer opens only after a click.Checked in a browser (mock dashboard on a Conversation page):
chunks/DrawerContent-*.jsonce. Later opens fetch nothing. Escape closes it.Subagent drawer, desktop and mobile:
Checks:
pnpm --filter @sentry/junior-dashboard typecheck,pnpm lintandpnpm file-length:checkpass.dashboard-output.test.ts, which fails the same way on main in this sandbox (nitroIntegrationis not exported by@sentry/[email protected]).e2e/conversations-mobile.spec.ts:615("keeps the message in view while earlier history and late content load") is flaky on main too: 3 of 16 runs failed on main.Not done here:
remark-gfmalso pulls in about 20 KB of markdown serialization code that the dashboard never uses. Removing it needs two direct dependencies.via @BYK.
--
View Session in Sentry