iterate.com / ui

git clone https://git.iterate.com/repos/ui

Virtual log: an older page is asked for while fewer than 8,000 px stand over the view

It was 1,500 px. A page is one read of the mind and takes about a second, so a
reader who went up at a steady pace met the list's top and its "reading older"
line again and again (Jonas, 28 Nov 2026: "proactively load more events in the
past in agent and context views on dash - atm too many loading breaks when
scrolling up"). Each page that lands asks for the next until the buffer stands.
The newer edge of a detached window keeps 1,500 px. The agent chat of the mind's
own kind wraps loadOlder and decides for itself.

Session: claude e7bfeefe-1067-494b-8f63-82177cb1beb9 on beelink

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158EjAGDfCugWqZ9a2JTTgL

Jonas Templestein, 2026-11-28 15:38 UTC · 1fe8f08ed0d59af5f962e92145f302c8e95834ba · parent d1184ed

1 file changed

M src/components/virtual-log/virtual-log.tsx
@@ -79,9 +79,18 @@
 /** The tail's height until it is measured. */
 const TAIL_ESTIMATE = 48;
 
-/** Older pages are asked for when the top of the view is this near the top of what is loaded. */
-const LOAD_OLDER_WITHIN_PX = 1_500;
+/** Newer pages (a detached window of history) are asked for when the view's end is this near the
+ *  end of what is loaded. */
+const LOAD_NEWER_WITHIN_PX = 1_500;
 
+/** READ AHEAD OF THE READER. An older page is asked for while fewer than this many px stand over
+ *  the view: about ten screens, and each page that lands asks for the next until they do. A page
+ *  is one read of the mind and takes about a second, so at 1,500 px a reader who went up at a
+ *  steady pace met the list's top and its "reading older" line again and again (Jonas, 28 Nov
+ *  2026: "proactively load more events in the past […] too many loading breaks when scrolling
+ *  up"). A view that wants its pages later wraps `older.loadOlder` (the agent chat does). */
+export const READ_AHEAD_PX = 8_000;
+
 /** What the list needs to know of a row. Stable across renders (a constant, or `useMemo`): the
  *  virtualizer lays every row out again when these change. */
 export type VirtualLogRowInfo<Row> = {
@@ -702,7 +711,8 @@
   return () => observer.disconnect();
 }
 
-/** Loads older or newer pages when the scroll position stands within `LOAD_OLDER_WITHIN_PX` of an unexhausted edge. */
+/** Asks for an older page while fewer than `READ_AHEAD_PX` stand over the view, and for a newer one
+ *  within `LOAD_NEWER_WITHIN_PX` of the end. After each render: a page that lands asks for the next. */
 function usePageEdges(
   scrollRef: { current: HTMLDivElement | null },
   older: OlderPages,
@@ -710,12 +720,11 @@
 ) {
   useEffect(() => {
     const el = scrollRef.current!;
-    if (!older.loading && !older.exhausted && el.scrollTop < LOAD_OLDER_WITHIN_PX)
-      older.loadOlder();
+    if (!older.loading && !older.exhausted && el.scrollTop < READ_AHEAD_PX) older.loadOlder();
     if (
       !newer.loading &&
       !newer.exhausted &&
-      el.scrollHeight - el.clientHeight - el.scrollTop < LOAD_OLDER_WITHIN_PX
+      el.scrollHeight - el.clientHeight - el.scrollTop < LOAD_NEWER_WITHIN_PX
     )
       newer.loadNewer();
   });