Skip to content

feat: Usage page -- plan info, resource bars, feature list (OPE-103)#276

Merged
DevanshuNEU merged 4 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feat/usage-page
Mar 2, 2026
Merged

feat: Usage page -- plan info, resource bars, feature list (OPE-103)#276
DevanshuNEU merged 4 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feat/usage-page

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Mar 2, 2026

Copy link
Copy Markdown
Collaborator

What

New Usage page at /dashboard/usage. Shows the user their current plan, resource limits, and feature availability.

Sections

Plan card -- tier badge (Free/Pro/Enterprise) with color coding

Resource usage -- three bars:

  • Repositories: 2/3 with green/amber/red progress bar
  • Files per repo: 'up to 500' (limit display, no bar)
  • Functions per repo: 'up to 2,000' (limit display, no bar)

Features -- 2x2 grid:

  • Semantic Code Search (always on)
  • Codebase DNA (always on)
  • MCP Server Access (tier-dependent)
  • Priority Indexing (locked on free, shows Pro badge)

Technical

  • Uses useUserUsage hook (GET /users/usage, React Query)
  • All shadcn components: Card, Badge, Separator, Skeleton
  • Loading skeleton while data fetches
  • 210 lines, 4 sub-components

Files

  • frontend/src/pages/UsagePage.tsx (new, 210 lines)
  • frontend/src/components/Dashboard.tsx (+2 lines, route)
  • frontend/src/components/dashboard/Sidebar.tsx (+2 lines, nav link)

Partial progress on OPE-103

Summary by CodeRabbit

  • New Features
    • Added a Usage page in the dashboard showing plan tier, resource usage (repositories, files, functions), feature availability, and API cost info with loading and error states.
    • Added a Usage menu item in the dashboard sidebar for quick navigation to the new page.

New page at /dashboard/usage showing:
- Plan card with tier badge (free/pro/enterprise, color-coded)
- Resource usage bars: repos (with progress bar), files/repo, functions/repo
- Bar colors: green <70%, amber 70-90%, red >90%
- Feature grid: Semantic Search, DNA, MCP Access, Priority Indexing
- Locked features show Pro badge + lock icon
- Loading skeleton while data fetches
- Uses useUserUsage hook (GET /users/usage, React Query)

Route: /dashboard/usage in Dashboard.tsx
Sidebar: BarChart3 icon + Usage nav link

210 lines, 4 sub-components (PlanCard, UsageBar, FeatureItem, UsageSkeleton).
All shadcn: Card, Badge, Separator, Skeleton. No custom UI.
@vercel

vercel Bot commented Mar 2, 2026

Copy link
Copy Markdown

@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@DevanshuNEU has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f314a0b and 8ab65c4.

📒 Files selected for processing (1)
  • frontend/src/pages/UsagePage.tsx
📝 Walkthrough

Walkthrough

Adds a new Usage page component and integrates it into the dashboard by adding a route and a sidebar navigation item; the page fetches and renders user usage, plan, resource limits, and feature availability with loading and error states.

Changes

Cohort / File(s) Summary
Dashboard Navigation
frontend/src/components/Dashboard.tsx, frontend/src/components/dashboard/Sidebar.tsx
Adds a /dashboard/usage route to DashboardRoutes and a "Usage" sidebar item (BarChart3 icon) linking to /dashboard/usage.
Usage Page Component
frontend/src/pages/UsagePage.tsx
New UsagePage export: fetches usage via useUserUsage, renders PlanCard, resource UsageBar rows, FeatureItem list, API cost info, loading skeleton, and simple error state; includes internal UI helpers and tier color mapping.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Router
  participant UsagePage
  participant Hook as useUserUsage
  participant API
  participant DB

  User->>Router: navigate /dashboard/usage
  Router->>UsagePage: render UsagePage
  UsagePage->>Hook: call useUserUsage(sessionToken, userId)
  Hook->>API: fetch /api/usage (auth)
  API->>DB: query usage data
  DB-->>API: return usage records
  API-->>Hook: return usage payload
  Hook-->>UsagePage: provide usage data
  UsagePage->>User: render plan, usage bars, features, or skeleton/error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A nibble of data, a hop and a cheer,
Charts and plan badges now appear near.
Bars that climb and features in view,
A rabbit says "use wisely" — and hops off to chew. 🥕

🚥 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 accurately describes the main change: a new Usage page with plan information, resource usage bars, and feature list. It is concise, specific, and directly matches the primary additions in 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
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/UsagePage.tsx`:
- Around line 38-41: Normalize usage.tier to a stable lowercase value and use
conservative defaults for features: when reading usage.tier (variable tier and
any checks like in render logic) convert toString().toLowerCase() and map known
synonyms ("free","pro","enterprise") to canonical keys before using as lookup
keys; for features (variable features / usage.features) set mcp_access default
to false and priority_indexing to false so missing fields don't grant access,
and keep repos and limits fallbacks as-is; update any conditional checks that
compare tier (e.g., badge color or free-plan messaging) to use the normalized
tier variable.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b19e67 and ef16a8e.

📒 Files selected for processing (3)
  • frontend/src/components/Dashboard.tsx
  • frontend/src/components/dashboard/Sidebar.tsx
  • frontend/src/pages/UsagePage.tsx

Comment thread frontend/src/pages/UsagePage.tsx
PlanCard: free users see a highlighted upgrade banner with
'Upgrade to Pro' button and Pro benefits summary. Pro/Enterprise
users see 'Active' label instead.

Cost placeholder: dashed-border card at bottom with TrendingUp icon.
Shows 'Token usage, cost breakdown by model, monthly spend -- coming
soon.' Sets user expectation for Phase 2 metering.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
frontend/src/pages/UsagePage.tsx (1)

39-42: ⚠️ Potential issue | 🟠 Major

Normalize tier and use conservative feature defaults.

Line 39 uses usage.tier directly for downstream comparisons/lookups, and Line 42 defaults mcp_access to true. This can mis-render plan state and accidentally grant feature access when fields are missing.

Suggested fix
+const normalizeTier = (value?: string) => {
+  const t = (value ?? 'free').toLowerCase()
+  if (t === 'enterprise' || t === 'pro' || t === 'free') return t
+  return 'free'
+}
-
-const tier = usage.tier || 'free'
+const tier = normalizeTier(usage.tier)
 const repos = usage.repositories || { current: 0, limit: 3 }
 const limits = usage.limits || { max_files_per_repo: 500, max_functions_per_repo: 2000 }
-const features = usage.features || { priority_indexing: false, mcp_access: true }
+const features = {
+  priority_indexing: usage.features?.priority_indexing ?? tier !== 'free',
+  mcp_access: usage.features?.mcp_access ?? false,
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/UsagePage.tsx` around lines 39 - 42, Normalize the usage
values: ensure tier is normalized (e.g., coerce to a string and toLowerCase()
with fallback 'free') before any downstream comparisons/lookups, and make
feature defaults conservative by changing the features fallback so mcp_access
defaults to false (keep priority_indexing false). Update the initialization of
tier, repos, limits, and features in UsagePage.tsx (the consts named tier,
repos, limits, features) to coerce/normalize inputs and avoid granting
mcp_access when the field is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/UsagePage.tsx`:
- Line 192: The progress bar forces a minimum width via style={{ width:
`${Math.max(pct, 2)}%` }}, causing 0 usage to render as non-zero; update the
expression to render 0% when pct is 0 (e.g. use `${pct > 0 ? Math.max(pct, 2) :
0}%`) so that in the UsagePage component the variable pct shows true zero usage
while still preserving a visible minimum for small non-zero values.
- Around line 149-152: The "Upgrade to Pro" Button in UsagePage renders without
an onClick/navigation, so users cannot start the upgrade flow; update the Button
(component named Button in UsagePage.tsx) to call the existing billing/upgrade
handler used elsewhere in this component (e.g., the upgrade or openBillingModal
function or the prop passed down for initiating billing) by adding an onClick
that invokes that handler (or navigates to the billing route) and ensure any
required props/state (like user plan or router) are imported/available in
UsagePage before wiring it up.

---

Duplicate comments:
In `@frontend/src/pages/UsagePage.tsx`:
- Around line 39-42: Normalize the usage values: ensure tier is normalized
(e.g., coerce to a string and toLowerCase() with fallback 'free') before any
downstream comparisons/lookups, and make feature defaults conservative by
changing the features fallback so mcp_access defaults to false (keep
priority_indexing false). Update the initialization of tier, repos, limits, and
features in UsagePage.tsx (the consts named tier, repos, limits, features) to
coerce/normalize inputs and avoid granting mcp_access when the field is missing.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef16a8e and f314a0b.

📒 Files selected for processing (1)
  • frontend/src/pages/UsagePage.tsx

Comment thread frontend/src/pages/UsagePage.tsx Outdated
Comment thread frontend/src/pages/UsagePage.tsx Outdated
Major layout improvements:
- Tier badge moved to header row (saves a whole card)
- Upgrade CTA is a slim banner, not a card-in-card
- Two-column grid: Resource Limits left, Features right
- Features as simple rows instead of bordered cards
- Cost placeholder horizontal (icon + text), not centered block
- Thinner progress bar (h-1.5 vs h-2)
- Less padding everywhere, more information density
- 215 lines, same data, half the vertical space
1. Progress bar: 0 repos now renders 0% width instead of 2% sliver
2. Upgrade button: opens pricing page in new tab instead of doing nothing
@vercel

vercel Bot commented Mar 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opencodeintel Ready Ready Preview, Comment Mar 2, 2026 10:27pm

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