Skip to content

Comments

Feat_#947#962

Open
DevDesai444 wants to merge 2 commits intogeneralaction:mainfrom
DevDesai444:feat-configurable-worktree-storage-#947
Open

Feat_#947#962
DevDesai444 wants to merge 2 commits intogeneralaction:mainfrom
DevDesai444:feat-configurable-worktree-storage-#947

Conversation

@DevDesai444
Copy link
Contributor

PR: Feat_#947

Branch: feat-configurable-worktree-storage-#947

Resolves: [feat]: Configurable Worktree Storage Location #947

Basic Description

In this PR, I added support for configuring where Emdash creates worktrees on a per-project basis, instead of always using ../worktrees.

What I did

  • Added a new project database field: worktree_base_path.
  • Updated backend services to read/save this value.
  • Updated worktree creation logic to use the configured base path.
  • Added project settings UI with options:
    • Default (../worktrees)
    • Inside project (.worktrees)
    • Temporary (/tmp/emdash)
    • Custom path
  • Added validation and safety checks for invalid paths.
  • Updated tests and documentation.

Verification

  • Ran formatting and consistency checks.
  • Ran type-check and tests.
  • Confirmed existing projects keep default behavior unless users change the setting.

@vercel
Copy link

vercel bot commented Feb 19, 2026

@DevDesai444 is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This PR adds configurable worktree base paths on a per-project basis. Users can now choose where Emdash creates worktrees: default (../worktrees), inside project (.worktrees), temporary (/tmp/emdash), or a custom path.

Key changes:

  • Added worktree_base_path column to projects table with proper migration
  • Updated WorktreeService and WorktreePoolService to resolve configured base paths dynamically
  • Extended ProjectSettingsService with validation preventing worktrees in project root or .git directory
  • Added UI controls in ProjectMainView with directory picker for custom paths
  • Blocked configuration for remote projects (not yet supported)
  • Updated tests and documentation

Issues found:

  • Windows compatibility: Frontend hardcodes /tmp/emdash but backend uses os.tmpdir() on Windows, causing mismatch when users select "Temporary" option

Confidence Score: 4/5

  • Safe to merge with minor Windows compatibility fix needed
  • The implementation is well-structured with proper validation, database migration, and test coverage. The core logic correctly handles path resolution, normalization, and safety checks. However, the Windows temp path hardcoding in the frontend will cause the "Temporary" option to malfunction on Windows, which is a cross-platform bug that should be fixed before release.
  • Fix Windows temp path in src/renderer/components/WorktreeBasePathControls.tsx before releasing to Windows users

Important Files Changed

Filename Overview
src/main/services/ProjectSettingsService.ts Core logic for resolving and validating worktree paths; includes safety checks but missing temp path constant handling
src/main/services/DatabaseService.ts Refactored to support updating multiple project settings atomically
src/main/services/WorktreeService.ts Updated to use configured base path; added allowAnyPath flag for cleanup safety
src/main/services/WorktreePoolService.ts Updated reserve/pool logic to respect configured base paths and scan all project paths for orphans
src/renderer/components/WorktreeBasePathControls.tsx New UI component for worktree location selection; hardcodes /tmp/emdash which won't work on Windows

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects worktree location in UI] --> B{Which mode?}
    B -->|Default| C[Set to null]
    B -->|Inside project| D[Set to '.worktrees']
    B -->|Temporary| E[Set to '/tmp/emdash']
    B -->|Custom| F[User picks directory]
    
    C --> G[IPC: updateProjectSettings]
    D --> G
    E --> G
    F --> G
    
    G --> H[ProjectSettingsService.updateProjectSettings]
    H --> I[normalizeWorktreeBasePathInput]
    I --> J{Validation}
    J -->|Invalid: project root| K[Throw error]
    J -->|Invalid: inside .git| K
    J -->|Valid| L[DatabaseService.updateProjectSettings]
    
    L --> M[Update projects table]
    M --> N[Return updated settings]
    
    O[Task creation] --> P[ProjectSettingsService.resolveProjectWorktreeBasePath]
    P --> Q[resolveWorktreeBasePath]
    Q --> R{Path type?}
    R -->|null/empty| S[Return ../worktrees]
    R -->|'.worktrees'| T[Return project/.worktrees]
    R -->|absolute| U[Return as-is]
    R -->|relative| V[Resolve from project]
    
    S --> W[WorktreeService creates worktree]
    T --> W
    U --> W
    V --> W
Loading

Last reviewed commit: 9d7c91e

Copy link

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

21 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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.

[feat]: Configurable Worktree Storage Location

1 participant