From 9ea7758abb510f5f07a7006236eb4f703c82e8c6 Mon Sep 17 00:00:00 2001 From: nntrivi2001 Date: Mon, 26 Oct 2026 08:35:35 +0700 Subject: [PATCH] fix(transcript): a non-Claude page honours its limit again (#86) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `carry?.drop(messages.shift())` skips its argument when `carry` is null — optional chaining short-circuits the whole call — so a Codex, omp, Cursor or Antigravity page never shifted its sliding window and returned the whole journal (codex-transcript.test.js: 8 messages for ?limit=2). Shift first, then hand the dropped message to the carry. --- server/routes/sessions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/routes/sessions.js b/server/routes/sessions.js index 7d17f68d..0993c3c1 100644 --- a/server/routes/sessions.js +++ b/server/routes/sessions.js @@ -1235,7 +1235,8 @@ router.get("/:id/transcript", async (req, res) => { messages.push(message); // Sliding window: only keep the last `limit` messages if (messages.length > limit) { - carry?.drop(messages.shift()); + const dropped = messages.shift(); + carry?.drop(dropped); } } if (total > limit) hasMore = true; @@ -1286,7 +1287,8 @@ router.get("/:id/transcript", async (req, res) => { messages.push(message); // Sliding window: only keep the last `limit` messages in memory if (messages.length > limit) { - carry?.drop(messages.shift()); + const dropped = messages.shift(); + carry?.drop(dropped); } } // If we shifted any messages out, there are more