Skip to content

fix(billing): align TeamUsage with backend PR #616#465

Merged
senamakel merged 1 commit intotinyhumansai:mainfrom
senamakel:fix/server-refactor
Apr 9, 2026
Merged

fix(billing): align TeamUsage with backend PR #616#465
senamakel merged 1 commit intotinyhumansai:mainfrom
senamakel:fix/server-refactor

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented Apr 9, 2026

Summary

  • Aligns frontend TeamUsage interface with backend billing simplification (tinyhumansai/backend#616)
  • fiveHourSpendUsdcycleLimit5hr, bypassRateLimitbypassCycleLimit
  • Removes deleted fields: dailyUsage, totalInputTokensThisCycle, totalOutputTokensThisCycle
  • Updates all consumers: Conversations.tsx, useUsageState.ts, InferenceBudget.tsx
  • Updates mock API response to match new shape

Test plan

  • tsc --noEmit passes (verified)
  • ESLint passes (verified, pre-existing warnings only)
  • Conversations page renders usage pills without TypeError
  • Billing settings InferenceBudget panel shows 5-hour cap correctly
  • Rate limit banner appears/disappears based on new cycleLimit5hr / bypassCycleLimit fields

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the usage cap calculation from 10-hour rolling windows to accurate 5-hour fixed cycle limits for proper rate limiting.
    • Removed daily usage metrics and detailed token tracking from the billing summary for clearer cost monitoring.
    • Updated spending cap display to reflect improved cycle-based tracking methodology.

Backend simplified billing model: fiveHourSpendUsd → cycleLimit5hr,
bypassRateLimit → bypassCycleLimit, removed dailyUsage and token
count fields. Updates all frontend consumers and mock API.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request refactors the team usage billing model from tracking rolling-window 5-hour spending and daily token counts to fixed-cycle usage limits. The TeamUsage interface is updated to replace fiveHourSpendUsd and daily metrics with cycleLimit5hr and cycleLimit7day, and bypassRateLimit is renamed to bypassCycleLimit. All UI components, hooks, and mock responses are updated to reflect the new field names and semantics.

Changes

Cohort / File(s) Summary
UI Component Updates
app/src/components/settings/panels/billing/InferenceBudget.tsx, app/src/pages/Conversations.tsx
Updated billing cap displays to use cycleLimit5hr instead of fiveHourSpendUsd and bypassCycleLimit instead of bypassRateLimit. Removed daily usage row and updated 5-hour cap percentage calculations. Changed limit detection logic to compare cycleLimit5hr >= fiveHourCapUsd.
Hook Logic Updates
app/src/hooks/useUsageState.ts
Updated usagePct10h calculation to use cycleLimit5hr as numerator instead of fiveHourSpendUsd. Changed isRateLimited condition to check cycleLimit5hr >= fiveHourCapUsd and renamed bypass flag reference to bypassCycleLimit.
Data Model & Mock Updates
app/src/services/api/creditsApi.ts, scripts/mock-api-core.mjs
Updated TeamUsage interface to remove token-level fields (dailyUsage, totalInputTokensThisCycle, totalOutputTokensThisCycle, fiveHourSpendUsd) and add fixed-cycle fields (cycleLimit5hr, cycleLimit7day). Renamed bypassRateLimit to bypassCycleLimit. Updated mock response payload to match new contract.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 From rolling windows, we now leap with grace,
To cycles fixed—a cleaner billing space!
Five hours capped, seven days in sight,
Field names fresh, our model shines so bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly identifies the main change: aligning the frontend TeamUsage interface with a backend refactor. It's concise, specific, and clearly conveys the primary purpose of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@senamakel senamakel merged commit 5d1d7ac into tinyhumansai:main Apr 9, 2026
8 of 9 checks passed
@senamakel senamakel deleted the fix/server-refactor branch April 9, 2026 20:10
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.

1 participant