From 8905ca8a8d3b9d143830238f29fae3a14757588e Mon Sep 17 00:00:00 2001 From: SeongWoon Cho Date: Tue, 15 Sep 2026 18:07:31 +0900 Subject: [PATCH] fix(ui): correct budget window reset hints for timezone and weekday The Budget Window editor hardcoded "midnight UTC" and labeled the weekly window as resetting on Sunday. The backend computes resets in the configured litellm_settings.timezone and anchors the weekly window on Monday, so the hints misled operators about when spend actually resets. Point the hints at litellm_settings.timezone (noting the UTC default) and fix the weekly label to Monday. Add a unit test that fails if the Sunday or fixed-UTC wording returns. --- .../BudgetWindowsEditor.test.ts | 29 +++++++++++++++++++ .../key_team_helpers/BudgetWindowsEditor.tsx | 8 +++-- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.test.ts diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.test.ts b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.test.ts new file mode 100644 index 00000000000..9fa157e8680 --- /dev/null +++ b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from "vitest"; + +import { BUDGET_WINDOW_OPTIONS } from "./BudgetWindowsEditor"; + +const hintFor = (value: string): string => { + const option = BUDGET_WINDOW_OPTIONS.find((o) => o.value === value); + if (!option) throw new Error(`no budget window option for ${value}`); + return option.resetHint; +}; + +describe("BUDGET_WINDOW_OPTIONS reset hints", () => { + it("describes the weekly window as resetting on Monday, matching the backend", () => { + expect(hintFor("7d")).toContain("Monday"); + expect(hintFor("7d")).not.toContain("Sunday"); + }); + + it("does not claim a fixed UTC reset, since the backend honors the configured timezone", () => { + for (const option of BUDGET_WINDOW_OPTIONS) { + expect(option.resetHint).not.toContain("midnight UTC"); + } + }); + + it("points at litellm_settings.timezone and its UTC default for every window that resets at a time of day", () => { + for (const value of ["24h", "7d", "30d"]) { + expect(hintFor(value)).toContain("litellm_settings.timezone"); + expect(hintFor(value)).toContain("defaults to UTC"); + } + }); +}); diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx index 3f8b2484c7b..b484ab50366 100644 --- a/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx +++ b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx @@ -8,11 +8,13 @@ export interface BudgetWindowEntry { max_budget: number | null; } +const RESET_TIMEZONE_NOTE = "in the proxy timezone (litellm_settings.timezone, defaults to UTC)"; + export const BUDGET_WINDOW_OPTIONS = [ { value: "1h", label: "Hourly", resetHint: "Resets every hour" }, - { value: "24h", label: "Daily", resetHint: "Resets daily at midnight UTC" }, - { value: "7d", label: "Weekly", resetHint: "Resets every Sunday at midnight UTC" }, - { value: "30d", label: "Monthly", resetHint: "Resets on the 1st of every month at midnight UTC" }, + { value: "24h", label: "Daily", resetHint: `Resets daily at midnight ${RESET_TIMEZONE_NOTE}` }, + { value: "7d", label: "Weekly", resetHint: `Resets every Monday at midnight ${RESET_TIMEZONE_NOTE}` }, + { value: "30d", label: "Monthly", resetHint: `Resets on the 1st of each month at midnight ${RESET_TIMEZONE_NOTE}` }, ]; interface BudgetWindowsEditorProps {