fix: repo limit per tier -- Enterprise users were blocked at free limit#278
Conversation
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.
|
@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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReplaces the hard-coded Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
frontend/src/components/dashboard/DashboardHome.tsxfrontend/src/components/dashboard/RepoListView.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.
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
frontend/src/components/dashboard/TopNav.tsxfrontend/src/hooks/useCachedQuery.ts
Enterprise users saw 'Free Plan' briefly before useUserUsage resolved. Now shows empty string until backend responds with actual tier.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
maxReposprop derived fromGET /users/usage(via useUserUsage hook). Each tier gets its actual limit: Free=1, Pro=5, Enterprise=10.Files
2 files, +8 -5 lines.
Summary by CodeRabbit