Skip to content

perf(dashboard): split heavy vendor libs into separate chunks#1587

Merged
esengine merged 1 commit into
mainfrom
perf/dashboard-vendor-code-split
May 23, 2026
Merged

perf(dashboard): split heavy vendor libs into separate chunks#1587
esengine merged 1 commit into
mainfrom
perf/dashboard-vendor-code-split

Conversation

@esengine

@esengine esengine commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

Web dashboard ships as a 943 KB monolithic app.js after #1418. PR description called the bundle size out as known low-priority debt; user feedback on the deployed dashboard says perf is bad enough to act on it.

Configure Vite manualChunks to peel heavy vendor libs out of the entry. Total bytes don't change but the browser fetches chunks in parallel and reuses them across deploys when only app code moves.

Before After (entry)
app.js (entry) 942.61 KB (gzip 292 KB) 223.76 KB (gzip 75 KB)
vendor-react.js 192.84 KB (gzip 60 KB)
vendor-katex.js 258.26 KB (gzip 78 KB)
vendor-markdown.js 171.91 KB (gzip 52 KB)
vendor-prism.js 86.04 KB (gzip 27 KB)
vendor-icons.js 8.07 KB (gzip 2 KB)

Entry size dropped 76%, gzip 74%. Real TTI win comes from parallel fetch + per-chunk parse + cross-deploy caching (vendor chunks stay cached when only app code changes).

Token-gated chunks

Browsers strip query strings when resolving relative ESM imports, so a chunk-to-chunk reference like from "./vendor-react.js" would 401 against the token-gated /assets/* route. serveAsset now rewrites every relative .js import in app.js and vendor-*.js to carry the live token before sending the body — same shape as the existing index.html templating, just applied to JS bodies.

Future work (not in this PR)

  • React.lazy on the Markdown surface so the markdown + katex chunks only download when first MD/math content appears. Bigger TTI win, separate PR.
  • react-virtuoso virtualization for the thread (it's already a declared dep). Separate PR.

Test plan

  • Two new dashboard-smoke.test.ts cases verify the token is injected into both app.js→vendor imports and chunk→chunk imports
  • npm --prefix dashboard run build clean, no circular chunks
  • Full npm run verify clean (3526+ tests pass)

Builds went from a 943 KB monolithic `app.js` to a 224 KB entry plus
five lazy-cacheable vendor chunks (react, markdown, katex, prism,
icons). Total bytes are unchanged but the browser can fetch chunks
in parallel and reuse them across deploys when only app code moves.

Browsers strip query strings when resolving relative ESM imports, so
chunk-to-chunk references like `from "./vendor-react.js"` would 401
against the token-gated /assets/* route. `serveAsset` now rewrites
every relative `.js` import to carry the live token before sending
the body — same shape as the existing index.html templating, just
applied to JS bodies.

Before:  app.js               942.61 kB │ gzip: 292.58 kB
After:   app.js               223.76 kB │ gzip:  74.75 kB
         vendor-react.js      192.84 kB │ gzip:  60.17 kB
         vendor-katex.js      258.26 kB │ gzip:  77.53 kB
         vendor-markdown.js   171.91 kB │ gzip:  52.18 kB
         vendor-prism.js       86.04 kB │ gzip:  26.77 kB
         vendor-icons.js        8.07 kB │ gzip:   1.98 kB
@esengine esengine merged commit cb0851c into main May 23, 2026
4 checks passed
@esengine esengine deleted the perf/dashboard-vendor-code-split branch May 23, 2026 04:10
esengine pushed a commit that referenced this pull request May 24, 2026
…moved, persisted usage stats, plan dispatch gate

Headline themes:
- Desktop: bundle the CLI-hosted React dashboard, retire Tauri+Preact duplicate (#1418)
- Config: drop preset abstraction; flash/pro are direct model selections (#1657, #1630)
- Stats: persist cumulative usage to session meta + auto-restore on startup (#1667, #1680, #1643, #1628)
- Plans: editMode="plan" enforced at the ToolRegistry dispatch gate (#1681); step advance fix (#1629)
- Context: fold once at turn start, drop pre-flight + byte-ceiling (#1642, #1646); collapsible compacted card (#1649)
- Subagents: per-skill flash/pro override + Settings UI (#1632)
- Desktop polish: sidebar drag-resize (#1688), responsive collapse (#1585), copy/edit overlay + msg-history nav (#1645), Esc closes modal not turn (#1685), QQ tab isolation (#1672), DiffCard for edits (#1662), theme-aware highlighting (#1655), system events toggle (#1654/#1650), macOS TCC inheritance (#1614), dashboard.enabled (#1612)
- Dashboard polish: persistent session URL (#1586, #1589, #1599), theme-aware highlighting (#1664), IME confirm-enter guard (#1689), code-fence lang fix (#1677), vendor chunk split (#1587), markdown table h-scroll (#1562)
- TUI: Alt+S input stash/recall; static history isolated from input rerenders (#1635); legacy mouse drop (#1637, #1648); multi-edit gated in review (#1647)
- Diff: SplitDiff column border holds under CJK (#1686)
- MCP: workspace roots passed to servers (#1625); codeCommand honors mcpServers (#1603)
- Config plumbing: (baseUrl, apiKey) resolved as a tuple (#1658); stale model id self-heal (#1663)

See CHANGELOG for the full list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant