Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added invitations query hook, migrated all tool files to use absolute imports

Type of Change

  • Performance
  • Code hygiene

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 31, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jan 31, 2026 1:39am

Request Review

@waleedlatif1
Copy link
Collaborator Author

@greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 31, 2026

Greptile Overview

Greptile Summary

This PR introduces a centralized invitations query hook and migrates 269 tool files from relative to absolute imports for improved maintainability and consistency.

Key Changes

  • New Invitations Query Hook: Added hooks/queries/invitations.ts with comprehensive React Query-based hooks for invitation management including batch operations, resending, canceling, and member removal with proper cache invalidation
  • Workspace Permissions Refactor: Migrated workspace permissions logic from legacy hooks to centralized query modules with improved cache key hierarchy and better integration with TanStack Query
  • Import Migration: Converted all tool files (a2a, apify, google_groups, incidentio, intercom, kalshi, mailchimp, shopify, similarweb, spotify, stagehand, typeform, wealthbox, wordpress, zendesk) to use absolute imports following project standards
  • Code Cleanup: Removed unused logger instances from multiple tool files and deprecated hooks (use-slack-accounts.ts, use-workspace-permissions.ts)
  • Biome Config: Simplified formatter configuration by removing explicit includes array

Technical Improvements

  • Centralized invitation state management with TanStack Query
  • Proper cache invalidation patterns across workspace and invitation operations
  • Improved type safety with explicit response interfaces
  • Eliminated direct API calls in components in favor of declarative hooks
  • Better separation of concerns between UI and data fetching logic

Confidence Score: 5/5

  • This PR is safe to merge - it's a well-executed refactoring with no logical issues
  • The changes are entirely code hygiene improvements (import migrations, hook consolidation) with no behavioral modifications. The new invitations hook follows established patterns, properly manages cache invalidation, and maintains type safety throughout
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/hooks/queries/invitations.ts added comprehensive invitations query hook with proper cache management, batch operations, and mutations for workspace member management
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/components/invite-modal/invite-modal.tsx refactored to use new invitation hooks, simplified state management and eliminated direct API calls in favor of centralized mutations
apps/sim/hooks/queries/workspace.ts enhanced with new workspace permissions query hook and improved cache key hierarchy
apps/sim/hooks/use-workspace-permissions.ts removed deprecated hook, functionality moved to centralized query module at hooks/queries/workspace.ts
apps/sim/app/workspace/[workspaceId]/providers/workspace-permissions-provider.tsx updated to use new workspace permissions query hook and simplified offline mode management

Sequence Diagram

sequenceDiagram
    participant User
    participant InviteModal
    participant InvitationsHooks
    participant TanstackQuery
    participant API
    participant PermissionsProvider
    
    User->>InviteModal: Open invite modal
    InviteModal->>InvitationsHooks: usePendingInvitations(workspaceId)
    InvitationsHooks->>TanstackQuery: useQuery(invitationKeys.list())
    TanstackQuery->>API: GET /api/workspaces/invitations
    API-->>TanstackQuery: Return pending invitations
    TanstackQuery-->>InviteModal: Display existing invitations
    
    User->>InviteModal: Add email(s) and set permissions
    User->>InviteModal: Click "Invite"
    InviteModal->>InvitationsHooks: useBatchSendWorkspaceInvitations()
    InvitationsHooks->>TanstackQuery: useMutation()
    TanstackQuery->>API: POST /api/workspaces/invitations (parallel)
    API-->>TanstackQuery: Return results
    TanstackQuery->>TanstackQuery: Invalidate invitationKeys.list()
    TanstackQuery-->>InviteModal: Success/failure results
    InviteModal-->>User: Show updated invitation list
    
    User->>InviteModal: Modify member permissions
    User->>InviteModal: Click "Save Changes"
    InviteModal->>InvitationsHooks: useUpdateWorkspacePermissions()
    InvitationsHooks->>TanstackQuery: useMutation()
    TanstackQuery->>API: PATCH /api/workspaces/{id}/permissions
    API-->>TanstackQuery: Return updated permissions
    TanstackQuery->>TanstackQuery: Invalidate workspaceKeys.permissions()
    TanstackQuery->>PermissionsProvider: Refresh permissions context
    PermissionsProvider-->>InviteModal: Updated permissions
    InviteModal-->>User: Show success
    
    User->>InviteModal: Cancel invitation
    InviteModal->>InvitationsHooks: useCancelWorkspaceInvitation()
    InvitationsHooks->>TanstackQuery: useMutation()
    TanstackQuery->>API: DELETE /api/workspaces/invitations/{id}
    API-->>TanstackQuery: Confirmation
    TanstackQuery->>TanstackQuery: Invalidate invitationKeys.list()
    TanstackQuery-->>InviteModal: Removed from list
    InviteModal-->>User: Show updated list
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@waleedlatif1 waleedlatif1 merged commit 4109fee into staging Jan 31, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/im branch January 31, 2026 02:39
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