Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added option to leave workspace
  • disallow write users from renaming workspace

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 16, 2026 8:25pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 16, 2026

Greptile Summary

This PR adds the ability for workspace members to leave workspaces and restricts workspace renaming to admin users only.

Key Changes:

  • Added "Leave" option to workspace context menu, visible to non-owners
  • Implemented handleLeaveWorkspace in the workspace management hook that calls the existing member removal API
  • Changed rename permission from write users to admin-only (disableRename={!contextCanAdmin} instead of !contextCanEdit)
  • Properly handles navigation after leaving by switching to the first remaining workspace

Implementation Quality:

  • Reuses existing /api/workspaces/members/[id] DELETE endpoint with proper authorization checks
  • API prevents leaving if user is the billing account or last admin
  • Clean prop threading through component hierarchy
  • Follows existing patterns for workspace operations (delete, duplicate, export)

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • The implementation reuses existing, well-tested member removal logic and follows established patterns. The rename permission change is a deliberate improvement to workspace security. Minor deduction for lack of automated tests, but manual testing was performed.
  • No files require special attention - implementation is clean and follows existing patterns

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/context-menu/context-menu.tsx Added leave workspace functionality to the context menu component with proper prop types and UI integration
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx Implemented leave workspace action handler and changed rename permission from write to admin-only, with owner check to conditionally show leave option
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx Wired up leave workspace functionality by passing handler and session user ID to WorkspaceHeader component

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextMenu
    participant WorkspaceHeader
    participant Sidebar
    participant useWorkspaceManagement
    participant API as /api/workspaces/members/[id]

    User->>ContextMenu: Right-click workspace
    ContextMenu->>WorkspaceHeader: Show leave option (if !isOwner)
    User->>ContextMenu: Click "Leave"
    ContextMenu->>WorkspaceHeader: handleLeaveAction()
    WorkspaceHeader->>Sidebar: onLeaveWorkspace(workspaceId)
    Sidebar->>useWorkspaceManagement: handleLeaveWorkspace(workspace)
    useWorkspaceManagement->>API: DELETE with sessionUserId
    API->>API: Check if user is billing account
    API->>API: Check if last admin
    API-->>useWorkspaceManagement: Success
    useWorkspaceManagement->>useWorkspaceManagement: Refresh workspace list
    useWorkspaceManagement->>useWorkspaceManagement: Switch to first remaining workspace
    useWorkspaceManagement-->>User: Navigate to new workspace
Loading

@waleedlatif1 waleedlatif1 merged commit c863125 into staging Jan 16, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/workspace-actions branch January 16, 2026 20:38
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.

2 participants