Add usage-based billing native UI mode#142
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a “native AI Credits” (usage-based billing) UI/report mode and threads report-format metadata through the pipeline and App so native AI Credits reports can be processed without relying on transition-period PRU comparison assumptions.
Changes:
- Make the pipeline metadata-aware (aggregator factory + updated report-format/header detection) to support native AI Credits uploads, including cases where alias columns are absent.
- Introduce
reportMode+ included-credits policy resolution and propagate them through App and views. - Update UI surfaces to hide PRU comparison columns/charts for native reports, reuse shared billing cards, and gate unsupported Cost Management simulation for native reports (with new tests).
Show a summary per file
| File | Description |
|---|---|
| src/App.tsx | Wires report metadata → report mode/policy and propagates gating + props into views. |
| src/components/ProductUsageTable.tsx | Adds reportMode to hide PRU comparison columns and sort appropriately in native mode. |
| src/components/ProductUsageTable.test.ts | Verifies transition vs native table columns render correctly. |
| src/components/ui/BillingProjectionDisclaimer.tsx | Adds showDetails to tailor disclaimer verbosity by report mode. |
| src/components/ui/BillingTotalsCards.tsx | Makes billing cards native-aware (omit PRU card; split org promo disclaimer control). |
| src/components/ui/BillingTotalsCards.test.ts | Ensures native mode retains AIC title/disclosures and promo note gating. |
| src/pipeline/aggregators/nativeUsageAggregation.test.ts | Updates/extends native aggregation tests for quota identity preservation. |
| src/pipeline/aggregators/usageMetrics.test.ts | Aligns native metrics expectations with native-normalized AIC fields. |
| src/pipeline/aggregators/userUsageAggregator.ts | Applies native included-credits quota identity policy when selecting monthly quota. |
| src/pipeline/aicIncludedCredits.test.ts | Adds coverage that license summaries use native policy quotas/credits. |
| src/pipeline/parser.ts | Splits validateBaseHeader from full AIC header validation. |
| src/pipeline/reportAdapters.ts | Detects native reports when alias columns are absent and validates base headers. |
| src/pipeline/reportAdapters.test.ts | Adds native-header-without-aliases detection coverage. |
| src/pipeline/reportUsageMetrics.ts | Uses native-normalized AIC gross/net fields and derives discount as gross−net. |
| src/pipeline/reportUsageMetrics.test.ts | Updates assertions to validate native-normalized AIC fields reflect allocation changes. |
| src/pipeline/runPipeline.ts | Accepts aggregator factory (constructed after report metadata detection). |
| src/pipeline/runPipeline.test.ts | Adds tests for native aggregation behaviors and header variants; updates expected AIC net values. |
| src/utils/reportMode.ts | Adds helpers to derive report mode from report metadata. |
| src/views/CostCentersView.tsx | Hides PRU comparison UI in native mode; reuses BillingTotalsCards and gates disclaimers. |
| src/views/CostManagementView.tsx | Adds native-mode “simulation unavailable” experience and hides simulator controls. |
| src/views/ModelsView.tsx | Hides PRU comparison charts in native mode; reuses BillingTotalsCards; adjusts charts for native. |
| src/views/OrganizationsView.tsx | Hides PRU comparison UI in native mode; reuses BillingTotalsCards and updates messaging. |
| src/views/OverviewView.tsx | Hides transition messaging/charts in native mode; wires reportMode + org promo disclaimer flag. |
| src/views/ProductsView.tsx | Adds reportMode to remove PRU legend/scale impact in native mode and passes through to table. |
| src/views/UserDetailsView.tsx | Adds reportMode/policy props and hides PRU comparison surfaces in native mode; reuses billing cards. |
| src/views/UsersView.tsx | Adds reportMode/policy props; updates seat pool sizing to use policy values and hides PRU columns in native. |
| src/views/nativeBillingCards.test.ts | Ensures multiple views reuse shared billing card title/disclosures in native mode. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 27/27 changed files
- Comments generated: 5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Usage-based billing reports need to render from native AI Credits columns without falling back to transition-period PRU comparison assumptions. This PR wires report metadata through App aggregation so native uploads can be processed safely, while preserving the transition-period billing preview experience.
Changes
feat: support native report aggregationfeat: add usage-based billing UI modefix: address usage billing review feedbackAdditional notes:
enableNativeAiCreditsProcessing: true, so usage-based billing reports are accepted.Testing
npm run test- passed, 24 files / 195 testsnpm run lint- passednpm run build- passed with the existing Vite chunk-size warningChecklist
npm run lint)