-
Notifications
You must be signed in to change notification settings - Fork 150
feat(dashboard): add billing screen #4050
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
base: 01-26-feat_dashboard_improve_data_providers_stability
Are you sure you want to change the base?
feat(dashboard): add billing screen #4050
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Pull Request Review: Billing UI ImplementationOverviewThis PR adds comprehensive billing UI components to the dashboard, including plan selection, usage tracking, and billing management. The implementation introduces several new React components with usage metrics visualization and integrates with the updated Cloud SDK. Positive Aspects ✅
Issues & Concerns🔴 Critical Issues1. Arithmetic Error in Billing Calculations (billing-page.tsx:82)const overage = usage > includedInPlan ? usage - includedInPlan : 0n;
return (overage * pricePerBillionUnits) / 1_000_000_000n;Problem: Division with BigInt truncates the result, potentially losing precision in financial calculations. Example: If overage is 500,000,000n and price is 49n:
Impact: Users could be undercharged or overcharged depending on usage patterns. Fix: Perform multiplication first, then divide, or add proper rounding: // Option 1: Round to nearest cent
return (overage * pricePerBillionUnits + 500_000_000n) / 1_000_000_000n;
// Option 2: More explicit rounding
const totalCents = (overage * pricePerBillionUnits) / 1_000_000_000n;
const remainder = (overage * pricePerBillionUnits) % 1_000_000_000n;
return remainder >= 500_000_000n ? totalCents + 1n : totalCents;2. Division by Zero Risk (usage-card.tsx:75-78)const calculatePercent = (value: bigint, max: bigint): number => {
if (max === 0n) return 0;
return Number((value * 10000n) / max) / 100;
};Problem: While the function handles const maxValue = includedInPlan
? current > includedInPlan ? current : (includedInPlan * 100n) / 75n
: current || 1n; // Falls back to 1n, but current could be 0n initiallyImpact: Edge case when 3. Inconsistent Plan Pricing Documentation (billing.ts:20-36)The comments state:
But the actual values are:
With pricing at $0.05 per 1k hours:
The math is correct, but consider adding explicit price calculations in comments for clarity. 4. Potential Memory Leak (billing-page.tsx:88-89)const { data } = useSuspenseQuery({
...dataProvider.currentProjectBillingDetailsQueryOptions(),
});If this page is unmounted during data fetch with Suspense, React Query may not properly clean up. Consider adding error boundaries and loading states.
|
Graphite Automations"Test" took an action on this PR • (01/27/26)1 assignee was added to this PR based on Kacper Wojciechowski's automation. |
537aefb to
df3af78
Compare
2154cae to
46d339e
Compare
df3af78 to
56694d7
Compare

TL;DR
Added billing UI components and updated the Cloud SDK dependency to support new billing features.
What changed?
BillingPlanBadgeBillingPlansBillingStatusBillingUsageGaugeCurrentBillCardManageBillingButtonUsageCard@radix-ui/react-collapsibledependency@rivet-gg/cloudSDK from versionf01ac23tod2c864dHow to test?
Why make this change?
This change introduces a new billing UI to allow users to view their current billing status, usage metrics, and manage their billing plans directly within the application. The updated Cloud SDK provides the necessary backend support for these new billing features.