Skip to content

feat (desktop): drag in git projects - #817

Merged
AviPeltz merged 3 commits into
mainfrom
drag-in-projects
Jan 19, 2026
Merged

AviPeltz merged 3 commits into
mainfrom
drag-in-projects

Conversation

@AviPeltz

@AviPeltz AviPeltz commented Jan 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • New Features
    • Drag-and-drop support to open projects by dropping folders into the workspace sidebar
    • Ability to open projects from a chosen filesystem path
    • Automatic detection of Git repos with a prompt to initialize Git for non-repo folders
    • Automatic creation of a workspace/branch when a project is opened
    • User-facing error toasts and processing overlays during drop/open operations

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@AviPeltz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 8f65df3 and 200afde.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/SidebarDropZone/SidebarDropZone.tsx
📝 Walkthrough

Walkthrough

Adds drag-and-drop project opening: a new TRPC procedure openFromPath, a React hook useOpenFromPath, a SidebarDropZone component handling drops (including Git init flow), and integrates the drop zone into the workspace sidebar.

Changes

Cohort / File(s) Summary
TRPC Backend
apps/desktop/src/lib/trpc/routers/projects/projects.ts
New openFromPath(path: string) procedure: validates path, finds Git root, returns needsGitInit if no repo, upserts/creates project and default branch, returns OpenNewResult.
React Query Hook & Export
apps/desktop/src/renderer/react-query/projects/useOpenFromPath.ts, apps/desktop/src/renderer/react-query/projects/index.ts
New useOpenFromPath hook wrapping electronTrpc.projects.openFromPath.useMutation; re-exported from index. On success invalidates getRecents and forwards user onSuccess.
Sidebar Drop Zone
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/SidebarDropZone/SidebarDropZone.tsx, .../SidebarDropZone/index.ts
New SidebarDropZone component: manages drag state, reads path via window.webUtils.getPathForFile, calls openFromPath, handles outcomes (error toast, InitGitDialog for needsGitInit, or calls createBranchWorkspace on success). Re-export added.
Sidebar Integration
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebar.tsx
Wraps sidebar content with SidebarDropZone and updates empty-state message to mention drag-and-drop.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Poem

🐰 I found a folder, soft and round,
I dropped it where the sidebars bound.
Git roots checked, a workspace born,
I hopped, I cheered, and twitched my horn.
New projects open—huzzah! 🥕📁

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is a template with only the checkbox for 'New feature' marked, but all substantive sections (Description, Related Issues, Testing, Screenshots, Additional Notes) are empty or contain only comments. Complete the PR description by adding: (1) a clear summary of the drag-and-drop functionality added, (2) related issue links if applicable, (3) testing steps or verification method, and (4) any additional context about the implementation.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat (desktop): drag in git projects' clearly summarizes the main change: adding drag-and-drop functionality for Git projects in the desktop app.

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 new openFromPath procedure is well-implemented.

The procedure correctly:

  • Validates path existence before proceeding
  • Reuses the OpenNewResult discriminated union for consistent return types
  • Handles the git initialization flow properly
  • Tracks analytics with the appropriate "drop" method

Consider extracting the shared logic between openFromPath and openNew (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 openFromPath endpoint already calls ensureMainWorkspace(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 call createBranchWorkspace again just to fetch the created workspace and navigate to it. This results in an unnecessary additional database query.

Optimize by having openFromPath return the workspace object alongside the project, allowing the frontend to navigate directly without the extra round trip.

@AviPeltz
AviPeltz merged commit d3049ef into main Jan 19, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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