Skip to content

settings: add configurable worktree location#92

Merged
vaayne merged 2 commits into
mainfrom
worktree-path
Jun 24, 2026
Merged

settings: add configurable worktree location#92
vaayne merged 2 commits into
mainfrom
worktree-path

Conversation

@vaayne

@vaayne vaayne commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Adds a user-configurable base directory for new local worktrees in Settings → General. Defaults to ~/.mori (unchanged behavior when left empty).

Why

New worktrees were hardcoded to ~/.mori. Users want them elsewhere (e.g. a dedicated ~/code/worktrees).

How

  • ToolSettings gains a worktreeBasePath field + resolvedWorktreeBaseDir() helper (expands ~, falls back to ~/.mori). Stored in the existing UserDefaults settings bucket.
  • WorkspaceManager.createWorktree() reads the resolved base dir per creation, so changes apply immediately.
  • General settings tab gets a path field with a live "Resolved:" preview and Apply button, reusing the existing onToolSettingsChanged save callback.
  • i18n (en + zh) and both CHANGELOGs updated.

Scope / tradeoffs

  • Only affects new worktrees. Existing worktrees store absolute paths in the DB and are left in place.
  • Remote SSH worktrees unchanged — they use <remote repo parent>/.mori, unrelated to the local home dir.

Test

  • mise run build passes (debug).
  • Verified manually via mise run dev: empty field resolves to ~/.mori; custom path updates the preview and persists on Apply.

vaayne added 2 commits June 24, 2026 12:07
New local worktrees are created under a user-configurable base directory
(Settings → General), defaulting to ~/.mori. Stored in ToolSettings and
resolved per creation so changes apply immediately. Existing worktrees are
left in place; remote SSH worktrees still use the repo's parent directory.
Mori was purely DB-driven and never discovered worktrees on disk, so a
repo's pre-existing worktrees stayed invisible. Add
importExistingWorktrees(projectId:) which scans `git worktree list`,
skips already-tracked and bare entries, and imports the rest (best-effort
tmux session each). Runs automatically on addProject so a freshly added
repo shows all its branches, and is exposed as an "Import Existing
Worktrees" project context-menu action for on-demand rescans.
@vaayne vaayne merged commit f87a0b4 into main Jun 24, 2026
5 checks passed
@vaayne vaayne deleted the worktree-path branch June 26, 2026 01:55
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