Repository navigation
feat(customer-portal): share budget editors and app model access - #52784
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
8268357 to
ecb9d11
Compare
79312d7 to
28027cf
Compare
|
@greptileai review 28027cf. Rebased onto main after #52682 merged. Only allowed-models changes remain. 146 focused tests, make check, and live persistence pass. |
|
bugbot run Please review 28027cf, rebased onto main. Eight frontend/test files remain. 146 focused tests, make check, and both live catalog saves pass. |
[Medium impact] The changes reach related dashboard budget and usage workflows, plus a bounded admin model lookup. Fix the two outstanding save failures before merging; the new custom-cap display issue is non-blocking. Findings
|
|
@greptileai review a5663bc. App pickers now retrieve resource models from backend access checks. Optional clearing, live persistence, and 166 focused tests pass. |
|
bugbot run Please review a5663bc. Backend lookup now respects team, project, and key permissions. Optional clearing and live UI persistence are verified. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@cursor please review eac6fbdf1d1. Model lookup errors now use resource failures, with live rotation proof and six regression cases. |
|
@greptileai please review eac6fbdf1d1. It fixes resource lookup errors and exposes budget fields, with passing regressions and live proof. |
|
Unable to authenticate your request. Please make sure to connect your GitHub account to Cursor. Go to Cursor |
eac6fbd to
440fbe5
Compare
|
@cursor please review the updated app budget hierarchy, separate preset catalogs, custom save preservation, and scoped model access. |
|
@greptileai please review the rebased UI and shared editors, especially preset selection, optional member limits, and existing budget preservation. |
|
Unable to authenticate your request. Please make sure to connect your GitHub account to Cursor. Go to Cursor |
|
@greptileai please review d6247943c1c, especially shared budget serialization, preset-to-Custom transitions, preserved reset dates, and optional model restrictions across customer scopes. |
|
@cursor review Please check d6247943c1c for shared budget editor regressions, particularly spend-period changes, blank amounts, and preset-to-Custom transitions. |
71e439c to
30380cf
Compare
|
@greptileai please review 30380cf after rebasing onto main with #52976 merged, especially shared budget editors and custom-window preservation. |
| const parsed = parseBudget(fields); | ||
| if ( | ||
| !validPrimaryPeriod(fields, original) || | ||
| fields.budgetWindows.some(({ budget }) => !isValidBudgetDuration(budget.budget_duration)) |
There was a problem hiding this comment.
A stored 6days window now fails this check, even when the admin only edits a rate. The backend accepts that period, but the new strict check blocks saving unrelated changes. Preserve unchanged stored periods, as the primary-period check already does.
Knowledge Base Used: Dashboard and enterprise UI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| : await fetchClient.POST("/management/v1/apps", { | ||
| body: { ...body, resource_id: id, resource_type: resource.resource_type }, | ||
| }); | ||
| return [ | ||
| id, | ||
| response.data | ||
| ? { appId: response.data.app_id, value: valueFor(response.data), saved: valueFor(response.data) } |
There was a problem hiding this comment.
| value: { | ||
| ...(fields.budgetSource === "custom" | ||
| ? { budget: { ...budget.value, ...budgetPolicyChanges(fields.policy, app?.budget) } } | ||
| : { budget_id: fields.budgetSource.startsWith("profile:") ? fields.budgetSource.slice(8) : null }), |
There was a problem hiding this comment.
No limit leaves custom app budget
High Severity
Choosing No limit only sends budget_id: null and omits budget: null. Custom overall app budgets are stored in budget, so a sparse PATCH leaves that policy in place. After save and reload the app still has its custom cap instead of no limit. The previous settings form cleared this by sending budget: null when the budget was disabled.
Reviewed by Cursor Bugbot for commit 30380cf. Configure here.
| customer.id, | ||
| customer.label, | ||
| row ?? { spend: 0, effective_budget: customer.id ? inherited : null }, | ||
| ), |
There was a problem hiding this comment.
Inherited customers show zero budget spend
Medium Severity
Customers that inherit the app default have no association row, so the table synthesizes spend: 0 and no budget_usage. Budget remaining and progress then look unused even when usage data for that customer is already on the row.
Reviewed by Cursor Bugbot for commit 30380cf. Configure here.
|
@greptileai please review 30380cf again after the rebase, rechecking prior findings, shared budget editors, custom-window preservation, and optional model restrictions. |
|
bugbot run Please review 30380cf again after the rebase, rechecking prior findings, shared budget editors, custom-window preservation, and monthly spend rendering. |
| const otherBudgets = budgets.filter( | ||
| (budget) => budget.source === "window" && customerBudgetPeriod(budget.budget_duration) === "other", | ||
| ); | ||
| const customWindows = otherBudgets.length > 0; |
There was a problem hiding this comment.
CustomerSpendCells now excludes primary caps from otherBudgets. For a member with a primary 7d or lifetime cap, the table stops showing that cap's recorded spend and reset date. It instead shows calendar-month spend with “No limit,” even though the cap still applies. Keep primary non-calendar caps in the displayed budget rows.
| const otherBudgets = budgets.filter( | |
| (budget) => budget.source === "window" && customerBudgetPeriod(budget.budget_duration) === "other", | |
| ); | |
| const customWindows = otherBudgets.length > 0; | |
| const otherBudgets = budgets.filter((budget) => customerBudgetPeriod(budget.budget_duration) === "other"); | |
| const customWindows = otherBudgets.some((budget) => budget.source === "window"); |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
4 issues from previous reviews remain unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 30380cf. Configure here.


Handwritten 1-3 sentence description
Unify customer and app budget editing with shared preset-or-custom controls and scoped model lists. App detail pages now separate Usage, Budget groups, and Settings; app, organization, team, and member pages share their header, navigation, and spacing.
Details
TLDR
Problem this solves:
How it solves it:
Rebased onto main after #52976 merged. Its finalized custom-period backend is now part of the base. This UI PR adds no database columns or budget request fields. Its backend changes add an admin-only accessible-model lookup with normalized errors.
Intentional product change: Budget templates use compact rows containing spend limits, TPM, RPM, soft budget, and allowed models. Multiple spend amounts stay inline, with a plus button to confirm another amount and period. Individual entities retain the preset-or-Custom split editor. Blank spend removes that cap. No reset keeps a lifetime cap. Optional model lists add no restrictions when empty.
Overall app, organization-wide, and app × organization catalogs remain separate. App × organization defaults now live below their template catalog in Budget groups, with App on the left, Budget group on the right, Add app default, and one bottom Save changes button. Existing assignments from the older organization catalog remain labeled and cannot be newly selected. Per-app member defaults can now link to shared app-member budget groups or use optional custom limits. Each app has a Budget groups tab headed Per App Member Budget Groups, with its default beneath the catalog. Settings contains the overall app budget, surcharge, and whether the app may create new customers. Teams show the same custom fields directly because they have no template catalog, without a budget-source dropdown or enable checkbox.
User Flow
Before, template values occupy repeated form sections, and app defaults are edited separately in app settings.
/customers/settings?tab=organizationand compare the existing budget groups.After, templates fit into rows and app defaults sit alongside their own catalog.
/customers/settings?tab=organizationand compare the same budget groups.The Add app budget identity fields also now align. Before at
3dbdd58e815, the app selector starts lower and is shorter than the organization field./customers/usage?org=budget-source-proofand click Add app budget.After at
8fe13f58b688171f282d4c9e16be76ff1c3e4e3e, both fields have matching label spacing and 36px height.Screenshots / Proof of Fix
Rebase verification at
30380cf00c1on mainb608fa878fbf, including #52976. The merged budget backend matches main. All 652 focused UI tests and 144 backend tests pass.make checkpasses, including Python gates, test-tree lint, dashboard lint budgets, and OpenAPI/type synchronization. The custom-cap regressions now exercise the shared forms, preserving custom windows and their reset identity while calendar caps are changed or removed. The original local logo edit was restored without committing it, and both Applications and Customers return HTTP 200 locally. GitHub reports no merge conflicts. The standalone dashboard production typecheck still reports the existingAgentControlPlaneViewlayout-export error in an unchanged file. CI and fresh Greptile/Bugbot reviews are pending.The real dashboard runs locally at
http://127.0.0.1:4336against proxy 4356, isolated PostgreSQL, and shared Redis 6396. The screenshots above show the actual UI. The catalog uses synthetic model entries, so no inference request was needed for these configuration changes.The budget persistence proof ran on the combined #52976 and #52784 code committed as
3dbdd58e815631e3dcab2c6eca11a063c05a31be. In one save, Budget Period Demo changed to No limit and Linked App Demo A changed to App model access demo. API readback confirmed both changes, five untouched app defaults, and unchanged overall budgets, member defaults, auto-create settings, and margins. Reload retained the selections. Separate integration coverage exercises multiple new rows, partial failures, stale refreshes, and retries without duplicate app creation.The app × organization dropdown now offers only that catalog's groups. Two existing UI Standard assignments remain labeled as overall organization groups. Their current policies are retained until explicitly replaced.
Through the real UI, Tier 1 saved a $500 monthly cap, $6,000 yearly cap, $75 per 7d, 100,000 TPM, 1,000 RPM, and $400 soft budget. Readback returned primary
max_budget=500andbudget_duration=1mo, plusbudget_limitsfor12moand7d, each with a reset deadline. Newly entered6daysand6modisplayed validation and disabled Add. Custom chips display/ 7donce.The period regression was originally reproduced at
440fbe545d5and corrected atd6247943c1c3. A yearly-to-monthly edit replaced January 1, 2027 with December 1, 2026. Amount-only edits retained the deadline, and member defaults reset independently. These paths remain covered after the rebase. Soft-budget-only edits retain their duration. Preset-to-Custom transitions retain the selected preset's extra windows and hidden policy.Focused runs pass for the changed app/group editors, settings/dialogs, form parsers, and previously failing CI files. The app/default/group test cleanup retained all 96 cases.
make checkpasses at the final tip. The app-budget modal integration file passes all 26 cases. Subsequent updates add app detail navigation, usage-table edit actions, shared spend-limit editors, and consistent detail-page layouts. Earlier screenshots and persistence probes below document the revisions named alongside them. OpenAPI snapshot and API type regeneration produced no extra diff. Local production typecheck reports only the existing generated dashboard-layout export error. CI and bot reviews are tracked separately.At
5487e6a8421, the latest layout cleanup passed 130 focused integration tests across app defaults, app management and usage, customer budget groups, customer management, and customer usage.make checkpassed. The actual local dashboard was checked on app Budget groups and Settings, organization Usage and Settings, team Usage, and member Usage. This cleanup changes no backend/API/schema code. Shared test fixtures and assertions remain reused.Team settings were also verified on
/customers/manage?org=app-budget-ui-org&team=app-budget-ui-team&tab=settings. Directly entering 20,000 TPM and 30 RPM saved successfully with no dollar cap. The shared settings/dialog regression files pass all 53 tests, including a team with no existing budget.The unchanged app-model endpoint was previously exercised for teams, projects, and keys. Missing resources return 404, lookup outages return 503, and authorization runs before the error boundary. The live key-rotation proof reproduced invalid-key responses and verified normalized errors and recovery.
Local reproduction setup and requests
Use an isolated local PostgreSQL database. The provider entries are synthetic and point to a closed localhost port. They are used only to populate the catalog.
The local launcher reads DATABASE_URL, LITELLM_MASTER_KEY, UI_USERNAME, and UI_PASSWORD from existing private local settings without printing them. Set DEMO_UNUSED_PROVIDER_KEY to any synthetic value. The equivalent commands are below. The recorded run used the same configuration with the unused synthetic value inline.
redis-server --port 6396 --daemonize yes .venv/bin/python litellm/proxy/proxy_cli.py --config proxy-config.yaml \ --host 127.0.0.1 --port 4356 --num_workers 2 --use_v2_migration_resolver cd litellm/ui/litellm-dashboard NEXT_PUBLIC_USE_REWRITES=true LENS_DEV_PROXY_URL=http://127.0.0.1:4356 \ npm run dev -- --webpack --hostname 127.0.0.1 --port 4336The endpoint probe creates an unrestricted two-model team, a one-model project beneath it, and a key in that project. Set TEAM_ID to the demo app team, PROJECT_ID to the project ID, and KEY_RESOURCE_ID to the stable UUID returned by
/management/v1/apps/resources?resource_type=virtual_key.The screenshots show actual browser interaction with this proxy. Browser video recording was unavailable, so no new recording is claimed.
Race reproduction
Use the proxy setup above and an isolated database. With Prisma and httpx installed, set DATABASE_URL and LITELLM_MASTER_KEY locally and run this script. The warmup makes the after run reach concurrent reads after the new proxy starts. The original before run used the already warm proxy.
Period and shared-field reproduction
With the local setup above, create a test app through
/management/v1/appsusing a disposable team. Set both itsbudgetanddefault_customer_member_budgetto the following values. Use the returned app ID for API readback and the team ID in/apps?app=<team-id>.{"max_budget":null,"budget_duration":null,"soft_budget":200,"tpm_limit":2000,"rpm_limit":100,"allowed_models":["validation-no-inference"],"budget_limits":[{"budget_duration":"12mo","max_budget":1200,"reset_at":"2027-01-01T00:00:00Z"}]}Change the existing annual cap to monthly through the UI and save. Read
/management/v1/apps/<app-id>to verify the next monthly deadline. Edit only its amount and verify the deadline remains unchanged. Repeat for the member default. For the main spend field, enter an amount and choose Custom with7d, save, then choose No reset and save. The amount remains and the main duration becomes null.On
/customers/settings, add a group and fill the five shared controls. Save and read/management/v1/customer_organization_budget_groupsto confirm those fields persist. Clearing a spend amount removes that cap without clearing TPM/RPM or model policy.App defaults and custom-period reproduction
Open
/customers/settings?tab=app. Add a template named Tier 1. Set the first spend amount to 500 per month, then use the plus button to add 6000 per year and 75 per custom period 7d. Enter TPM 100000, RPM 1000, and soft budget 400. Save. Entering 6days or 6mo in the custom-period field must disable Add and show the accepted format.curl -s http://127.0.0.1:4356/management/v1/app_customer_organization_budget_groups \ -H "Authorization: Bearer $LITELLM_MASTER_KEY"The saved Tier 1 has
max_budget: 500,budget_duration: "1mo", and extra12mo: 6000and7d: 75entries with reset deadlines.In the defaults table below, select different groups for two apps. Click the single bottom Save changes button, reload, and confirm both assignments persisted. With unconfigured app resources available, Add app default allows several pending rows before that same save. Read
/management/v1/appsbefore and after and comparedefault_tier_budget_id; unrelated budgets and other settings must stay unchanged.Pre-Submission checklist
Type
New Feature, Bug Fix, and Refactoring
Caveats
Low
30380cf00c1are pending.Final Attestation
Note
Medium Risk
Adds proxy management auth resolution for model listing and broadens budget PATCH/PUT surfaces across app and customer scopes, though changes are mostly UI with a narrow new read-only API.
Overview
Adds an admin-only management API to list models an app resource (team, project, or virtual key) may use, backed by
app_resource_modelsandaccessible_model_nameswith normalized 404/503 errors.On the dashboard, app budgeting is split and reused: Settings holds overall app budget, surcharge, and customer auto-create; Budget groups pages edit shared templates and per-app organization/member defaults (including bulk save, custom member limits, and scoped model pickers fed by the new endpoint). Usage gets sortable tables, detail-page navigation, and organization spend editing via shared customer budget dialogs—per-customer org budgets no longer embed optional member limits in the same form.
Removes legacy pieces (
AppBudgetEditor,AppProfileSelect) and expands integration coverage for defaults, settings, and usage flows.Reviewed by Cursor Bugbot for commit 30380cf. Bugbot is set up for automated code reviews on this repo. Configure here.