Skip to content

Commit d26faeb

Browse files
yuneng-jiangclaude
andcommitted
[Fix] UI - Usage: Reduce batch size to 3, add loading spinner to fetch banner
- Reduce RENDER_BATCH_SIZE from 5 to 3 for more frequent chart updates - Add LoadingOutlined spinner at the start of all fetching Alert banners Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent f72931a commit d26faeb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

ui/litellm-dashboard/src/components/UsagePage/components/EntityUsage/EntityUsage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
Text,
2323
Title,
2424
} from "@tremor/react";
25-
import { ExportOutlined } from "@ant-design/icons";
25+
import { ExportOutlined, LoadingOutlined } from "@ant-design/icons";
2626
import { Alert, Button } from "antd";
2727
import React, { useMemo, useState } from "react";
2828
import { ActivityMetrics, processActivityData } from "../../../activity_metrics";
@@ -404,6 +404,7 @@ const EntityUsage: React.FC<EntityUsageProps> = ({ accessToken, entityType, enti
404404
message={
405405
<div className="flex items-center justify-between">
406406
<span>
407+
<LoadingOutlined spin className="mr-2" />
407408
Currently fetching spend data: fetched {progress.currentPage} / {progress.totalPages} pages. Charts will
408409
update periodically as data loads. Moving off of this page will stop and reset this. To continue using
409410
the UI in the meantime,{" "}
@@ -439,6 +440,7 @@ const EntityUsage: React.FC<EntityUsageProps> = ({ accessToken, entityType, enti
439440
message={
440441
<div className="flex items-center justify-between">
441442
<span>
443+
<LoadingOutlined spin className="mr-2" />
442444
Currently fetching agent data: fetched {agentProgress.currentPage} / {agentProgress.totalPages} pages.
443445
Charts will update periodically as data loads. Moving off of this page will stop and reset this. To
444446
continue using the UI in the meantime,{" "}

ui/litellm-dashboard/src/components/UsagePage/components/UsagePageView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ const UsagePage: React.FC<UsagePageProps> = ({ teams, organizations }) => {
448448
message={
449449
<div className="flex items-center justify-between">
450450
<span>
451+
<LoadingOutlined spin className="mr-2" />
451452
Currently fetching spend data: fetched {paginatedResult.progress.currentPage} /{" "}
452453
{paginatedResult.progress.totalPages} pages. Charts will update periodically as data loads. Moving
453454
off of this page will stop and reset this. To continue using the UI in the meantime,{" "}

ui/litellm-dashboard/src/components/UsagePage/hooks/usePaginatedDailyActivity.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface PaginationProgress {
1010
const PAGE_FETCH_DELAY_MS = 300;
1111

1212
/** Number of pages to accumulate before flushing to React state (reduces re-renders). */
13-
const RENDER_BATCH_SIZE = 5;
13+
const RENDER_BATCH_SIZE = 3;
1414

1515
/** The metadata fields returned by the daily activity API that should be summed across pages. */
1616
const SUMMABLE_METADATA_KEYS = [
@@ -80,8 +80,8 @@ function sumMetadata(
8080
}
8181

8282
/**
83-
* Hook that auto-paginates daily activity endpoints, updating state after each
84-
* page so charts render progressively. Cancels on unmount, param changes, or
83+
* Hook that auto-paginates daily activity endpoints, updating state in batches
84+
* so charts render progressively. Cancels on unmount, param changes, or
8585
* manual cancel().
8686
*
8787
* The `args` array should contain every argument the fetchFn expects EXCEPT
@@ -204,18 +204,18 @@ export function usePaginatedDailyActivity({
204204
accumulatedMetadata.has_more = page < totalPages;
205205
accumulatedMetadata.page = page;
206206

207-
// Always update progress so the banner stays responsive.
208-
setProgress({ currentPage: page, totalPages });
209-
210-
// Flush accumulated data to React state every RENDER_BATCH_SIZE pages
211-
// (or on the final page) to avoid expensive per-page re-renders.
207+
// Flush accumulated data and progress to React state every
208+
// RENDER_BATCH_SIZE pages (or on the final page) to avoid
209+
// expensive per-page re-renders. Progress and data are updated
210+
// together so the counter never appears to decrement.
212211
const isLastPage = page === totalPages;
213212
const isBatchBoundary = (page - 1) % RENDER_BATCH_SIZE === 0;
214213
if (isLastPage || isBatchBoundary) {
215214
setData({
216215
results: accumulatedResults,
217216
metadata: accumulatedMetadata,
218217
});
218+
setProgress({ currentPage: page, totalPages });
219219
}
220220
}
221221

0 commit comments

Comments
 (0)