iterate.com / ui

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

Virtual log: a chat that is shorter than its view stands on the list's end (#12)

A chat that is shorter than its view stands on the list's end (`shortLogAt="end"`, used by the chat's two lists). A page of older rows that lands above it then moves no row.

Why: /agents/main opened with 6 rows in a 762 px view on 28 Nov 2026 07:40 UTC, and the reader's first touch moved every row by 482 px (measured with perf/scroll-check.mjs of /repos/chat). Card: tasks/make-the-dash-scroll-and-render-smoothly-on-large-logs-like.md.

Checks: pnpm check passes (1,264 tests).

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0158EjAGDfCugWqZ9a2JTTgL

Iterate-Run: /@1640600

jonas, 2026-11-28 07:42 UTC · cdd7ad53587302fb184a107b80773982b475f09c · parent 3223457

5 files changed

M src/components/agent-chat/agent-feed-list.tsx
@@ -106,6 +106,7 @@
     <VirtualLog
       rows={items}
       rowInfo={CHAT_ROWS}
+      shortLogAt="end"
       renderRow={renderRow}
       tail={
         state.live || (dots && last) || after ? (
M src/components/agent-chat/chat-parts.tsx
@@ -53,6 +53,7 @@
     <VirtualLog
       rows={rows}
       rowInfo={ROWS}
+      shortLogAt="end"
       renderRow={render}
       older={older}
       empty={older.failed ? null : older.exhausted ? empty : <ChatReading />}
M src/components/virtual-log/AGENTS.md
@@ -31,6 +31,9 @@
   same wait.
 - The loading line stands where the first row will stand: under the list's `paddingStart`, with a
   row's own padding (`ChatReading`). Nothing moves when the rows come.
+- A chat's log that is shorter than the view stands on the list's end (`shortLogAt="end"`): an
+  older page that lands above it then moves no row. At the start, each page pushes the rows down
+  and no scroll can make up for it (the Dash's feed, 28 Nov 2026: 482 px at the first touch).
 - `older` stops on an error: a view passes `OLDER_EXHAUSTED` once its context has one. If not, the
   list asks for the failed page again each time the read ends. A kind's frame passes `OLDER_FAILED`:
   the same stop, and `Feed` then shows neither a loading state nor its words for an empty log.
M src/components/virtual-log/virtual-log-scroll.test.tsx
@@ -112,7 +112,10 @@
     60,
   );
   const scroller = view.container.querySelector<HTMLDivElement>('[data-slot="virtual-log"]')!;
-  Object.defineProperty(scroller, "scrollHeight", { configurable: true, get: () => 2_400 });
+  Object.defineProperty(scroller, "scrollHeight", {
+    configurable: true,
+    get: () => 2_400,
+  });
   // Leave the end and stand at scrollTop 0.
   act(() => {
     scroller.dispatchEvent(new WheelEvent("wheel", { deltaY: -120, bubbles: true }));
@@ -162,7 +165,10 @@
     26,
   );
   const scroller = view.container.querySelector<HTMLDivElement>('[data-slot="virtual-log"]')!;
-  Object.defineProperty(scroller, "scrollHeight", { configurable: true, get: () => 4_000 });
+  Object.defineProperty(scroller, "scrollHeight", {
+    configurable: true,
+    get: () => 4_000,
+  });
   act(() => {
     scroller.dispatchEvent(new WheelEvent("wheel", { deltaY: -120, bubbles: true }));
     scroller.scrollTop = 0;
@@ -189,4 +195,22 @@
     />,
   );
   expect(scroller.scrollTop).toBe(1_300);
+});
+
+test("a chat's short log stands on the list's end, and another view's on its start", () => {
+  const rows: TestRow[] = [{ id: "r-0", offset: 1, estimate: 40 }];
+  const column = (shortLogAt?: "end") => {
+    using view = mount(
+      <VirtualLog
+        rows={rows}
+        rowInfo={ROW_INFO}
+        renderRow={(row) => <div>{row.id}</div>}
+        label="Short"
+        shortLogAt={shortLogAt}
+      />,
+    );
+    return view.container.querySelector<HTMLElement>('[role="log"]')!.className;
+  };
+  expect(column("end")).toContain("justify-end");
+  expect(column()).not.toContain("justify-end");
 });
M src/components/virtual-log/virtual-log.tsx
@@ -115,6 +115,7 @@
   paddingStart = 0,
   paddingEnd = 0,
   columnClassName,
+  shortLogAt = "start",
   className,
 }: {
   rows: readonly Row[];
@@ -153,6 +154,10 @@
   paddingEnd?: number;
   /** The column the rows sit in, inside the scroller, so its scrollbar stays at the edge. */
   columnClassName?: string;
+  /** Where a log that is shorter than the view stands. `"end"` is for a chat: its rows stand on the
+   *  list's end, so a page of older rows that lands above them moves nothing that the reader sees.
+   *  At `"start"` each such page pushes the rows down, and no scroll can make up for it. */
+  shortLogAt?: "start" | "end";
   className?: string;
 }) {
   const scrollRef = useRef<HTMLDivElement>(null);
@@ -253,7 +258,12 @@
       <div
         role={label ? "log" : undefined}
         aria-label={label}
-        className={cn("shrink-0 grow", columnClassName)}
+        data-short-log-at={shortLogAt}
+        className={cn(
+          "shrink-0 grow",
+          shortLogAt === "end" && count > 0 && "flex flex-col justify-end",
+          columnClassName,
+        )}
       >
         {count === 0 ? (
           empty
@@ -353,7 +363,13 @@
    *  tail appends and shifts/changes on any prepend, even when a floating day header keeps index 0. */
   headIndex: number;
   headKey: string | null;
-  items: Array<{ key: string; index: number; start: number; end: number; hasOffset: boolean }>;
+  items: Array<{
+    key: string;
+    index: number;
+    start: number;
+    end: number;
+    hasOffset: boolean;
+  }>;
 };
 
 /** Configures TanStack Virtual for a log with pixel-based overscan, live-`scrollTop` compensation