From 9e1000d17aeb61179a3b417dff7093d3d1926b0f Mon Sep 17 00:00:00 2001 From: marwanakeel Date: Mon, 16 Feb 2026 14:36:39 +0400 Subject: [PATCH] fix(ui): fetch all session logs pages instead of only first 50 The session logs drawer was only showing 50 results because sessionSpendLogsCall didn't pass pagination params to the backend endpoint, which defaults to page_size=50. Now fetches all pages (using page_size=100, the backend max) and merges them so the session sidebar displays every log entry. Co-Authored-By: Claude Opus 4.6 --- .../src/components/networking.tsx | 61 +++++++++++++------ 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 885a62fab54..390f04af627 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -7020,31 +7020,56 @@ export const teamPermissionsUpdateCall = async (accessToken: string, teamId: str }; /** - * Get all spend logs for a particular session + * Get all spend logs for a particular session. + * Fetches every page (page_size=100, the backend max) and merges + * them into a single response so the session drawer shows all logs. */ export const sessionSpendLogsCall = async (accessToken: string, session_id: string) => { + const pageSize = 100; // backend maximum + let currentPage = 1; + let allData: any[] = []; + let total = 0; + try { - let url = proxyBaseUrl - ? `${proxyBaseUrl}/spend/logs/session/ui?session_id=${encodeURIComponent(session_id)}` - : `/spend/logs/session/ui?session_id=${encodeURIComponent(session_id)}`; + while (true) { + const baseUrl = proxyBaseUrl + ? `${proxyBaseUrl}/spend/logs/session/ui` + : `/spend/logs/session/ui`; + const url = `${baseUrl}?session_id=${encodeURIComponent(session_id)}&page=${currentPage}&page_size=${pageSize}`; - const response = await fetch(url, { - method: "GET", - headers: { - [globalLitellmHeaderName]: `Bearer ${accessToken}`, - "Content-Type": "application/json", - }, - }); + const response = await fetch(url, { + method: "GET", + headers: { + [globalLitellmHeaderName]: `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + }); - if (!response.ok) { - const errorData = await response.json(); - const errorMessage = deriveErrorMessage(errorData); - handleError(errorMessage); - throw new Error(errorMessage); + if (!response.ok) { + const errorData = await response.json(); + const errorMessage = deriveErrorMessage(errorData); + handleError(errorMessage); + throw new Error(errorMessage); + } + + const data = await response.json(); + const pageData = data.data || []; + allData = allData.concat(pageData); + total = data.total || allData.length; + + if (currentPage >= (data.total_pages || 1)) { + break; + } + currentPage++; } - const data = await response.json(); - return data; + return { + data: allData, + total: total, + page: 1, + page_size: total, + total_pages: 1, + }; } catch (error) { console.error("Failed to fetch session logs:", error); throw error;