Skip to content

perf(dashboard): Load pages outside the conversation workspace on demand - #2734

Merged
BYK merged 1 commit into
mainfrom
perf/dashboard-route-split
Nov 5, 2026
Merged

BYK merged 1 commit into
mainfrom
perf/dashboard-route-split

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Follow-up to #2731. The browser downloaded every dashboard page, recharts with its d3/redux deps, and Shiki's core before it could paint the conversation workspace. Now each of those loads when it's first needed.

First load = the entry plus every chunk it imports statically (esbuild metafile of tsup.client.config.ts):

first load files raw gzip-9 br-11
main 2 2,448,020 741,377 606,927
this PR 55 1,712,998 550,926 478,718
change −735 KB (−30%) −190 KB (−26%) −128 KB (−21%)

Recharts, d3, redux, immer, the Shiki core and TextMate engine, and all src/client/pages code except the layouts and loading skeletons are no longer on the first load.

Changes

  • Lazy pages: in App.tsx, every route page outside the conversation workspace is now React.lazy: automations, code, locations, people, settings, system, workspaces, plugin and memory pages, and admin. The conversation workspace and review desk stay eager. Layouts and loading skeletons stay eager, so route-loading states still show at once. TracedRoutes takes a fallback and wraps the matched route in Suspense.
  • pluginUserPagePath moved to pages/user/pluginUserPageRoutes.ts. ProfileMenu and primaryNav imported the helper from PluginUserPage.tsx, and that pulled the memory page and recharts into the entry. This uses the same pattern as codeRepositoryRoutes.ts.
  • Shiki loads with the first code block. The highlighter moved to code-highlighter.ts, and HighlightedCode imports it inside its existing async query. Before the first highlight it shows the same plain HighlightedCodeFallback that it already showed.

esbuild lifts every shared chunk into a direct import of the entry, so all 55 first-load files are requested together right after the entry. Asset requests are counted in the QA below.

Not in this PR

  • modulepreload hints in the HTML shell. They would let those chunks download in parallel with the entry, but the shell would need a build manifest of the entry's imports.
  • emojibase shortcodes (47 KB). The conversation list needs them to render text on first paint.
  • @base-ui/react (208 KB) is already imported per component and tree-shaken.

QA

Mock dashboard (JUNIOR_DASHBOARD_MOCK_CONVERSATIONS=true pnpm dev) in Playwright:

  • Home loads 55 asset files, none of them page or chart code.
  • Moving from home to System inside the app fetches 6 more chunks. System → People fetches 5 more.
  • SQL in the conversation still highlights.
  • No page errors and no 4xx responses.

Automations and Settings redirect to home with dashboard auth off, the same as main, so they're covered by e2e instead.

Home Conversation (code highlighted)
home conversation
System (in-app navigation, charts from a lazy chunk) People
system people

home on mobile

Checks

  • Dashboard typecheck and lint pass, and so do file-length:check and dashboard-style:check.
  • Dashboard e2e: 95/95 passed, run locally with the CI env unset.
  • Dashboard unit tests: 368/369. The one failure is dashboard-output.test.ts, caused by the stale @sentry/server-utils@11.6.0 (nitroIntegration missing) in this sandbox. It fails the same way on main.

via @BYK.

--

View Session in Sentry

@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 11:13am UTC

Request Review

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Review screenshots in Frameshift

Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Subagents · Desktop
Conversation Subagents · Desktop
Changed
Locations · Desktop
Locations · Desktop
Changed
Settings Mcp · Desktop
Settings Mcp · Desktop
Changed

@BYK
BYK merged commit 4d9587f into main Nov 5, 2026
43 checks passed
@BYK
BYK deleted the perf/dashboard-route-split branch November 5, 2026 11:58
BYK pushed a commit that referenced this pull request Nov 5, 2026
…and (#2738)

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**
- The client build (`tsup.client.config.ts`) writes
`dist/client-manifest.json`. It lists the entry and every chunk the
entry imports statically, taken from the esbuild metafile.
- The page shell adds a `<link rel="modulepreload">` in `<head>` for
each chunk. The server build embeds the manifest, and checks that every
name in it is in `dist/public`.
- The manifest also names the entry. This replaces the scan for the
newest `client-*.js`.

**Drawer on demand**
- `Drawer` lazy-loads `DrawerContent`, so base-ui's drawer (swipe
dismiss, virtual keyboard provider) leaves the first load. A drawer
opens only after a click.

| first load | files | raw | br-11 |
|---|---|---|---|
| main | 55 | 1,749,633 | 488,353 |
| this PR | 59 | 1,710,419 | 478,821 |

**Checked in a browser** (mock dashboard on a Conversation page):
- All 59 first-load files were fetched once each, with no duplicate
fetches. Each chunk has a preload link.
- The chunk requests started at 24–31 ms, before the entry request at 51
ms. Before this change they could start only after the entry had loaded.
- On the first open, the drawer fetches `chunks/DrawerContent-*.js`
once. Later opens fetch nothing. Escape closes it.

Subagent drawer, desktop and mobile:

<img
src="https://junior-prod.sentry.dev/public/artifacts/90eca645-5d78-48ac-8d5d-fefd8f2cbc6c.png"
width="640" alt="Subagent transcript drawer on desktop"> <img
src="https://junior-prod.sentry.dev/public/artifacts/f6aa51f8-46c4-4b6b-bc31-75c90fcceca1.png"
width="200" alt="Subagent transcript drawer on mobile">

**Checks:**
- `pnpm --filter @sentry/junior-dashboard typecheck`, `pnpm lint` and
`pnpm file-length:check` pass.
- Dashboard e2e: 96/96.
- Dashboard unit tests: 368/369. The one failure is
`dashboard-output.test.ts`, which fails the same way on main in this
sandbox (`nitroIntegration` is not exported by
`@sentry/server-utils@11.6.0`).
- `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:**
- Markdown (149 KB raw) and the Sentry SDK (146 KB) are the biggest
remaining parts of the first load. The transcript and pageload tracing
need both on first paint.
- `remark-gfm` also pulls in about 20 KB of markdown serialization code
that the dashboard never uses. Removing it needs two direct
dependencies.

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

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A17b6d7f555623680001f2a90 -->

--

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

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

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
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 |
|---|---|
| ![before
transcript](https://junior-prod.sentry.dev/public/artifacts/b4947b78-03e1-436b-a63f-8b927028f578.png)
| ![after
transcript](https://junior-prod.sentry.dev/public/artifacts/0c11e4d0-ca99-440a-aa2d-268baac25b4d.png)
|
| ![before
conversations](https://junior-prod.sentry.dev/public/artifacts/7c910c02-c24f-4ce1-8b63-0c3585b7d3af.png)
| ![after
conversations](https://junior-prod.sentry.dev/public/artifacts/e9b34c90-cb15-47ea-ab11-2a7ffa9b82b0.png)
|

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

![avatar
compare](https://junior-prod.sentry.dev/public/artifacts/2b9a421c-4cec-4214-a2f4-e56151d3d0e4.png)

### 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/server-utils@11.6.0`. 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 <126780+BYK@users.noreply.github.com>

This branch was successfully deployed

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