Skip to content

fix: repo limit per tier -- Enterprise users were blocked at free limit#278

Merged
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/repo-limit-per-tier
Mar 5, 2026
Merged

fix: repo limit per tier -- Enterprise users were blocked at free limit#278
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/repo-limit-per-tier

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

Bug

Add Repository and Import from GitHub buttons were disabled for Enterprise users with 3 repos. The check used MAX_FREE_REPOS (hardcoded to 1 after PR #277) for ALL users regardless of tier.

Fix

RepoListView now takes a maxRepos prop derived from GET /users/usage (via useUserUsage hook). Each tier gets its actual limit: Free=1, Pro=5, Enterprise=10.

Files

  • DashboardHome.tsx: derives maxRepos from usage, passes to RepoListView and GitHubRepoSelector
  • RepoListView.tsx: replaced MAX_FREE_REPOS with maxRepos prop

2 files, +8 -5 lines.

Summary by CodeRabbit

  • New Features
    • Repository import/selection limits now reflect your account usage for a personalized limit.
    • Top navigation displays your plan label derived from current usage (e.g., "Free Plan").
    • Usage data now includes repository counts and feature flags (e.g., priority indexing, MCP access) so UI controls adapt to your entitlements.

Bug: Add Repository button used MAX_FREE_REPOS (hardcoded to 1) for
ALL users. Enterprise users with 3 repos hit 3 >= 1 and got blocked.

Fix: RepoListView now takes maxRepos prop from useUserUsage hook.
DashboardHome derives maxRepos from usage?.repositories?.limit.
Free gets 1, Pro gets 5, Enterprise gets 10 -- from the backend.

Also fixed GitHubRepoSelector maxSelectable to use same dynamic limit.

Removed MAX_FREE_REPOS import from both DashboardHome and RepoListView.
@vercel

vercel Bot commented Mar 5, 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 5, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e07018c2-cc1c-4ff7-8844-dbb4f55cc1ef

📥 Commits

Reviewing files that changed from the base of the PR and between 55d039e and 950ef1a.

📒 Files selected for processing (1)
  • frontend/src/components/dashboard/TopNav.tsx

📝 Walkthrough

Walkthrough

Replaces the hard-coded MAX_FREE_REPOS with a dynamic maxRepos derived from usage?.repositories?.limit, threads it from DashboardHome into RepoListView and GitHub selector, and expands useUserUsage to include repositories and features. TopNav uses usage-derived tier.

Changes

Cohort / File(s) Summary
Dashboard components
frontend/src/components/dashboard/DashboardHome.tsx, frontend/src/components/dashboard/RepoListView.tsx, frontend/src/components/dashboard/GitHubRepoSelector.tsx
Replaced MAX_FREE_REPOS usage with a maxRepos prop derived from usage?.repositories?.limit; added maxRepos: number to RepoListView props and passed it into the GitHub selector (maxSelectable) and button disabled conditions.
Top navigation
frontend/src/components/dashboard/TopNav.tsx
Switched tier derivation to use useUserUsage data (usage.tier) instead of session metadata; removed imports/types tied to static tier limits.
User usage hook
frontend/src/hooks/useCachedQuery.ts
Expanded useUserUsage return shape to include repositories: { current, limit, display } and features: { priority_indexing, mcp_access } while preserving existing tier/limits fields.
Manifest
package.json
Manifest entry updated (present in diff).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client
participant DashboardHome
participant useUserUsage as "useUserUsage (hook)"
participant RepoListView
participant GitHubSelector as "GitHubRepoSelector"

Client->>DashboardHome: render
DashboardHome->>useUserUsage: fetch usage (access token, user id)
useUserUsage-->>DashboardHome: return usage { repositories, features, tier, limits }
DashboardHome->>RepoListView: render(props..., maxRepos = usage.repositories.limit)
RepoListView->>GitHubSelector: render(maxSelectable = maxRepos)
GitHubSelector-->>Client: UI respects maxSelectable

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped from config into code,
Pulled limits from usage down the road,
Props in paw, I pass them round,
Repos counted, caps unbound,
Hooray — a tidy, user-wise load! 🎋

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 clearly summarizes the main fix: repo limits are now per-tier instead of hardcoded, resolving the bug where Enterprise users were incorrectly blocked at the free tier limit.

✏️ 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/components/dashboard/DashboardHome.tsx`:
- Line 27: The return type for the useUserUsage hook in useCachedQuery.ts is
missing repositories and features fields causing TS errors when
DashboardHome.tsx reads usage.repositories.limit; update the useUserUsage return
type (the interface/type used by the useUserUsage hook) to include repositories:
{ current: number; limit: number; display: string }, limits: {
max_files_per_repo: number; max_functions_per_repo: number;
playground_searches_per_day: number | null }, and features: { priority_indexing:
boolean; mcp_access: boolean } while keeping tier: string so the hook and any
callers like DashboardHome.tsx compile cleanly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5255fe45-abc3-456b-8674-c55cc312b333

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf0589 and cb61792.

📒 Files selected for processing (2)
  • frontend/src/components/dashboard/DashboardHome.tsx
  • frontend/src/components/dashboard/RepoListView.tsx

Comment thread frontend/src/components/dashboard/DashboardHome.tsx
Bug: TopNav read tier from session.user_metadata.tier (stale JWT).
When admin bumps a user to Enterprise, the JWT doesn't update until
re-login. So TopNav still showed 'Free Plan' even after upgrade.

Fix: TopNav now uses useUserUsage hook (GET /users/usage) which reads
the actual tier from user_profiles table. Changes reflect immediately
after admin dashboard tier update.

Also: added repositories and features to useUserUsage return type
to match the actual backend response shape.

@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/components/dashboard/TopNav.tsx`:
- Around line 29-30: The code currently defaults tier to 'free' causing a brief
mislabel for paid users; update TopNav.tsx so tier/tierLabel are computed only
when usage?.tier is defined (e.g., if (usage?.tier) { const tier = usage.tier;
const tierLabel = `${tier.charAt(0).toUpperCase()}${tier.slice(1)} Plan`; } else
{ const tierLabel = 'Loading…' } ), removing the fallback of 'free' and showing
a neutral/loading label until usage?.tier resolves; reference the variables
tier, tierLabel and the usage?.tier check when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d1d20873-f81e-43c7-a582-5a19750a4343

📥 Commits

Reviewing files that changed from the base of the PR and between cb61792 and 55d039e.

📒 Files selected for processing (2)
  • frontend/src/components/dashboard/TopNav.tsx
  • frontend/src/hooks/useCachedQuery.ts

Comment thread frontend/src/components/dashboard/TopNav.tsx Outdated
Enterprise users saw 'Free Plan' briefly before useUserUsage resolved.
Now shows empty string until backend responds with actual tier.
@vercel

vercel Bot commented Mar 5, 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 5, 2026 9:03pm

@DevanshuNEU DevanshuNEU merged commit c3288da into OpenCodeIntel:main Mar 5, 2026
7 checks passed
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