(sidebar): every projects-changed rebuilds the whole sidebar, ~0.6 s with 900 sessions #543
Copy link
Copy link
Open
Description
Found by the rendering audit that followed #541. Measured on main 3a40242 in an isolated instance with a synthetic cache of 30 projects × 30 sessions (39,510 sidebar nodes).
renderProjects (public/sidebar.js:609-1104) rebuilds the whole sidebar on every projects-changed, even when nothing changed:
- the path is
onProjectsChanged(app.js:1733-1746, 900 ms debounce) →loadProjects(app.js:1182); - each call builds a new sidebar, runs morphdom over it, then
rebindSidebarEvents; buildSessionItem(sidebar.js:1644-1790) creates about 15 SVG buttons per row throughinnerHTML.
Cost: 454 ms cold, 601–728 ms in steady state with identical data.
| Function | Self time |
|---|---|
processProjectSessions |
313 ms |
| morphdom | 310 ms |
buildSessionItem |
267 ms |
morphAttrs |
128 ms |
Style and layout afterwards cost 0–3 ms: the whole cost is JS, about 0.7 ms per session.
Frequency (inferred from the code, not observed with a real CLI): every JSONL write of a live session; the main-side watcher throttles to 1.5 s. That is about once a second while any session writes and the Sessions tab is shown.
Not measured: JB's real cache.
Fix, in order of payoff:
- Skip
renderProjectswhen the projects payload equals the previous one. - Clone a row
<template>instead of 15 SVGinnerHTMLwrites. - Re-render only the project groups whose sessions changed.
Metadata
Metadata
Assignees
Labels
No labels
Activity
devsuitup commentedon Oct 28, 2026
Step 1 (skip identical payload) anytime; the row-template step after #819/#821 add their icon slots.
(sidebar): skip the rebuild when nothing it renders changed (#543) (#867