fix(server): scrolling back through a long thread no longer re-reads the whole thread on every page
BO
16m ago+113+113+012345678901234567890123456789-33-33-01234567890123456789
Fork review only, never merged: this is the diff intended for pingdotgg/t3code (see pingdotgg/t3code#20427).
Scrolling back through a long thread rebuilt the whole thread index on every history page. This keeps the index for the 4 most recently read threads and reuses it while the newest event of the thread and of its fork sources is unchanged.
The revision query moved from ThreadFind.ts to threadRevision.ts. Focused tests: ThreadFind, ProjectionStore, threadHistoryPaging and ThreadSearch, 90 passed.
Summary by cubic
Scrolling back through a long thread no longer rebuilds the whole thread index on every history page, cutting scrollback time from quadratic in thread length (13k items: 72 pages, 2.3–2.7s) to a few cached reads.
- Caches the timeline index for the 4 most recently read threads, invalidated when the newest event of the thread or its fork sources changes.
- Moves the shared revision query from
ThreadFind.tsto the newthreadRevision.tsso both callers use the same check. - Adds a test covering cache reuse and invalidation as the thread and its fork source change.