From d26ae9606cc9773f69ca9df7700d94e59fe657d0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 5 Aug 2026 16:42:18 +0000 Subject: [PATCH 1/3] feat(account): full entitlement usage visibility and usage_get capability Extend the account usage page with all entitlement resources grouped by daily rates, counts, storage, and per-item limits. Each row shows current use, plan limit, percent, a progress bar, near-limit warnings (>80%), and plain-language guidance on what counts and how to reduce usage. Add shared entitlement usage snapshot logic, resource visibility copy, and the read-only account usage_get MCP capability for agent parity. Cross-link billing plan cards and usage warnings to /account/billing. Co-authored-by: Kent C. Dodds --- .../worker/client/routes/account-billing.tsx | 5 + .../worker/client/routes/account-usage.tsx | 253 ++++++++++++++---- .../src/app/account-usage-data.node.test.ts | 34 +-- packages/worker/src/app/account-usage-data.ts | 81 ++---- packages/worker/src/app/loader-data.ts | 4 + .../src/entitlements/resource-visibility.ts | 164 ++++++++++++ .../entitlements/usage-snapshot.node.test.ts | 116 ++++++++ .../worker/src/entitlements/usage-snapshot.ts | 86 ++++++ .../src/mcp/capabilities/account/domain.ts | 14 +- .../account/usage-get.node.test.ts | 113 ++++++++ .../src/mcp/capabilities/account/usage-get.ts | 85 ++++++ 11 files changed, 821 insertions(+), 134 deletions(-) create mode 100644 packages/worker/src/entitlements/resource-visibility.ts create mode 100644 packages/worker/src/entitlements/usage-snapshot.node.test.ts create mode 100644 packages/worker/src/entitlements/usage-snapshot.ts create mode 100644 packages/worker/src/mcp/capabilities/account/usage-get.node.test.ts create mode 100644 packages/worker/src/mcp/capabilities/account/usage-get.ts diff --git a/packages/worker/client/routes/account-billing.tsx b/packages/worker/client/routes/account-billing.tsx index 8424239723..efc53859d0 100644 --- a/packages/worker/client/routes/account-billing.tsx +++ b/packages/worker/client/routes/account-billing.tsx @@ -565,6 +565,11 @@ export function AccountBillingRoute(handle: Handle) { {tier.price}

{tier.description}

+

+ + See your current usage + +

{isCurrent || isIncluded ? (
diff --git a/packages/worker/src/entitlements/usage-snapshot.ts b/packages/worker/src/entitlements/usage-snapshot.ts index 52263b6aa0..0488084d43 100644 --- a/packages/worker/src/entitlements/usage-snapshot.ts +++ b/packages/worker/src/entitlements/usage-snapshot.ts @@ -57,8 +57,13 @@ export async function readEntitlementUsageSnapshot(input: { now, }) const limit = resolvePlanLimit(input.plan, resource) + // per_unit_max compares one candidate value (no accumulating usage) + // and boolean_allowance limits are 0/1 allowance flags, so a + // current/limit ratio is meaningless for both. const percentOfLimit = - visibility.kind === 'per_unit_max' || limit === 0 + visibility.kind === 'per_unit_max' || + visibility.kind === 'boolean_allowance' || + limit === 0 ? null : current / limit return {