iterate.com / ui

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

Agent pages: the blocks of older history begin on multiples of 8,000 offsets, so the mind answers them from its kept files #19

merged chat-history-aligned was squashed into main as d7e74c9 by jonas, 2026-11-28 17:08 UTC. jonas opened it 2026-11-28 17:08 UTC.

The manager's go, 28 Nov 2026 16:53 UTC, on Jonas's words of 15:29 UTC
("proactively load more events in the past in agent and context views on
dash - atm too many loading breaks when scrolling up").

The mind of iterate.com keeps a finished block of a chat's history as a
file since 17:1x UTC (config commit "Chat history: a finished block is kept
as a file of the mind"): a kept block answers in about 135 to 250 ms, a scan
of the same block in 630 to 1,500 ms. It keeps only a block that begins on
a multiple of 8,000 and is 8,000 long. The stub's first block now ends at
the window and begins on such a multiple; every block below it is a whole one.

Via: /agents/claude/dash-context-feed-threads-mwy308tb-4d1e63
Session: claude 89f0feea-b83f-4937-8b4a-56af6cb8884b on beelink
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Conversation

Nobody has said anything yet.

Sign in to comment or to merge.

Files

2 files changed

M src/agent-kind-view/chat-history.test.ts
@@ -40,25 +40,23 @@
 
   // the first older window: a block of 8,000 offsets that ends where the window ends
   const first = await held.readEvents(49_000, 1000);
-  expect(asked).toEqual(["chat 42000 50000"]);
   expect(first.events).toHaveLength(100);
   expect(first).toMatchObject({ scannedThroughOffset: 50_000, atHead: false, version: 3 });
 
-  // the next windows come from the block: no call
+  // the reader is in the lower half of that block: the whole block below was read ahead, once
+  expect(asked).toEqual(["chat 48000 50000", "chat 40000 48000"]);
+
+  // the next windows come from what is held: no call
   const second = await held.readEvents(47_000, 1000);
   expect(second.events).toHaveLength(300);
-  expect(asked).toEqual(["chat 42000 50000"]);
-
-  // half through the block: the block below is read ahead, once
   const third = await held.readEvents(45_000, 250);
   expect(third.events).toHaveLength(250);
   expect(third.scannedThroughOffset).toBe(47_500);
-  await held.readEvents(43_000, 1000);
-  expect(asked).toEqual(["chat 42000 50000", "chat 34000 42000"]);
-  // below the first block, from what was read ahead
-  const fourth = await held.readEvents(40_000, 1000);
-  expect(fourth.events[0]).toEqual({ offset: 40_010 });
   expect(asked).toHaveLength(2);
+  // in the lower half again: the next whole block
+  await held.readEvents(43_000, 1000);
+  await held.readEvents(41_000, 1000);
+  expect(asked).toEqual(["chat 48000 50000", "chat 40000 48000", "chat 32000 40000"]);
 });
 
 test("a mind with no such read: one refusal, then the context's own read", async () => {
@@ -70,7 +68,7 @@
   await held.readEvents(9000, 1000);
   await held.readEvents(8000, 100);
   await held.readEvents(7000, 100);
-  expect(asked).toEqual(["plain 9000 1000", "chat 100", "plain 8000 100", "plain 7000 100"]);
+  expect(asked).toEqual(["plain 9000 1000", "chat 8000", "plain 8000 100", "plain 7000 100"]);
 });
 
 test("an answer that is not the whole block: the window is read as a page", async () => {
@@ -82,6 +80,6 @@
   });
   await held.readEvents(9000, 1000);
   const page = await held.readEvents(8000, 100);
-  expect(asked).toEqual(["plain 9000 1000", "chat 100 8100", "chat 8000 x100"]);
+  expect(asked).toEqual(["plain 9000 1000", "chat 8000 8100", "chat 8000 x100"]);
   expect(page.events).toHaveLength(5);
 });
M src/agent-kind-view/chat-history.ts
@@ -70,8 +70,12 @@
     // over the block: a window's rest, which the log's reader asks for after a full answer
     if (block && after >= block.hi) return read(after, limit);
     if (!block || after + limit < block.lo) {
-      // the first older page, or a jump far below: a block that ends where this window ends
-      const fresh = await span(Math.max(0, after + limit - BLOCK), after + limit);
+      // the first older page, or a jump far below: a block that ends where this window ends and
+      // begins on a multiple of BLOCK, so that every block below it is a whole one that the mind
+      // keeps (it answers a kept block from a file, with no scan of the log)
+      const top = after + limit;
+      const aligned = Math.floor((top - 1) / BLOCK) * BLOCK;
+      const fresh = await span(Math.max(0, aligned > after ? aligned - BLOCK : aligned), top);
       if (!fresh || after < fresh.lo) return read(after, limit);
       block = fresh;
     } else if (after < block.lo) {