Skip to content

Fix project transfers#926

Merged
N2D4 merged 2 commits intodevfrom
fix-project-transfers
Oct 4, 2025
Merged

Fix project transfers#926
N2D4 merged 2 commits intodevfrom
fix-project-transfers

Conversation

@N2D4
Copy link
Contributor

@N2D4 N2D4 commented Oct 4, 2025

High-level PR Summary

This PR refactors the project transfer functionality by moving the transferProject method from the Project object to the User object. The implementation is relocated from the admin interface (StackAdminInterface) to the client interface (StackClientInterface), and the dashboard now calls user.transferProject() instead of project.transfer(). This change maintains the same underlying API call but reorganizes the ownership and invocation pattern for better architectural alignment.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 packages/template/src/lib/stack-app/users/index.ts
2 packages/stack-shared/src/interface/client-interface.ts
3 packages/stack-shared/src/interface/admin-interface.ts
4 packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts
5 packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts
6 apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx

Need help? Join our Discord


Important

Refactor project transfer logic to use StackClientInterface instead of StackAdminInterface, updating relevant methods and interfaces.

  • Behavior:
    • Refactor project transfer logic to use StackClientInterface.transferProject() instead of StackAdminInterface.transferProject().
    • Update handleTransfer in page-client.tsx to use user.transferProject().
  • Interface Changes:
    • Remove transferProject() from StackAdminInterface in admin-interface.ts.
    • Add transferProject() to StackClientInterface in client-interface.ts.
  • Implementation:
    • Update _StackAdminAppImplIncomplete and _StackClientAppImplIncomplete to use the new transferProject() method.
    • Remove transfer() method from admin-app-impl.ts.
    • Add transferProject() method to client-app-impl.ts for handling project transfers.
  • Misc:
    • Update InternalUserExtra type in users/index.ts to include transferProject() method.

This description was created by Ellipsis for efcac6d. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Internal users can now transfer a project to another team directly, with the view auto-refreshing after completion.
  • Refactor

    • Project transfer has moved from the admin app to the internal user context.
    • Dashboard project settings updated to use the new transfer flow; the page reloads after a transfer to reflect changes.

Copilot AI review requested due to automatic review settings October 4, 2025 05:50
@cursor
Copy link

cursor bot commented Oct 4, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 10.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@vercel
Copy link

vercel bot commented Oct 4, 2025

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

Project Deployment Preview Comments Updated (UTC)
stack-backend Building Building Preview Comment Oct 4, 2025 5:50am
stack-dashboard Building Building Preview Comment Oct 4, 2025 5:50am
stack-demo Building Building Preview Comment Oct 4, 2025 5:50am
stack-docs Building Building Preview Comment Oct 4, 2025 5:50am

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the project transfer functionality by moving the transfer method from the project object to the user object. The change improves the API design by making it clearer that project transfers are user-initiated actions.

Key changes:

  • Moved transferProject method from project interface to user interface
  • Updated the implementation to use client interface instead of admin interface
  • Modified the dashboard to call the new user-based transfer method

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/template/src/lib/stack-app/users/index.ts Added transferProject method to user interface type definition
packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts Implemented transferProject method in client app using client interface
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts Removed project's transfer method and unused import
packages/stack-shared/src/interface/client-interface.ts Added transferProject method to client interface for internal projects
packages/stack-shared/src/interface/admin-interface.ts Removed transferProject method from admin interface
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx Updated to use user's transferProject method instead of project's transfer method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@N2D4 N2D4 merged commit d09496d into dev Oct 4, 2025
9 of 20 checks passed
@N2D4 N2D4 deleted the fix-project-transfers branch October 4, 2025 05:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Project transfer capability is shifted from the admin interface to the client/internal user path. The dashboard now calls user.transferProject(project.id, teamId). Admin-side transfer method is removed. Client interface and internal user surface gain transferProject, which posts to /internal/projects/transfer and refreshes project state.

Changes

Cohort / File(s) Summary
Dashboard usage update
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx
Replace project.transfer(...) with user.transferProject(project.id, selectedTeamId); reload behavior and error handling unchanged.
Admin transfer removal
packages/stack-shared/src/interface/admin-interface.ts, packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts
Remove admin-side project transfer method and its implementation; no other admin interface changes.
Client transfer introduction
packages/stack-shared/src/interface/client-interface.ts, packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts
Add StackClientInterface.transferProject(session, projectIdToTransfer, newTeamId) posting to /internal/projects/transfer; implement InternalUserExtra-backed method calling interface then refreshing project.
User API surface extension
packages/template/src/lib/stack-app/users/index.ts
Add InternalUserExtra.transferProject(projectIdToTransfer, newTeamId): Promise.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant D as Dashboard Page
  participant IUX as InternalUserExtra
  participant CI as StackClientInterface
  participant S as Server (/internal/projects/transfer)

  U->>D: Trigger project transfer (select team)
  D->>IUX: transferProject(projectId, newTeamId)
  IUX->>CI: transferProject(session, projectId, newTeamId)
  CI->>S: POST { project_id, new_team_id }
  S-->>CI: 200 OK
  CI-->>IUX: void
  IUX->>IUX: app._refreshProject()
  IUX-->>D: resolved
  D->>D: reload UI (existing behavior)
  note over D,IUX: Flow moved from admin path to client/internal user path
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump the keys with whiskered flair,
A project hops from here to there.
Admin burrow, quiet now—
Client tunnels take the plow.
POST and refresh, quick as a blink,
New-team clover in a single link.
Boing! Another tidy sync.

✨ 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 fix-project-transfers

📜 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 f21cfda and efcac6d.

📒 Files selected for processing (6)
  • apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx (1 hunks)
  • packages/stack-shared/src/interface/admin-interface.ts (0 hunks)
  • packages/stack-shared/src/interface/client-interface.ts (1 hunks)
  • packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts (1 hunks)
  • packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts (1 hunks)
  • packages/template/src/lib/stack-app/users/index.ts (1 hunks)

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
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.

Greptile Overview

Summary

This PR refactors project transfer functionality in the Stack Auth system by moving the responsibility from the admin interface to the user interface. The changes implement a cleaner API design where users initiate project transfers rather than projects being transferred through admin methods.

The key architectural change moves the transferProject method from the StackAdminInterface class to the user interface, making it available through InternalUserExtra. This is reflected in the dashboard where the call pattern changes from project.transfer(user, selectedTeamId) to user.transferProject(project.id, selectedTeamId). The refactoring maintains the same underlying API endpoint (/internal/projects/transfer) but routes it through the client interface instead of the admin interface.

The implementation adds the method to multiple layers: the type definition in InternalUserExtra, the client interface implementation with proper validation (ensuring it's only called on internal projects), and the client app implementation that handles the interface call and refreshes project data. The admin project interface has its transfer method completely removed, consolidating all transfer functionality under the user object.

Important Files Changed

Changed Files
Filename Score Overview
packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts 3/5 Added transferProject method to internal user interface with basic implementation
packages/stack-shared/src/interface/client-interface.ts 4/5 Implemented transferProject method with proper validation and API call structure
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts 4/5 Removed transfer method from AdminProject interface and cleaned up imports
packages/stack-shared/src/interface/admin-interface.ts 5/5 Removed transferProject method from StackAdminInterface as part of architectural refactor
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx 4/5 Updated UI to use new user.transferProject API instead of project.transfer
packages/template/src/lib/stack-app/users/index.ts 3/5 Added transferProject method signature to InternalUserExtra type definition

Confidence score: 4/5

  • This PR is relatively safe to merge with good architectural improvements and consistent implementation patterns
  • Score reflects solid refactoring work but some files lack comprehensive error handling and testing coverage
  • Pay close attention to client-app-impl.ts which has minimal error handling for the transfer operation

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Dashboard as Dashboard Page
    participant TeamSwitcher as TeamSwitcher Component
    participant ClientApp as Stack Client App
    participant Backend as Stack Backend

    User->>Dashboard: "Opens Project Settings page"
    Dashboard->>ClientApp: "getUser()"
    ClientApp->>Backend: "GET /users/me"
    Backend-->>ClientApp: "User data with teams"
    ClientApp-->>Dashboard: "Current user with teams"
    
    Dashboard->>Dashboard: "Find current owner team"
    Dashboard->>Dashboard: "Check user permissions for current team"
    
    User->>TeamSwitcher: "Selects new team for transfer"
    TeamSwitcher-->>Dashboard: "Team selection change"
    Dashboard->>Dashboard: "Set selectedTeamId state"
    
    User->>Dashboard: "Clicks Transfer button"
    Dashboard->>Dashboard: "Open ActionDialog for confirmation"
    
    User->>Dashboard: "Confirms transfer in dialog"
    Dashboard->>Dashboard: "Set isTransferring = true"
    Dashboard->>ClientApp: "user.transferProject(projectId, newTeamId)"
    ClientApp->>Backend: "POST /internal/projects/transfer"
    Note over Backend: Validates permissions and transfers project ownership
    Backend-->>ClientApp: "Transfer success"
    ClientApp-->>Dashboard: "Transfer complete"
    Dashboard->>Dashboard: "window.location.reload()"
    Note over Dashboard: Page reloads to reflect ownership change
Loading

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

},
async transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void> {
await app._interface.transferProject(session, projectIdToTransfer, newTeamId);
await app._refreshProject();
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Only refreshes current project cache, but transferring a project might affect owned projects list and should refresh _ownedProjectsCache as well

Suggested change
await app._refreshProject();
await app._refreshProject();
await app._refreshOwnedProjects(session);
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts
Line: 1252:1252

Comment:
**logic:** Only refreshes current project cache, but transferring a project might affect owned projects list and should refresh `_ownedProjectsCache` as well

```suggestion
        await app._refreshProject();
        await app._refreshOwnedProjects(session);
```

How can I resolve this? If you propose a fix, please make it concise.

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 f21cfda..efcac6d

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (5)

packages/stack-shared/src/interface/client-interface.ts
packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/project-settings/page-client.tsx
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts
packages/template/src/lib/stack-app/users/index.ts

⏭️ Files skipped (1)
  Locations  
packages/stack-shared/src/interface/admin-interface.ts

This was referenced Nov 25, 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