fix(transcript): a non-Claude page honours its limit again (#86)

`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.
This commit is contained in:
2026-10-26 08:35:35 +07:00
parent f51a6a895e
commit 9ea7758abb
+4 -2
View File
@@ -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