Skip to content

Dashboard pending team invitations#961

Merged
BilalG1 merged 3 commits intodevfrom
dashboard-pending-team-invitations
Oct 17, 2025
Merged

Dashboard pending team invitations#961
BilalG1 merged 3 commits intodevfrom
dashboard-pending-team-invitations

Conversation

@BilalG1
Copy link
Contributor

@BilalG1 BilalG1 commented Oct 17, 2025

Screenshot 2025-10-16 at 7 22 51 PM

High-level PR Summary

This PR enhances the team invitation management in the dashboard by replacing a server action with a client-side implementation that displays pending team invitations in a redesigned dialog. The new dialog shows current dashboard admin seat usage (active users plus pending invitations versus the limit), lists all pending invitations with the ability to revoke them, and provides an upgrade path when the team reaches capacity. The implementation uses React Suspense for loading states and moves invitation logic to the client using the admin app API.

⏱️ Estimated Review Time: 15-30 minutes

💡 Review Order Suggestion
Order File Path
1 packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts
2 apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
3 apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx

Need help? Join our Discord

Analyze latest changes

Summary by CodeRabbit

  • New Features

    • Team invitation now uses a modal dialog interface
    • Added upgrade prompt when team reaches capacity limits
  • Bug Fixes

    • Fixed invitation list not updating after revocation
  • Improvements

    • Enhanced error handling with user-facing notifications for invitation failures
    • Improved form validation feedback during team member invitations

@vercel
Copy link

vercel bot commented Oct 17, 2025

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

Project Deployment Preview Comments Updated (UTC)
stack-backend Ready Ready Preview Comment Oct 17, 2025 2:28am
stack-dashboard Ready Ready Preview Comment Oct 17, 2025 2:28am
stack-demo Ready Ready Preview Comment Oct 17, 2025 2:28am
stack-docs Ready Ready Preview Comment Oct 17, 2025 2:28am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The pull request migrates team member invitation from an inline form dialog to a modal-based UI. It removes the server-side inviteUser function and shifts data flow from prop-passing to direct adminApp access. A new TeamAddUserDialogContent component encapsulates invitation logic and conditional upgrade handling. Cache invalidation is added after revoking team invitations.

Changes

Cohort / File(s) Summary
Modal-based invitation UI
apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx
Replaced inline FormDialog with Dialog primitive containing new TeamAddUserDialogContent component; shifted data fetching to use adminApp context; added Suspense wrapper and error/success toast handling; updated PageClient signature to accept no props.
Server-side invitation removal
apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
Removed inviteUser server function and eliminated its prop passing to PageClient; simplified parent component.
Cache refresh after revoke
packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts
Added cache invalidation for team invitations after revoking a server team invitation.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Modal Dialog
    participant Content as TeamAddUserDialogContent
    participant AdminApp as adminApp
    participant API as Backend

    User->>UI: Click invite trigger
    UI->>Content: Open modal with Suspense
    Content->>AdminApp: Fetch team data
    AdminApp-->>Content: Team, users, invitations
    User->>Content: Enter email
    Content->>Content: Validate email
    alt User at capacity
        Content->>Content: Show upgrade option
        User->>Content: Click upgrade
        Content->>API: createCheckoutUrl()
    else Within capacity
        User->>Content: Click invite
        Content->>API: Submit invitation
        alt Success
            API-->>Content: Success
            Content-->>User: Toast notification
        else Error
            API-->>Content: Error
            Content-->>User: Error message & toast
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes involve refactoring a dialog flow into a modal-based component with new props signatures, shifting data access patterns from prop-passing to context-based retrieval via adminApp, and introducing cache invalidation logic. While individually straightforward, the heterogeneous nature across files (UI component restructuring, server function removal, cache handling) and the signature changes to consumed components require careful review for potential breakage.

Possibly related PRs

  • more visible invite team members #932: Directly modifies the same team invitation flow in page-client.tsx, migrating to modal/Dialog UI and centralizing admin-user fetching and upgrade handling.

Suggested reviewers

  • N2D4

Poem

🐰 A modal blooms where forms once lay,
Invitations hop a modern way,
Cache refreshed with every revoke,
No server calls—just context spoke,
Dialog dances, dialogs done!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Dashboard pending team invitations" clearly and directly reflects the main objective of the changeset. The raw summary confirms that the PR's primary focus is implementing a client-side dialog-based UI to display and manage pending team invitations in the dashboard, replacing a previous server action approach. The title is specific and concise, avoiding generic or vague terminology, and accurately conveys the feature being introduced without being overly broad.
Description Check ✅ Passed The PR description exceeds the minimal template requirements and provides a comprehensive overview of the changes. It includes a well-structured high-level summary explaining what was changed (replacing a server action with a client-side implementation), why it matters (showing seat usage and pending invitations), how it was implemented (React Suspense and admin app API), and practical guidance like estimated review time and a suggested review order for files. The description is specific and substantive, clearly communicating the technical approach and user-facing improvements without being vague.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dashboard-pending-team-invitations

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6a2ab5 and d0d75eb.

📒 Files selected for processing (3)
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx (3 hunks)
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx (1 hunks)
  • packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
packages/template/**

📄 CodeRabbit inference engine (AGENTS.md)

When modifying the SDK copies, make changes in packages/template (source of truth)

Files:

  • packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Prefer ES6 Map over Record when representing key–value collections

Files:

  • packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx
{apps/dashboard,apps/dev-launchpad,packages/stack-ui,packages/react}/**/*.{tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

For blocking alerts and errors in UI, do not use toast notifications; use alerts instead

Files:

  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx
{apps/dashboard,apps/dev-launchpad,packages/stack-ui,packages/react}/**/*.{tsx,jsx,css}

📄 CodeRabbit inference engine (AGENTS.md)

Keep hover/click animations snappy; avoid pre-transition delays on hover and apply transitions after the action (e.g., fade-out on hover end)

Files:

  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
  • apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx
🧬 Code graph analysis (2)
apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx (1)
apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx (1)
  • PageClient (16-121)
apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx (6)
packages/template/src/lib/stack-app/teams/index.ts (1)
  • Team (36-50)
packages/template/src/lib/stack-app/apps/interfaces/admin-app.ts (2)
  • StackAdminApp (23-89)
  • StackAdminApp (97-97)
packages/stack-ui/src/components/ui/dialog.tsx (5)
  • Dialog (122-122)
  • DialogContent (125-125)
  • DialogHeader (128-128)
  • DialogTitle (131-131)
  • DialogFooter (127-127)
packages/stack-ui/src/components/ui/use-toast.tsx (1)
  • toast (195-195)
packages/stack-ui/src/components/ui/input.tsx (1)
  • Input (10-41)
packages/stack-ui/src/components/ui/skeleton.tsx (1)
  • Skeleton (18-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: all-good
  • GitHub Check: docker
  • GitHub Check: Vercel Agent Review
  • GitHub Check: check_prisma_migrations (22.x)
  • GitHub Check: lint_and_build (latest)
  • GitHub Check: docker
  • GitHub Check: restart-dev-and-test
  • GitHub Check: setup-tests
  • GitHub Check: build (22.x)
  • GitHub Check: build (22.x)
  • GitHub Check: Security Check
🔇 Additional comments (8)
packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts (1)

735-738: LGTM! Essential cache invalidation added.

The cache refresh after revoking the invitation ensures that components using team.useInvitations() (lines 809-812) immediately reflect the updated state. This follows the established pattern in the codebase (e.g., line 802 for invitation creation, lines 787 and 794 for team membership changes).

apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx (6)

16-121: LGTM! Clean refactor to no-props component.

The removal of the inviteUser prop and migration to a Dialog-based UI is well-structured. The component correctly uses React hooks and passes the adminApp from projects[0].app to the TeamAddUserDialog component.


128-162: LGTM! Proper Dialog implementation with Suspense.

The Dialog component correctly manages open/close state and uses Suspense for loading states with an appropriate skeleton fallback.


181-200: Good error handling pattern.

The error handling properly distinguishes between validation errors (displayed inline via setFormError) and runtime errors (displayed as toasts). The validation logic correctly uses the inviteFormSchema and clears the form on success.


202-213: LGTM! Proper checkout flow implementation.

The upgrade handler correctly creates a checkout URL and navigates to it, with appropriate error handling.


295-331: LGTM! Skeleton component properly mirrors content structure.

The skeleton loading state correctly represents the main dialog content with appropriate placeholders and disabled inputs.


177-189: Verify server-side seat limit enforcement for concurrent team invitations.

The client-side capacity check prevents the invite button when at capacity, but the concern about race conditions when multiple admins invite simultaneously is valid. Tests show no verification of seat limit enforcement on the server endpoint (/api/v1/team-invitations/send-code). Ensure the backend validates that invitations cannot exceed the team's seat limit to prevent concurrent admins from bypassing the capacity check.

apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx (1)

29-29: LGTM! Correct removal of server-side invitation logic.

The removal of the inviteUser prop and rendering PageClient without props correctly aligns with the refactoring that moved invitation logic to the client side using adminApp.


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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Oct 17, 2025

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on b6a2ab5..c26d916

  Severity     Location     Issue     Delete  
High apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page-client.tsx:169 Null pointer dereference
✅ Files analyzed, no issues (2)

apps/dashboard/src/app/(main)/(protected)/(outside-dashboard)/projects/page.tsx
packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts

@BilalG1 BilalG1 merged commit 4ed486b into dev Oct 17, 2025
28 checks passed
@BilalG1 BilalG1 deleted the dashboard-pending-team-invitations branch October 17, 2025 02:38
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on c26d916..d0d75eb

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (31)

.vscode/settings.json
apps/backend/src/auto-migrations/index.tsx
apps/backend/src/oauth/model.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/layout.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/payments/products/layout.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/payments/products/page-client-catalogs-view.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/use-admin-app.tsx
apps/dashboard/src/app/(main)/purchase/[code]/page-client.tsx
apps/dashboard/src/components/data-table/user-table.tsx
apps/dashboard/src/components/link.tsx
apps/dashboard/src/components/payments/checkout.tsx
apps/dashboard/src/lib/prefetch/hook-prefetcher.tsx
apps/dashboard/src/lib/prefetch/url-prefetcher.tsx
apps/e2e/tests/backend/backend-helpers.ts
apps/e2e/tests/backend/endpoints/api/v1/payments/validate-code.test.ts
apps/e2e/tests/js/inheritance.test.ts
examples/convex/stack/server.tsx
packages/init-stack/src/index.ts
packages/stack-shared/src/config/schema.ts
packages/stack-shared/src/utils/caches.tsx
packages/stack-shared/src/utils/globals.tsx
packages/stack-shared/src/utils/react.tsx
packages/stack-shared/src/utils/regex.tsx
packages/template/src/lib/hooks.tsx
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts
packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts
packages/template/src/lib/stack-app/apps/implementations/common.ts
packages/template/src/lib/stack-app/apps/implementations/server-app-impl.ts
packages/template/src/lib/stack-app/apps/interfaces/admin-app.ts
packages/template/src/lib/stack-app/apps/interfaces/client-app.ts

@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 2025
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.

1 participant