Repository navigation
workspaces: create local workspaces as APFS copy-on-write clones - #99
Merged
Merged
Conversation
clonefile via copyfile(COPYFILE_CLONE) with a pre-flight volume check (CLONE_FORCE is incompatible with RECURSIVE directory trees), a status callback that skips sockets/FIFOs like .git/fsmonitor--daemon.ipc, temp path + rename materialization, on-disk kind classification, and the post-clone git fixup (drop inherited .git/worktrees, checkout -f). Also adds GitBackend.commitsAhead for unpushed-work probes.
Worktree.kind (hint only; destructive ops re-verify on disk), ToolSettings.preferCowClones (default on), and Project.dismissedWorktreePaths so auto-discovery cannot resurrect workspaces the user removed while keeping files.
Local creation clones the project dir (untracked files — node_modules, .build — carry over instantly), falling back to git worktree (repos) or a plain copy (non-git) on non-APFS/cross-volume. Deletion branches on on-disk truth with path guardrails and an escalated warning when a clone holds unpushed commits (they exist only in the clone). Discovery scans the worktree base dir at launch/import, gated by the per-project dismissed-paths list. Settings toggle to prefer clones, on by default.
Hover-revealed [+] and [...] icons next to the collapse chevron replace the dedicated '+ New workspace' row, saving a row per section. Opacity (not conditional insertion) keeps the chevron from shifting; projects with no workspaces show the accessories permanently so the create entry point stays discoverable. The overflow menu's New Workspace item drops its expanded-only gate since the header works while collapsed too.
copyfile(RECURSIVE) walks per file (~30s for repos with node_modules); clonefile(2) on the root directory clones the entire tree in one syscall (measured 1.7s on a 4 GB repo) and handles sockets natively. The per-file walk stays as fallback when clonefile refuses.
Insert an in-memory placeholder row with a new .creating status before materialization, promote to .active and persist on success, roll back on failure. Creating rows are non-interactive, show a 'Creating…' status line, and are skipped by git status polling since their path may not exist yet. Never persisted, so a crash mid-create leaves no stale record.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Local workspace creation now clones the whole project directory via a single
clonefile(2)syscall (~1.7s for a 4 GB repo, measured) instead ofgit worktree add, sonode_modules,.build, and other untracked artifacts are available instantly in the new workspace. Also works for non-git projects.clonefile(2)→ per-filecopyfile(COPYFILE_CLONE)walk (with volume pre-check so it never silently degrades to a physical copy) →git worktree add(git repos) / plain copy (non-git). SSH projects keep the existing worktree path untouched.Creating…status (newWorktreeStatus.creating, never persisted), promoted to active on success, rolled back on failure.+ New workspacerow is gone;+and…are now hover-revealed icons in the project header next to the collapse chevron (always visible for projects with no workspaces).Notes
COPYFILE_CLONE_FORCEis incompatible withCOPYFILE_RECURSIVEon directory trees (interior dirs are mkdir'd) — the volume pre-check provides the no-silent-physical-copy guarantee instead.Worktree.kindis persisted as a hint only; destructive operations re-verify the on-disk shape (.gitdir = clone,.gitfile = linked worktree).mise run test— fixed here (test:git).Verification
mise run test— six packages, 1369 assertions, all green (new CowCloner suite covers clone content/symlinks, dest-exists, temp cleanup, on-disk classification, and real-git fixup).