refactor(gateway): reuse session message count helper

This commit is contained in:
Vincent Koc
2026-06-22 22:35:28 +08:00
parent f7d6a059a4
commit ae6bea1771
+1 -16
View File
@@ -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(