Repository navigation
perf(sidebar): mount only the session rows near the viewport - #15090
Conversation
|
Intent: keep the Sessions sidebar responsive with hundreds of sessions by mounting only the rows near each lane's viewport, while every feature that walks rows in DOM order keeps working. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify a drag gesture begun on a still-visible stub (in the post-jump gap) fails gracefully — stubs swallow mousedown, so the lift silently no-ops until the row mounts. [DESIGN-REVIEWED] dc57565 Description read[DESCRIPTION-READ] 00b8b91e087cf8cb6ff2360ac8d58a110a6d2fd9c805ce64c2b78eff59e2632a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify stub activation (click/focus replay after mount) on a non-Chromium engine — manual verification ran Playwright Chromium only, and the mousedown-prevent/replay sequence is engine-sensitive. What this change shipsInventory (10 items) — 9 justifiedIntent: keep the Sessions sidebar responsive with hundreds of sessions — a FIX (perf defect, issue #15088 with linked measurements; four new wiring tests fail on base). The existing virtualizer (react-virtuoso,
[FIRST-PRINCIPLES-REVIEWED] dc57565 Description read[DESCRIPTION-READ] f8366a2f23bb802a695a6300237da71533f1702f83d614156abef9eb347393e5 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No blind reader has cold-read the new stub rows; all states are shown in committed screenshots, but comprehension of the placeholder frame is unverified in this fork lane. Watch
Suggestions
[UX-REVIEWED] dc57565 Description read[DESCRIPTION-READ] 064785a73dbb974ee8e20d8b154704b6e579fd765237dfaaaf9bb3790410d72b That sha256 names everything this verdict read: the PR description, plus the 8 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed |
bad5902 to
1b05dad
Compare
|
|
|
|
|
|
|
1b05dad to
4989336
Compare
|
|
|
|
|
|
|
|
|
@kirodotdev maintainers: PR Readiness on e29b33a is stuck on its 02:05 UTC evaluation ("waiting on Opus 5 Review (not started)"), but the Opus 5 Review check-run completed with success at 02:15 UTC and every other check on this head is green; every review item has a disposition above. The self-heal sweep has not recomputed it in 35 minutes, and a fork contributor cannot dispatch the workflow. Could one of you recompute it? |
Every session row carries a query observer, several store subscriptions, a dnd-kit draggable and droppable, a Framer node and two Radix menus, so the sidebar's cost grew with the number of mounted rows. With a few hundred sessions a switch, a search keystroke and even an idle tick turned into multi-hundred-millisecond long tasks. Rows far from their lane's viewport now render as a stub of the same height that keeps the row's data-session-row, scope and container attributes, and mount the real row when an IntersectionObserver rooted on the lane scroller brings them within 1200px. The active, renaming, dragged and revealed rows never stub; a row holding focus or an open menu is not unmounted. Without IntersectionObserver rows render exactly as before, with no wrapper.
e29b33a to
dc57565
Compare
|
Rebased onto main after #15094 split ChatSidebar into pages/chat-sidebar/*: the same row-windowing wiring re-applied, no behaviour change; windowing and sidebar tests, tsc and a Chromium check re-run green. |
|
@kirodotdev maintainers: PR Readiness on dc57565 is stuck on its 05:50 UTC evaluation ("waiting on Opus 5 Review (not started)"), but the Opus 5 Review check-run completed with success after it and every other check on this head is green; every review item has a disposition above. The self-heal sweep has not recomputed it in 40 minutes, and a fork contributor cannot dispatch the workflow. Could one of you recompute it? |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed on behalf of the maintainers (sweep 2026-09-30): readiness passed, required checks green on dc57565, no blocking review threads, security posture unchanged. Approving and merging.
Problem / Motivation
Goal: the Sessions sidebar stays responsive with hundreds of sessions.
With a few hundred sessions, switching sessions, typing in the sidebar search and even leaving the dashboard idle produce long main-thread tasks. Issue #15088 has the measurements: five session switches cost 18 s of long tasks at 600 rows against 2.4 s at 50.
Why it matters
Heavy users keep hundreds of live sessions, and the sidebar is on screen for every chat. Every switch, keystroke and status tick pays a cost that grows with the whole list, so the dashboard gets slower the more it is used.
Not a goal
What changed (motivation → approach → change)
The sidebar's cost follows the number of mounted rows, not the visible ones. Rendering only the first 40 rows of a 600-session list brought every measurement back to the 50-row level.
content-visibility: autoalready skips paint for off-screen rows, but not their React, subscription, dnd-kit and Framer work.A row far from its lane's viewport now renders as a stub instead. The stub has the same height, shows the title on the row's second line in the row's own text color (the session key for an untitled session, as the real row does), and carries the same
data-slot-key,data-session-row, scope and container attributes, so keyboard navigation, digit shortcuts, hover hold, scroll memory, reveal and anything else that looks rows up still find every row in order. One IntersectionObserver per lane scroller, with a 1200px margin, mounts the real row before it scrolls into view and stubs it again once it is that far out. A general virtualizer was rejected because it needs one flat item list and takes over the DOM, which the folder tree and those features depend on.pages/chat/sessionRowWindow.tsxWindowedSessionRowrenders the row unchanged with no wrapper when there is no observerrenderSessionRowinpages/ChatSidebar.tsxpages/ChatSidebar.tsxA row that holds focus or an open menu is not stubbed while it does, and is stubbed once the focus leaves or the menu closes if it is still out of the window, and a zero-height report from a row inside a collapsed folder leaves the row as it was. A stub is a Tab stop like the real row. Focusing, clicking, middle-clicking, right-clicking or pressing Enter or Space on a stub mounts the real row and hands that focus or event to it, so the real row's own handlers, including its context menu, decide what happens. The unmeasured stub height is 76px, the size a never-painted
.session-rowalready takes, so the lane's scroll height is unchanged.docs/feature-map/README.mdlists the new file under Sessions.Backwards compatibility
Compatible: no API, setting or stored state changes. Without IntersectionObserver the sidebar renders exactly as on main.
Tests
src/test/sessionRowWindow.test.tsx: no observer means no wrapper; one observer rooted on the lane; stubs keep row identity (data-slot-key,data-session-row, title) and DOM order and mount when near; stub height is the last real height, and a zero-height "not intersecting" report changes nothing; each root mounts its own first rows, including under StrictMode;keepMounted, focus and an open menu keep the row live; focusing a stub moves focus onto the mounted row; the stub is a Tab stop; a click, a modified click, a middle-click, a right-click and Enter/Space on a stub reach the real row once, including the real press-then-click sequence where the press must not swap the stub out; a late root does not remount rows; a row held by focus or an open menu stubs once released.src/test/ChatSidebar.rowWindow.test.tsxalso pins that a stub carries the samedata-session-*attributes, role and tab stop as a real row, inside a[data-slot-key]box with the same key.src/test/ChatSidebar.rowWindow.test.tsx: through the real sidebar, rows past the window are stubs in order, the lane scroller is the observer root, the active row stays mounted past the window, and a row the observer reports near mounts. All four fail on main.integration/setup.tsmeans they run with the window active.Manual verification
Production build, stubbed API, Playwright Chromium, 4x CPU throttle, total long-task time:
Scrolling now pays for the rows it brings in; no single task exceeded 71 ms. After a jump past the window, stubs stay in view for 200 to 310 ms at 4x throttle and 330 to 580 ms at 6x before the real rows replace them. A click on a stub in that gap opens its session in Chromium, and a right-click opens its session menu, the same as on a mounted row. A drag from the last row that autoscrolls up past about 100 stubbed rows still drops onto a folder header: stubs are never drop targets, and folder headers and the root group are never stubbed. With 600 sessions in 20 folders, five switches went from 23.5 s to 3.9 s. On a 400-session lane, scroll height and the row at a given scroll position match main (30287px, row 163 at the same offset after settling). DOM nodes at 600 rows fell from 15,803 to 2,593.
Screenshots / video
At rest the lane looks the same. Both shots show the same 400-session list at the same scroll position, 60% down the lane.
Before (main):
After (this PR):
A stub is visible only in the frame after a jump the window has not caught up with, such as dragging the scrollbar thumb to the end. The first shot is that frame, taken with the observer held back so it stays on screen. The second is the same position once the observer runs, and every row is real again.
Drag across the stubbed rows
A session dragged from the bottom of the lane autoscrolls up through about 100 stubbed rows and lands on the Project A folder header. The folder move request (
PATCH /api/chat/slots/chat-395/folderwithfolder_id: f0) was sent.Related Issues
Fixes #15088
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)