fix(ui): derive session total from accumulated rows when backend omits it

Compute the session total after all pages are fetched, falling back to the
accumulated row count rather than the first page's. Guards the truncation
note against a backend response that omits total but spans multiple pages.
This commit is contained in:
Ceder 2026-06-05 20:18:07 +02:00
parent 7ee4833764
commit 64340226c5

View file

@ -129,7 +129,6 @@ export function LogDetailsDrawer({
// than one page of logs are shown in full (capped for safety).
const firstPage = await sessionSpendLogsCall(accessToken, sessionId, 1, SESSION_PAGE_SIZE);
let rows: LogEntry[] = firstPage.data || firstPage || [];
const total: number = firstPage.total ?? rows.length;
const pagesToFetch = Math.min(firstPage.total_pages ?? 1, MAX_SESSION_PAGES);
if (pagesToFetch > 1) {
@ -149,6 +148,10 @@ export function LogDetailsDrawer({
}
}
// Fall back to the accumulated row count (not just the first page) when the
// backend omits total, so the truncation note reflects what was fetched.
const total: number = firstPage.total ?? rows.length;
const logs = rows
.map((row) => ({
...row,