From b341a223399874314f151c0667b50b4b4255ee02 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Thu, 13 Aug 2026 15:57:03 -0700 Subject: [PATCH] fix(ui): keep the guardrails metric cards wrapping at narrow widths The antd Row and Col the migration replaced never squeezed the summary cards below their content width; they wrapped onto a second line instead. Measured on a live dashboard, antd laid out five per row at 1280 and 1024, then four plus one at 900 and three plus two at 820, never narrower than about 126px. A fixed grid-cols-5 kept all five on one line and compressed them to 86px at 820, so the metric values overflowed their cards. An auto-fit track with a 7rem minimum reproduces antd's wrap points and card widths exactly at all four measured viewports, and is identical at 1280, so the route's visual baseline is unchanged. The added test fails against grid-cols-5 and passes against the track --- .../_components/GuardrailsOverview.test.tsx | 9 +++++++++ .../_components/GuardrailsOverview.tsx | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.test.tsx index b616982d69b..2aff2083870 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.test.tsx @@ -152,6 +152,15 @@ describe("GuardrailsOverview", () => { await waitFor(() => expect(document.querySelector('[aria-busy="true"]')).toBeInTheDocument()); }); + it("wraps the metric cards on a flexible track instead of a fixed column count", async () => { + renderOverview(); + + const grid = (await screen.findByText("Total Evaluations")).closest("div.grid"); + + expect(grid).not.toBeNull(); + expect(grid!.className).toMatch(/grid-cols-\[repeat\(auto-fit,minmax\([^)]+,1fr\)\)\]/); + }); + it("shows a failure message when the usage request rejects", async () => { mockGetGuardrailsUsageOverview.mockRejectedValue(new Error("network down")); renderOverview(); diff --git a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.tsx b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.tsx index 3d91fc1b9b6..e1048c5322f 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/guardrails-monitor/_components/GuardrailsOverview.tsx @@ -211,7 +211,7 @@ export function GuardrailsOverview({ -
+