From ae6bea1771001e2ad14c6e95e15566c2f6783209 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 22 Jun 2026 22:35:28 +0800 Subject: [PATCH] refactor(gateway): reuse session message count helper --- src/gateway/session-utils.fs.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/gateway/session-utils.fs.ts b/src/gateway/session-utils.fs.ts index 457a68fc61fa..e02be45a2e50 100644 --- a/src/gateway/session-utils.fs.ts +++ b/src/gateway/session-utils.fs.ts @@ -643,22 +643,7 @@ export async function readSessionMessageCountAsync( if (!filePath) { return 0; } - let stat: fs.Stats | null = null; - try { - stat = await fs.promises.stat(filePath); - const cached = getCachedTranscriptMessageCount(filePath, stat); - if (typeof cached === "number") { - return cached; - } - } catch { - // Count from the transcript reader below when stat metadata is unavailable. - } - const index = await readSessionTranscriptIndex(filePath); - const count = index?.entries.length ?? 0; - if (stat) { - setCachedTranscriptMessageCount(filePath, stat, count); - } - return count; + return await readSessionMessageCountFromPathAsync(filePath); } export function readRecentSessionMessagesWithStats(