Commit graph

26 commits

Author SHA1 Message Date
Yassin Kortam
bc5638b38e
fix(ui): stop per-model usage export from duplicating user spend across models (#30980)
Some checks are pending
GitHub Actions Security Analysis / zizmor (push) Waiting to run
The "day-by-day by user and model" usage export overcounted spend by
repeating each user-day total once per model. generateDailyWithModelsData
iterated day.breakdown.models crossed with the entity's own
api_key_breakdown and added the api key's full daily spend to every model,
leaving the per-model object (modelData) unused and never matching the api
key to the model. A user who called N models got N identical rows, so the
column summed to N times the real spend; one reported export totaled
$167,953 against a true $21,353 (7.87x).

Attribute each model only the spend of the keys that actually used it by
intersecting the entity's api keys with modelData.api_key_breakdown. This
mirrors the already-correct pattern in activity_metrics.tsx, so per-model
rows now sum back to the user-day total and models a user never called no
longer appear.

The existing tests passed only because their mocks omitted
models[*].api_key_breakdown and never asserted numeric values. The mocks
now match the real /user/daily/activity payload, and new tests assert that
per-model spend sums to the user-day total and that uncalled models are
omitted; both fail on the old code.

Resolves LIT-3866
2026-06-22 11:26:54 -07:00
ryan-crabbe-berri
7edf3a9cb5
style(ui): run prettier --write across the dashboard (#29622)
Formatting-only pass; no logic changes. Brings the UI into compliance
with .prettierrc so the new format-check CI job passes
2026-06-04 11:37:54 -07:00
Ryan Crabbe
5452692af4
test(ui): align EntityUsageExport tests with entity-key display logic
The previous fix (9dca431989) switched the export display logic to use the
entity key directly, but left the unit tests asserting the old behavior
where id/alias were extracted from api_key_breakdown metadata.

Rename mock entity keys from entity1/entity2 to "team-1"/"team-2" to
reflect the real shape of team-export payloads (breakdown.entities is
keyed by the entity identifier). Replace three tests whose assertions
documented the removed behavior:

- "should use key alias when available" → entity key is the alias when
  no team alias map is supplied
- "should use team alias map when key alias is not available" → team
  alias map resolves from the entity key
- "should use dash when team id is not available" → entity key itself
  is the fallback label (illustrated with a tag export)
2026-04-04 14:37:38 -07:00
Ryan Crabbe
9dca431989
fix(ui): use entity key for export instead of extracting team_id from api_key_breakdown
The export utility always extracted team_id from api_key_breakdown
metadata to populate the entity label/ID columns. This worked for
team exports (where entity key = team_id) but was wrong for every
other entity type — tags, orgs, customers, agents, users all
showed the API key's team name (e.g. "admins") instead of the
actual entity value.

Replace extractTeamIdFromApiKeyBreakdown with resolveEntityDisplay
which uses the entity key directly. For teams the teamAliasMap
still resolves a human-readable alias; for all other types the
entity key itself is the correct label.
2026-04-04 13:54:42 -07:00
yuneng-jiang
d98440f452 Merge remote-tracking branch 'origin' into litellm_yj_march_18_2026 2026-03-18 16:20:07 -07:00
yuneng-jiang
51f78b7d72 address greptile review feedback (greploop iteration 4)
- Add guard assertion before non-null click on custom code switch
- Use await act(async ...) for timer advancement to avoid act warnings
- Pin locale in date range assertion for CI determinism

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 13:09:17 -07:00
yuneng-jiang
b75266d254 merge origin/main, resolve test file conflicts
Resolved conflicts in ScoreChart.test.tsx and HelpLink.test.tsx by
preferring origin/main's renderWithProviders pattern and merging
unique tests from both branches.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 12:57:31 -07:00
yuneng-jiang
bbc120095e address greptile review feedback (greploop iteration 3)
- Remove Ant Design CSS class selector coupling in ExportFormatSelector test
- Lift mock fns out of TestTable component body to enable callback assertions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 12:48:01 -07:00
yuneng-jiang
40721ab18f address greptile review feedback (greploop iteration 1)
- Move vi.useRealTimers() to afterEach for proper cleanup
- Use label-based DOM queries instead of fragile positional indexes
- Remove leftover debug console.log from AgentHubTableColumns.tsx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 12:31:25 -07:00
yuneng-jiang
20c1d984a6 [Test] UI: Add unit tests for 10 previously untested components
Add Vitest + RTL tests covering DebugWarningBanner, HelpLink, ExportFormatSelector, ExportSummary, ExportTypeSelector, UsageExportHeader, MetricCard, ScoreChart, GuardrailConfig, and AgentHubTableColumns. 73 tests total.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 12:18:42 -07:00
yuneng-jiang
441f768abd Merge remote-tracking branch 'origin' into litellm_yj_march_17_2026 2026-03-18 12:07:50 -07:00
yuneng-jiang
e0e1ac617a [Test] UI: Add unit tests for 10 previously untested components
Add Vitest + RTL tests for HelpLink, DebugWarningBanner, ExportFormatSelector,
ExportTypeSelector, ExportSummary, MetricCard, PolicySelect,
ComplexityRouterConfig, RateLimitTypeFormItem, and AgentCardGrid (67 tests total).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 13:30:06 -07:00
Ryan Crabbe
c098eca509 fix(ui): CSV export empty on Global Usage page
Aggregated endpoint returns empty breakdown.entities; fall back to
grouping breakdown.api_keys by team_id.
2026-03-16 22:36:23 -07:00
Krish Dholakia
5662228e20
feat(ui): add user filtering to usage page (#22059)
* feat(ui): add user filtering to usage page

Adds "User Usage" as a new view option in the usage page dropdown,
allowing admins to view and filter usage data by individual users
via the existing /user/daily/activity backend endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(ui/): working usage filtering

* fix(ui): use single-select for user filter and add tests

The user entity type's backend endpoint only accepts a single user_id,
so the filter now uses single-select mode instead of multi-select.
Added tests for the new user entity type in EntityUsage and
UsageViewSelect. Updated CLAUDE.md and AGENTS.md with guidance on
UI/backend contract consistency and test coverage for new entity types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* revert: remove unintended package-lock.json changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* revert: restore package-lock.json to merge base state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 10:37:45 -08:00
yuneng-jiang
077cfa8c15 Adding test 2026-01-28 13:36:19 -08:00
yuneng-jiang
905e9cd6c9 breakdown by team and keys 2026-01-28 13:30:27 -08:00
yuneng-jiang
308d24d067 Resolve Team ID and Team name in export 2026-01-13 14:42:28 -08:00
yuneng-jiang
8ed1dfcb6a Agent Usage UI 2025-12-10 15:46:22 -08:00
yuneng-jiang
5a2e89a49e Customer Usage UI 2025-12-04 15:13:17 -08:00
yuneng-jiang
4aea2df986 Various Text, button state, and test changes 2025-11-27 16:19:50 -08:00
yuneng-jiang
40db4527f7 [Feature] UI - Organization Usage in Usage Tab (#16614)
* Organization Usage UI

* Resolved build issues

* Added a test
2025-11-26 21:51:19 -08:00
yuneng-jiang
5da77ac40a
[Fix] Revert UI - Organization Usage (#16980)
* Revert "[Feature] UI - Organization Usage in Usage Tab (#16614)"

This reverts commit 4de182c98f.

* Networking Changes
2025-11-22 16:02:12 -08:00
yuneng-jiang
4de182c98f
[Feature] UI - Organization Usage in Usage Tab (#16614)
* Organization Usage UI

* Resolved build issues

* Added a test
2025-11-15 16:23:48 -08:00
yuneng-jiang
c5496fd61c
[Feature] UI - Move Budgets out of Experimental (#16544)
* Move budget out of experimental and delete budget with friction

* Fixed tests

* Revert non test change
2025-11-12 13:27:02 -08:00
yuneng-jiang
0a90283fec
Change usage page to have a parent date picker (#16264) 2025-11-07 10:00:37 -08:00
Ishaan Jaff
a10425d1ce
[Feat] Allow Team Admins to export a report of the team spending (#15542)
* v0 for export

* v0 for Export

* add types for EntityUsageExportModalProps

* add folder struct

* add summry selector

* add selector for export

* add utils for entity usage export

* refactored buttons

* fixes name

* fix alignment

* test: EntityUsageExportModal

* fix lint
2025-10-14 15:07:59 -07:00