Skip to content

Fix today selector date mutation bug in dashboard components #12042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

colesmcintosh
Copy link
Collaborator

@colesmcintosh colesmcintosh commented Jun 25, 2025

Title

Fix today selector date mutation bug in dashboard components

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

  • Refactored date range selection: Created a new UsageDatePicker component to centralize date handling logic across dashboard components
  • Fixed date mutation issues: Improved date handling consistency to prevent mutation bugs in the today selector
  • Simplified component logic: Removed duplicate date selection code from multiple dashboard components (cache_dashboard.tsx, model_dashboard.tsx, usage.tsx, new_usage.tsx, entity_usage.tsx)
  • Enhanced reusability: The new UsageDatePicker component can be reused across all usage-related dashboard views

Files Modified:

  • ui/litellm-dashboard/src/components/cache_dashboard.tsx - Simplified date handling
  • ui/litellm-dashboard/src/components/entity_usage.tsx - Updated to use new date picker
  • ui/litellm-dashboard/src/components/model_dashboard.tsx - Simplified date handling
  • ui/litellm-dashboard/src/components/new_usage.tsx - Updated to use new date picker
  • ui/litellm-dashboard/src/components/shared/usage_date_picker.tsx - New component for centralized date handling
  • ui/litellm-dashboard/src/components/usage.tsx - Simplified date handling

The changes improve code maintainability by centralizing date selection logic and fix mutation issues that were causing problems with the today selector functionality.

colesmcintosh and others added 5 commits June 24, 2025 14:28
- Create new Date objects instead of mutating original DateRangePicker dates
- Fixes issue where first API call would mutate dateValue.from/to causing
  subsequent calls to use corrupted date ranges
- Updated usage.tsx, cache_dashboard.tsx, and model_dashboard.tsx
- Minimal change preserving original timezone logic
…mponent, simplifying date handling logic and improving consistency across components.
Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 8:03pm

… directly, improving clarity and consistency in metric data retrieval.
…proving timezone handling for date selections. Default time range visibility is set to true, ensuring better user experience in usage dashboards.
@krrishdholakia
Copy link
Contributor

  • Is this referencing a github issue? if so, please note it here
  • If there are UI changes, please attach a screenshot / loom for review

@ishaan-jaff
Copy link
Contributor

This was for a user issue from slack cc @krrishdholakia. @colesmcintosh can you add loom or screenshot ?

- Fix date formatting in API calls from ISO format to YYYY-MM-DD
- Update userDailyActivityCall, teamDailyActivityCall, and tagDailyActivityCall
- Prevent date mutation by creating new Date objects before API calls
- Set proper time boundaries (00:00:00 to 23:59:59) for same-day selections

The API expects dates in YYYY-MM-DD format but the UI was sending
full ISO timestamps, causing the Today filter to return empty results.
@colesmcintosh
Copy link
Collaborator Author

@ishaan-jaff @krrishdholakia Here's the Date Fix UI Demo

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@colesmcintosh colesmcintosh merged commit 98ba5c8 into BerriAI:main Jun 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants