Repository navigation
feat (desktop): drag in git projects - #817
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds drag-and-drop project opening: a new TRPC procedure Changes
Sequence DiagramsequenceDiagram
participant User
participant SidebarDropZone
participant TRPC as "electronTrpc.projects.openFromPath"
participant InitGitDialog
participant CreateWS as "electronTrpc.workspaces.createBranchWorkspace"
User->>SidebarDropZone: Drag folder over sidebar
SidebarDropZone->>SidebarDropZone: show drag overlay
User->>SidebarDropZone: Drop folder
SidebarDropZone->>SidebarDropZone: get path via window.webUtils.getPathForFile()
SidebarDropZone->>TRPC: openFromPath(path)
alt path invalid / fs error
TRPC-->>SidebarDropZone: error
SidebarDropZone->>SidebarDropZone: show dismissible error toast
else needs Git init
TRPC-->>SidebarDropZone: needsGitInit
SidebarDropZone->>InitGitDialog: open dialog for path
InitGitDialog-->>SidebarDropZone: user confirms/cancels
else success (project returned)
TRPC-->>SidebarDropZone: success with project
SidebarDropZone->>CreateWS: createBranchWorkspace(projectId, branch)
CreateWS-->>SidebarDropZone: workspace created
SidebarDropZone->>SidebarDropZone: invalidate recents / update UI
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/SidebarDropZone/SidebarDropZone.tsx`:
- Around line 130-142: The comment is inaccurate: the error toast isn’t
auto-dismissed; update SidebarDropZone to auto-clear errors by adding a
useEffect watching the error state that starts a timeout (e.g., 3–5s) which
calls setError(null) and clears the timer on cleanup, while keeping the existing
manual Dismiss button and error display; reference the error state and setError
inside the SidebarDropZone component for the change.
🧹 Nitpick comments (2)
apps/desktop/src/lib/trpc/routers/projects/projects.ts (1)
433-470: LGTM! The newopenFromPathprocedure is well-implemented.The procedure correctly:
- Validates path existence before proceeding
- Reuses the
OpenNewResultdiscriminated union for consistent return types- Handles the git initialization flow properly
- Tracks analytics with the appropriate "drop" method
Consider extracting the shared logic between
openFromPathandopenNew(lines 416-430 and 455-469) into a helper function to reduce duplication, but this is optional given the small scope.♻️ Optional: Extract shared project opening logic
async function openProjectFromGitRoot( mainRepoPath: string, method: "open" | "drop" | "init" ): Promise<OpenNewSuccess> { const defaultBranch = await getDefaultBranch(mainRepoPath); const project = upsertProject(mainRepoPath, defaultBranch); await ensureMainWorkspace(project); track("project_opened", { project_id: project.id, method }); return { canceled: false, project }; }Then use it in both procedures to reduce duplication.
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/SidebarDropZone/SidebarDropZone.tsx (1)
96-99: The workspace creation call can be optimized by returning workspace info from the backend.The
openFromPathendpoint already callsensureMainWorkspace(project)on the backend (line 459 in projects.ts), which creates the workspace. However, it returns only the project info without the workspace details, forcing the frontend to callcreateBranchWorkspaceagain just to fetch the created workspace and navigate to it. This results in an unnecessary additional database query.Optimize by having
openFromPathreturn the workspace object alongside the project, allowing the frontend to navigate directly without the extra round trip.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Description
Related Issues
Type of Change
Testing
Screenshots (if applicable)
Additional Notes
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.