Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

refactor(ui): drop the per-user usage page clamp now handled by the shared DataTable

ryan-crabbe-berri3bdc5ecd0e27
diff --git a/ui/litellm-dashboard/src/components/per_user_usage.test.tsx b/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
index d5c2216dfd5..30b3059b7d2 100644
--- a/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
+++ b/ui/litellm-dashboard/src/components/per_user_usage.test.tsx
@@ -178,6 +178,30 @@ describe("PerUserUsage", () => {
expect(screen.getByTestId("pagination-next")).toBeDisabled();
});
+ it("goes back to the first page when the data disappears under the current page", async () => {
+ const user = userEvent.setup();
+ render(<PerUserUsage {...defaultProps} />);
+ await screen.findByText("user-1");
+ await user.click(screen.getByTestId("pagination-next"));
+ await screen.findByText("user-51");
+
+ serveUsers(0);
+ await user.click(screen.getByTestId("pagination-next"));
+
+ await waitFor(() => {
+ expect(lastCall()).toEqual(["test-token", 1, 50, undefined]);
+ });
+ expect(mockPerUserAnalyticsCall.mock.calls.slice(-2)).toEqual([
+ ["test-token", 3, 50, undefined],
+ ["test-token", 1, 50, undefined],
+ ]);
+ expect(screen.getByText("No per-user usage data")).toBeInTheDocument();
+ expect(screen.getByTestId("pagination-range")).toHaveTextContent("No results");
+ expect(screen.getByText("Page 1 of 1")).toBeInTheDocument();
+ expect(screen.getByTestId("pagination-first")).toBeDisabled();
+ expect(screen.getByTestId("pagination-prev")).toBeDisabled();
+ });
+
it("refetches with the selected page size and goes back to the first page", async () => {
const user = userEvent.setup();
render(<PerUserUsage {...defaultProps} />);
diff --git a/ui/litellm-dashboard/src/components/per_user_usage.tsx b/ui/litellm-dashboard/src/components/per_user_usage.tsx
index 57b1a926ec0..f600cd6c45d 100644
--- a/ui/litellm-dashboard/src/components/per_user_usage.tsx
+++ b/ui/litellm-dashboard/src/components/per_user_usage.tsx
@@ -62,9 +62,6 @@ const PerUserUsage: React.FC<PerUserUsageProps> = ({ accessToken, selectedTags,
.then((response) => {
if (stale) return;
setPerUserData(response);
- if (response.total_pages > 0 && pagination.pageIndex >= response.total_pages) {
- setPagination({ ...pagination, pageIndex: response.total_pages - 1 });
- }
})
.catch((error) => console.error("Failed to fetch per-user data:", error));