feat:Replace NEXT_PUBLIC_MOCK_MAINTAINER env flag with useUserRole hook - #303
Conversation
|
@Olajcodes is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
|
@Olajcodes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe bounty sidebar now uses ChangesSponsor role gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/bounty/bounty-sidebar.tsx`:
- Around line 85-87: The role-guard copy in bounty-sidebar’s sponsor checks is
stale: the alert text still says “Only maintainers” even though the logic now
uses isSponsor. Update the denial message in the affected guard blocks
(including the repeated check in the same component) to say “Only sponsors can
mark as completed” or equivalent, so the user-facing copy matches the new role
contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7b22cb49-f39e-4521-94d6-4a0a111fe96f
📒 Files selected for processing (1)
components/bounty/bounty-sidebar.tsx
Benjtalkshow
left a comment
There was a problem hiding this comment.
Clean change, all acceptance criteria from #274 are met, CI is green, tsc
and lint pass locally. One small thing: the file lost its trailing newline
("\ No newline at end of file" in the diff) — please add the newline back
on the closing brace so this matches the rest of the codebase. Also please
attach a screenshot showing the bounty sidebar for both a sponsor (Mark as
Completed visible) and a contributor (button hidden) so I can verify the
gating visually. Once those are in, ready to merge.
Benjtalkshow
left a comment
There was a problem hiding this comment.
All addressed cleanly — trailing newline is back and the CodeRabbit feedback is in. Local pnpm lint, pnpm tsc --noEmit, and pnpm build all pass, no NEXT_PUBLIC_MOCK_MAINTAINER or IS_MAINTAINER residue left. Just attach a screenshot of the bounty sidebar for both a sponsor (showing the Mark as Completed button) and a contributor (button hidden) so I can verify the role gating visually, then ready to merge.
Summary
Closes #274.
Replaces the
NEXT_PUBLIC_MOCK_MAINTAINERenvironment flag with the realuseUserRole()hook introduced in PR #254. The old constant was a dev shim that bypassed session-based role checks entirely — theconsole.warnblock in the file itself flagged it as something that must never reach production. This PR removes it and wires the sidebar to the actual authenticated session role.Changes
components/bounty/bounty-sidebar.tsxRemoved:
const IS_MAINTAINER = process.env.NEXT_PUBLIC_MOCK_MAINTAINER === "true";(line 32)console.warnguard block (lines 34–41) that acknowledged the shim was unsafe for productionAdded:
import { useUserRole } from "@/hooks/use-user-role";const role = useUserRole();— reads the role from the live session viaauthClient.useSession()const isSponsor = role === "sponsor";— replaces everyIS_MAINTAINERreference throughout the componentNo other files changed. No new env vars introduced.
Acceptance criteria
NEXT_PUBLIC_MOCK_MAINTAINERremains inbounty-sidebar.tsxsponsorrole and hidden forcontributorusersconsole.warnblock removedHow to test
Diff at a glance
{isSponsor
Summary by CodeRabbit