Skip to content

Conversation

@Maxsky5
Copy link

@Maxsky5 Maxsky5 commented Jan 12, 2026

Closes #1830 #1620

Summary

Allow users to configure a custom directory where git worktrees are created for each project, instead of using the system temp directory (e.g., /var/folders/.../vibe-kanban-dev/worktrees).
This is useful for:

  • Keeping worktrees on a specific disk/partition
  • Organizing project worktrees in a predictable location (e.g., ~/my-project-worktrees)
  • Avoiding temp directory cleanup issues on some systems

Changes

Database

  • New migration (20260112000000_add_worktree_base_dir_to_projects.sql): Adds worktree_base_dir TEXT DEFAULT NULL column to projects table

Backend

File Change
crates/db/src/models/project.rs Added worktree_base_dir field to Project and UpdateProject structs, updated all SQL queries
crates/server/src/routes/projects.rs Added path validation on project update using validate_worktree_dir()
crates/utils/src/path.rs Added validate_worktree_dir() (checks path exists, is directory, is writable) and expand_tilde() utilities
crates/services/src/services/worktree_manager.rs Added get_worktree_base_dir_with_config() as the single source of truth for worktree path resolution
crates/services/src/services/workspace_manager.rs Delegates to WorktreeManager::get_worktree_base_dir_with_config()
crates/local-deployment/src/container.rs Updated create() and ensure_container_exists() to fetch project and use its worktree_base_dir

Frontend

File Change
frontend/src/pages/settings/ProjectSettings.tsx Added input field for worktree base directory in General Settings card
frontend/src/i18n/locales/*/settings.json Added translations for all 6 locales (en, es, ja, ko, zh-Hans, zh-Hant)
shared/types.ts Regenerated TypeScript types

Bug Fix

Fixed a state management issue in ProjectSettings.tsx where the onSuccess callback from a previous render's stale closure would overwrite fresh mutation data with stale form state. The fix ensures the form state is updated from the mutation response rather than being clobbered.

Testing

  • Added 6 unit tests for get_worktree_base_dir_with_config() in worktree_manager.rs:
    • None returns default worktrees path
    • Empty string returns default
    • Whitespace-only returns default
    • Absolute path is used directly
    • Tilde (~) is expanded to home directory
    • Leading/trailing whitespace is trimmed
  • All existing tests pass: cargo test --workspace
  • Frontend type checks pass: pnpm run check

How to Test

  1. Open Project Settings for any project
  2. Find "Worktree Base Directory" input in General Settings
  3. Enter a valid absolute path or ~/some-path
  4. Save and create a new workspace session
  5. Verify the worktree is created in the specified directory

Notes

  • If the field is left empty, the default temp directory behavior is preserved
  • Path validation ensures the directory exists and is writable before saving
  • Translations are AI-generated. Let me know if I should update any of them

Allow users to configure a custom directory for git worktrees on a
per-project basis instead of using the system temp directory.

- Add worktree_base_dir column to projects table via migration
- Add validation for worktree directory (exists, writable, absolute/tilde)
- Update LocalContainerService to use project's worktree_base_dir
- Add UI input field in Project Settings with i18n support (6 locales)
- Fix project update mutation to prevent stale state overwriting fresh data
- Add unit tests for worktree base directory resolution
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.

Feature Request: Configurable base directory for Git worktrees (per-project + global default)

1 participant