Skip to content

Surface per-member budget cycle in Teams > Members tab - #26207

Merged
yuneng-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_team_member_total_spend_frontend
Apr 24, 2026
Merged

yuneng-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_team_member_total_spend_frontend

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Frontend companion to #26195 — surfaces member spend and budget-cycle info on the Teams > Members tab.

  • Teams > Members tab: adds three new columns.
    • Current Cycle Spend (USD) — spend in the member's current budget window (what's checked against their limit).
    • Total Spend (USD) — cumulative spend by this member within this team. Tooltip notes tracking began 2026-04-21; earlier spend is not included.
    • Budget Reset — date the member's budget next rolls over, or — if no budget/duration.
  • New helper src/utils/budgetUtils.ts → formatBudgetReset(iso): dayjs-based, returns "MMM D, YYYY" or null for missing/malformed input so callers skip rendering.

Requires backend PR #26195 to merge first — total_spend and budget_reset_at are populated by its /team/info changes.

Screenshots

Issued a request with Alice's key under this team to verify per-member Current Cycle Spend / Total Spend increment and Budget Reset renders.

Screenshot 2026-04-23 at 3 39 31 PM

Test plan

  • Teams > {team with members} > Members tab — Current Cycle Spend, Total Spend, and Budget Reset columns render
  • Hover Total Spend header → tooltip mentions the 2026-04-21 tracking-start caveat
  • Member with budget_duration + budget_reset_at set → Budget Reset shows MMM D, YYYY
  • Member with no budget or no duration → Budget Reset shows —
  • Typecheck: cd ui/litellm-dashboard && npx tsc --noEmit -p tsconfig.json — no new errors in edited files

@greptile-apps

greptile-apps Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR surfaces per-member budget cycle data on the Teams > Members tab by adding three new columns (Current Cycle Spend, Total Spend, Budget Reset) and a new formatBudgetReset utility, while the backend correctly seeds a fresh budget_reset_at when cloning a team default budget for a new member.

  • P1 — Budget Status card "Resets …" lines not implemented: The PR description and test-plan items 5 & 6 state that the Overview > Budget Status card will show "Resets …" lines for the team budget and the member-default budget, but TeamInfo.tsx only gains two type-field additions — no rendering changes exist, and budget_reset_at is absent from the team_member_budget_table shape in TeamData. Both test-plan checkboxes would fail against the current code.

Confidence Score: 4/5

Safe to merge for the Members-tab columns; the Budget Status card "Resets …" feature described in the PR is unimplemented.

The Members tab additions and backend budget-clone fix are correct and well-guarded. One P1 remains: the PR description explicitly claims "Resets …" lines are added to the Budget Status card (Overview tab), but no rendering changes exist in the diff and the TypeScript TeamData interface doesn't expose budget_reset_at for team_member_budget_table. Test-plan items 5 and 6 would not pass.

ui/litellm-dashboard/src/components/team/TeamInfo.tsx — missing budget_reset_at in team_member_budget_table shape and absent Budget Status card rendering.

Important Files Changed

Filename Overview
litellm/proxy/_types.py Promotes team_member_budget_table from LiteLLM_BudgetTable to LiteLLM_BudgetTableFull so the API response includes budget_reset_at; backward-compatible since Full extends Base.
litellm/proxy/management_helpers/utils.py Correctly seeds budget_reset_at from the clone time when a member inherits a team default budget, preventing stale reset timestamps for mid-cycle joiners.
ui/litellm-dashboard/src/components/team/TeamInfo.tsx Adds total_spend and budget_reset_at to TeamMembership interface; however, team_member_budget_table in TeamData is missing budget_reset_at, and no rendering changes add the described "Resets …" lines to the Budget Status card.
ui/litellm-dashboard/src/components/team/TeamMemberTab.tsx Adds Current Cycle Spend, Total Spend, and Budget Reset columns to the Members tab; helpers correctly handle null values from the membership lookup.
ui/litellm-dashboard/src/utils/budgetUtils.ts New formatBudgetReset helper using dayjs; correctly guards against null/undefined/invalid inputs and returns a fixed "MMM D, YYYY" format.

Sequence Diagram

sequenceDiagram
    participant UI as TeamMemberTab (UI)
    participant API as /team/info (Backend)
    participant DB as litellm_budgettable

    UI->>API: GET /team/info?team_id=...
    API->>DB: fetch team_memberships with litellm_budget_table
    DB-->>API: membership rows (spend, total_spend, budget_reset_at)
    API-->>UI: TeamInfoResponseObject (LiteLLM_BudgetTableFull per member)
    UI->>UI: getUserCurrentCycleSpend(userId) → membership.spend
    UI->>UI: getUserTotalSpend(userId) → membership.total_spend
    UI->>UI: getUserBudgetReset(userId) → formatBudgetReset(budget_reset_at)
    UI->>UI: Render columns: Current Cycle Spend / Total Spend / Budget Reset
Loading

Comments Outside Diff (1)

  1. ui/litellm-dashboard/src/components/team/TeamInfo.tsx, line 121-123 (link)

    P1 Budget Status card "Resets …" rendering is absent

    The PR description states this PR adds "Resets …" lines for the team budget and the shared member-default budget to the Overview > Budget Status card. The test plan also lists two checkboxes for these items (team max_budget + budget_duration and team_member_budget default). However, the diff for TeamInfo.tsx only adds two type fields to TeamMembership — no rendering changes touch the Budget Status card, and budget_reset_at is not added to the team_member_budget_table shape in the TeamData interface. Both test plan items (5 and 6) would fail against the current code.

Reviews (10): Last reviewed commit: "restore budget_reset_at on TeamMembershi..." | Re-trigger Greptile

Adds a "Total Spend (USD)" column backed by the new
membership.total_spend field. Cumulative across budget cycles;
tracking began 2026-04-21.
@ryan-crabbe-berri
ryan-crabbe-berri force-pushed the litellm_team_member_total_spend_frontend branch from 91ce958 to 331e3f2 Compare April 22, 2026 22:00
Adds a formatBudgetReset helper (dayjs-based, with validity guard) that
renders the next reset as "today" / "in N days" / "on MMM D, YYYY". The
team budget card now shows the team's reset timestamp and the member-
default reset (when a shared team_member_budget is configured), and the
Members tab gains a Budget Reset column per member.
Adds back the per-cycle spend column that was replaced by Total Spend in
331e3f2. Current Cycle Spend reads membership.spend (zeroed on
budget_reset_at) — this is the value enforced against the member's
budget, so admins need it to see whether a member is approaching their
cap for the active window. Total Spend remains for lifetime analytics.
@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Base automatically changed from litellm_team_member_total_spend to litellm_internal_staging April 23, 2026 01:20
@veria-ai

veria-ai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Low: UI and minor backend changes for team member budget display

This PR adds budget cycle and total spend information to the Teams > Members UI tab, creates a small utility for formatting budget reset dates, and fixes the budget reset timestamp when cloning a team default budget for a new member. No security issues found.


Status: 0 open
Risk: 1/10

Posted by Veria AI · 2026-04-23T22:58:10.291Z

@veria-ai

veria-ai Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Low: UI and minor backend changes for team member budget display

This PR adds budget cycle information (reset timestamps, total spend, current cycle spend) to the Teams > Members UI tab and fixes the budget reset time when cloning a team default budget for a new member. The backend change uses Prisma ORM for the database write, and the frontend changes are purely display-oriented. No security issues found.


Status: 0 open
Risk: 1/10

Posted by Veria AI · 2026-04-23T23:50:25.837Z

Out of scope for the members-tab feature and regressed legacy teams
whose budget_reset_at is null (duration was previously shown as a
fallback).
@veria-ai

veria-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Low: UI and budget display changes

This PR surfaces per-member budget cycle information (current cycle spend, total spend, budget reset date) in the Teams > Members tab. The backend change properly initializes budget reset timestamps when cloning team budgets for new members. No security-sensitive fields are newly exposed, and all data flows through existing authenticated endpoints.


Status: 0 open
Risk: 1/10

Posted by Veria AI · 2026-04-24T00:03:52.698Z

Members tab column reads this field; dropping it from the type in the
previous revert broke the type check without affecting the reverted
render logic.
@veria-ai

veria-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Low: UI and budget cloning changes with no security impact

This PR surfaces per-member budget cycle information (total spend, budget reset time) in the Teams > Members UI tab. The backend change correctly initializes budget_reset_at when cloning team budgets for new members using Prisma ORM. The type change from LiteLLM_BudgetTable to LiteLLM_BudgetTableFull exposes budget_reset_at and created_at in responses — both are non-sensitive server timestamps. No new endpoints, authentication changes, or injection vectors introduced.


Status: 0 open
Risk: 1/10

Posted by Veria AI · 2026-04-24T00:08:40.038Z

@yuneng-berri
yuneng-berri merged commit 08cc1e6 into litellm_internal_staging Apr 24, 2026
53 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_team_member_total_spend_frontend branch April 24, 2026 00:24

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants