don't error on inivte when guest/ui changes on org modal#2127
don't error on inivte when guest/ui changes on org modal#2127ignaciojimenezr wants to merge 1 commit into
Conversation
ignaciojimenezr
commented
May 16, 2026
- we throwed errors when guest tried to create projects
- changed ui for org modal a bit
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
WalkthroughThis PR introduces role-based access control for project creation in the active organization and refines sidebar organization interactions. The Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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
🧹 Nitpick comments (1)
mcpjam-inspector/client/src/components/sidebar/sidebar-context-switcher.tsx (1)
56-57: 💤 Low valueUpdate stale comment.
The comment mentions "chip-level gear" but this element was removed in the current changes. Only the per-row gear in the organization popover remains.
📝 Suggested comment update
/** * Navigates to an organization's overview/billing page. - * Used by the chip-level gear and the per-row gear in the org popover. + * Used by the per-row settings button in the organization popover. */🤖 Prompt for 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. In `@mcpjam-inspector/client/src/components/sidebar/sidebar-context-switcher.tsx` around lines 56 - 57, The file comment in sidebar-context-switcher.tsx is stale—remove the reference to the removed "chip-level gear" and update the comment above the SidebarContextSwitcher (or surrounding component/function) to accurately describe that this element is used by the per-row gear in the organization popover only; locate the existing comment block in the SidebarContextSwitcher component and replace the phrase "chip-level gear and the per-row gear in the org popover" with a concise note mentioning only the per-row gear in the org popover.
🤖 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 `@mcpjam-inspector/client/src/App.tsx`:
- Around line 1104-1114: The role-check uses magic strings and a string-typed
myRole; change Organization.myRole to the OrganizationMembershipRole type,
replace the hardcoded strings in the insufficientOrgRoleForCreate check with a
small constant/set (e.g., ALLOWED_CREATE_ROLES or isRoleAllowed function) and
update the logic that computes activeOrgMyRole and insufficientOrgRoleForCreate
to use that typed enum/set (symbols: Organization.myRole,
OrganizationMembershipRole, activeOrgMyRole, insufficientOrgRoleForCreate); also
ensure the fallback when the org is not found remains explicit (undefined myRole
should not block creation).
---
Nitpick comments:
In `@mcpjam-inspector/client/src/components/sidebar/sidebar-context-switcher.tsx`:
- Around line 56-57: The file comment in sidebar-context-switcher.tsx is
stale—remove the reference to the removed "chip-level gear" and update the
comment above the SidebarContextSwitcher (or surrounding component/function) to
accurately describe that this element is used by the per-row gear in the
organization popover only; locate the existing comment block in the
SidebarContextSwitcher component and replace the phrase "chip-level gear and the
per-row gear in the org popover" with a concise note mentioning only the per-row
gear in the org popover.
🪄 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: c551c5fb-5dbc-4689-92b6-d1c189965695
📒 Files selected for processing (3)
mcpjam-inspector/client/src/App.tsxmcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-context-switcher.test.tsxmcpjam-inspector/client/src/components/sidebar/sidebar-context-switcher.tsx
💤 Files with no reviewable changes (1)
- mcpjam-inspector/client/src/components/sidebar/tests/sidebar-context-switcher.test.tsx
| const activeOrgMyRole = activeOrganizationId | ||
| ? effectiveOrganizations.find((org) => org._id === activeOrganizationId) | ||
| ?.myRole | ||
| : undefined; | ||
| const insufficientOrgRoleForCreate = | ||
| isAuthenticated && | ||
| !!activeOrganizationId && | ||
| activeOrgMyRole !== undefined && | ||
| activeOrgMyRole !== "owner" && | ||
| activeOrgMyRole !== "admin" && | ||
| activeOrgMyRole !== "member"; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify role value usage and type definitions across the codebase
# Search for role type definitions
echo "=== Searching for role type definitions ==="
rg -n --type=ts --type=tsx 'type.*[Rr]ole.*=|interface.*[Rr]ole' -A 3
# Search for role value assignments and checks
echo -e "\n=== Searching for myRole usage patterns ==="
rg -n --type=ts --type=tsx '\.myRole\s*===' -C 2
# Search for organization member role references
echo -e "\n=== Searching for organization role strings ==="
rg -n --type=ts --type=tsx '"(owner|admin|member|guest|viewer)"' --glob '*organization*' -C 1Repository: MCPJam/inspector
Length of output: 300
🏁 Script executed:
#!/bin/bash
# Verify role value usage and type definitions across the codebase
# Using corrected rg syntax without unsupported file types
# Search for role type definitions
echo "=== Searching for role type definitions ==="
rg -n 'type.*[Rr]ole.*=|interface.*[Rr]ole' --type=ts -A 3
# Search for role value assignments and enum definitions
echo -e "\n=== Searching for role value constants/enums ==="
rg -n '"owner"|"admin"|"member"|"guest"' --type=ts -B 2 -A 1
# Search for myRole property definitions and usage
echo -e "\n=== Searching for myRole property ==="
rg -n 'myRole\s*[?:]' --type=ts -B 1 -A 1
# Find organization-related files that might define roles
echo -e "\n=== Organization-related files ==="
fd -e ts -e tsx 'org|role' mcpjam-inspector/Repository: MCPJam/inspector
Length of output: 50374
🏁 Script executed:
#!/bin/bash
# Focused search on role type definitions and usage
echo "=== Role type definitions ==="
rg -n 'type.*MembershipRole|type.*ProjectRole|type.*OrganizationRole' --type=ts
echo -e "\n=== Organization interface - myRole property ==="
rg -n -A 5 'interface Organization' mcpjam-inspector/client/src/hooks/useOrganizations.ts
echo -e "\n=== How myRole is used in the codebase ==="
rg -n '\.myRole' mcpjam-inspector/client/src/ --type=ts | head -20
echo -e "\n=== Check if role types are imported/used in App.tsx ==="
rg -n 'OrganizationMembershipRole\|import.*useOrganizations' mcpjam-inspector/client/src/App.tsxRepository: MCPJam/inspector
Length of output: 1660
🏁 Script executed:
#!/bin/bash
# Find complete Organization interface
echo "=== Complete Organization interface ==="
sed -n '6,25p' mcpjam-inspector/client/src/hooks/useOrganizations.ts
echo -e "\n=== Search for guest role checks ==="
rg -n '"guest"' mcpjam-inspector/client/src/ --type=ts -B 2 -A 2
echo -e "\n=== Check if guest role is intentionally allowed ==="
rg -n 'guest.*create\|create.*guest' mcpjam-inspector/client/src/ --type=ts -i
echo -e "\n=== Full insufficientOrgRoleForCreate logic context ==="
sed -n '1100,1120p' mcpjam-inspector/client/src/App.tsxRepository: MCPJam/inspector
Length of output: 18995
Use the OrganizationMembershipRole type for type safety instead of hardcoded role strings.
The role-based gating uses hardcoded strings "owner", "admin", and "member" without type safety. While the logic correctly blocks users with insufficient roles (including the valid "guest" role), the myRole property is typed as string in the Organization interface instead of OrganizationMembershipRole. This creates maintenance risk if role values change or expand. Consider:
- Updating
Organization.myRoletoOrganizationMembershipRole(notstring) - Creating a constant for allowed roles to avoid magic strings and improve readability
- Explicitly documenting the undefined fallback behavior (when org is not found, creation is not blocked)
🤖 Prompt for 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.
In `@mcpjam-inspector/client/src/App.tsx` around lines 1104 - 1114, The role-check
uses magic strings and a string-typed myRole; change Organization.myRole to the
OrganizationMembershipRole type, replace the hardcoded strings in the
insufficientOrgRoleForCreate check with a small constant/set (e.g.,
ALLOWED_CREATE_ROLES or isRoleAllowed function) and update the logic that
computes activeOrgMyRole and insufficientOrgRoleForCreate to use that typed
enum/set (symbols: Organization.myRole, OrganizationMembershipRole,
activeOrgMyRole, insufficientOrgRoleForCreate); also ensure the fallback when
the org is not found remains explicit (undefined myRole should not block
creation).