Skip to content

[Billing Credits] PR-I3: Credit usage card#1990

Merged
Vu-John merged 3 commits intomainfrom
04-30-_billing_credits_pr-i3_credit_usage_card_activity_table
May 2, 2026
Merged

[Billing Credits] PR-I3: Credit usage card#1990
Vu-John merged 3 commits intomainfrom
04-30-_billing_credits_pr-i3_credit_usage_card_activity_table

Conversation

@Vu-John
Copy link
Copy Markdown
Collaborator

@Vu-John Vu-John commented May 1, 2026

[Billing Credits] PR-I3: Credit usage card

Adds a usage card to the organization billing page. Two stacked progress
bars (daily limit + paid credits) gated on user state. Replaces the
placeholder copy that previously sat above the plan-comparison table.

Visual

┌─ Credit usage ──────────────────────────────────┐
│ Your model credits                  [Top up]    │
│ Credits are linked to your user, not the org.   │
│                                                 │
│ Daily limit               9% used · resets 11h  │
│ ▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │
│                                                 │
│ Paid credits                        30% used    │
│ ▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │
└─────────────────────────────────────────────────┘

The paid bar is hidden until the user's first top-up. Both bars use a
bare percent ("X% used") with no dollar values surfaced anywhere on
the card.

Changes

  • New useCreditBalance hook. Calls the server's read-side balance
    endpoint, normalizes defensively, and useMemos the result so
    consumers don't churn on every parent render. Auth-gated via
    useConvexAuth().isAuthenticated + Convex "skip" sentinel.
  • New CreditBalanceCard: header + sub-line clarifying credits are
    user-scoped (not org-scoped) + two usage bars + Top up button.
  • New TopupActionButton: renders the Top up button only when the
    preset endpoint resolves with at least one preset. Wrapped in an
    inner error boundary so a missing-function error collapses to no
    button rather than crashing the whole card.
  • OrganizationBillingSection slots the card in above the
    plan-comparison view, wrapped in <ErrorBoundary fallback={null}>,
    and removes a stale placeholder note that surfaced an outdated
    per-user-per-day pricing line.
  • Imports the relocated ErrorBoundary from
    @/components/ui/error-boundary (moved out of evals/ in PR-I2 —
    no longer a domain-specific primitive).

Why no dollar values

The card surfaces only percentages. Showing dollar amounts on the
paid-credits row would invite the user to compute a wrong remaining
dollar value (since the bar's denominator is in the credited domain,
not the paid domain). Bare percentages match the well-validated
gas-gauge UX pattern used by similar credit pages — the row label
("Daily limit", "Paid credits") tells the user what the pool is, and
the percent tells them where they are within it.

Tests

  • CreditBalanceCard.test.tsx: skeleton loading state, hidden paid
    bar before any top-up, paid row renders as % used only,
    top-up button opens dialog, regression guard that neither row
    ever renders a $ character, lock-in test for the user-scope
    sub-line copy.
  • TopupActionButton.test.tsx: renders only when presets are
    available, hides on loading + empty, click handler.
  • OrganizationsTab.billing.test.tsx: extended convex/react mock
    to include useQuery stub for the new auth-gated hook.

Stack

  • PR-I1 ✅
  • PR-I2 ✅
  • This PR ← you are here

Notes

  • Marked draft. Backend Fix 6 (response payload trim) shipped in
    mcpjam-backend#184; remaining gate is full backend deploy to
    production.
  • The activity-table feature considered earlier was dropped in design
    review — Stripe email receipts are the source of truth for payment
    history; in-inspector duplication added complexity and surface area
    without a clear win.

Risk

Low. Net-new card on the billing page; only existing surface changed
is the removal of a stale tooltip line in the plan-comparison table
and a small semantic tightening of the shared ErrorBoundary
primitive (in PR-I2). The card handles missing data, missing
endpoints, and unauthenticated states without crashing.

@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 04:07 — with GitHub Actions Inactive
@chelojimenez
Copy link
Copy Markdown
Contributor

chelojimenez commented May 1, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Collaborator Author

Vu-John commented May 1, 2026

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Internal preview

Preview URL: https://mcp-inspector-pr-1990.up.railway.app
Deployed commit: a659407
PR head commit: 0c7f604
Backend target: staging fallback.
Health: ❌ Convex unreachable — see upsert-preview job logs (staging may need convex deploy)
Access is employee-only in non-production environments.

@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 38fe6b7 to 8ef879f Compare May 1, 2026 04:18
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 8ef879f to c1eb58a Compare May 1, 2026 04:23
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 04:23 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from c1eb58a to a63f96b Compare May 1, 2026 04:40
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from a55ab8c to a42fcee Compare May 1, 2026 04:46
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from a63f96b to 86e1318 Compare May 1, 2026 04:46
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 04:46 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from a42fcee to 58f56f9 Compare May 1, 2026 04:54
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 86e1318 to 02cbce1 Compare May 1, 2026 04:54
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 04:54 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from 58f56f9 to eca8ffc Compare May 1, 2026 05:39
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 02cbce1 to de5265f Compare May 1, 2026 05:39
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from de5265f to 355b020 Compare May 1, 2026 05:43
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 05:44 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 355b020 to e1e3a0f Compare May 1, 2026 06:07
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from eca8ffc to ee6a70f Compare May 1, 2026 06:07
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 06:07 — with GitHub Actions Inactive
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 1, 2026 08:09 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from 5d59d58 to 8fb4dcb Compare May 2, 2026 00:00
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 619b6de to 717bd2a Compare May 2, 2026 00:00
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 2, 2026 00:00 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 717bd2a to eade3c4 Compare May 2, 2026 00:48
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 2, 2026 00:48 — with GitHub Actions Inactive
@Vu-John Vu-John changed the title [Billing Credits] PR-I3: Credit usage card + activity table [Billing Credits] PR-I3: Credit usage card May 2, 2026
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from eade3c4 to 277bf6d Compare May 2, 2026 00:56
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 2, 2026 00:56 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from 8fb4dcb to 272406d Compare May 2, 2026 01:48
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 277bf6d to 3dfc063 Compare May 2, 2026 01:48
@Vu-John Vu-John temporarily deployed to preview-pr-1990 May 2, 2026 01:48 — with GitHub Actions Inactive
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta branch from 272406d to 535a22d Compare May 2, 2026 03:46
@Vu-John Vu-John force-pushed the 04-30-_billing_credits_pr-i3_credit_usage_card_activity_table branch from 3dfc063 to 0c7f604 Compare May 2, 2026 03:46
@Vu-John Vu-John marked this pull request as ready for review May 2, 2026 03:47
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 2, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@dosubot dosubot Bot added the enhancement New feature or request label May 2, 2026
@Vu-John Vu-John changed the base branch from 04-30-_billing_credits_pr-i2_top-up_dialog_chat_banner_cta to main May 2, 2026 03:56
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants