Skip to content

don't error on inivte when guest/ui changes on org modal#2127

Open
ignaciojimenezr wants to merge 1 commit into
mainfrom
error-inite
Open

don't error on inivte when guest/ui changes on org modal#2127
ignaciojimenezr wants to merge 1 commit into
mainfrom
error-inite

Conversation

@ignaciojimenezr
Copy link
Copy Markdown
Collaborator

  • we throwed errors when guest tried to create projects
  • changed ui for org modal a bit

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 16, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@dosubot dosubot Bot added the bug Something isn't working label May 16, 2026
@chelojimenez
Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Copy Markdown
Contributor

Internal preview

Preview URL will appear in Railway after the deploy finishes.
Deployed commit: d39e983
PR head commit: 37f2b56
Backend target: staging fallback.
Access is employee-only in non-production environments.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Review Change Stack

Walkthrough

This PR introduces role-based access control for project creation in the active organization and refines sidebar organization interactions. The App.tsx change disables project creation when the user's role in the active organization is not owner, admin, or member, with a distinct "no permission" message. The sidebar updates remove the settings gear from the org chip, relocate settings access to a button revealed on org-row hover, hide project member avatars by default until row hover, and adjust visual styling for section labels and component backgrounds to use bg-sidebar consistently.

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
mcpjam-inspector/client/src/components/sidebar/sidebar-context-switcher.tsx (1)

56-57: 💤 Low value

Update 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5fe12a6 and 37f2b56.

📒 Files selected for processing (3)
  • mcpjam-inspector/client/src/App.tsx
  • mcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-context-switcher.test.tsx
  • mcpjam-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

Comment on lines +1104 to +1114
const activeOrgMyRole = activeOrganizationId
? effectiveOrganizations.find((org) => org._id === activeOrganizationId)
?.myRole
: undefined;
const insufficientOrgRoleForCreate =
isAuthenticated &&
!!activeOrganizationId &&
activeOrgMyRole !== undefined &&
activeOrgMyRole !== "owner" &&
activeOrgMyRole !== "admin" &&
activeOrgMyRole !== "member";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 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 1

Repository: 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.tsx

Repository: 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.tsx

Repository: 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:

  1. Updating Organization.myRole to OrganizationMembershipRole (not string)
  2. Creating a constant for allowed roles to avoid magic strings and improve readability
  3. 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants