Repository navigation
Pre-warmed worktree pool for instant thread creation (#192) - #1564
Conversation
Keep 2 idle detached worktrees per project under userData/worktree-pool; setupWorktree claims one with git worktree move + checkout -b, falling back to worktree add when the pool is empty. Refilled in the background. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28c7a3754d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await gitOutAsync( | ||
| project.path, | ||
| ["worktree", "add", "--detach", dir, start], | ||
| { timeout: 120_000 }, |
There was a problem hiding this comment.
Suppress checkout hooks while filling the hidden pool
For repositories with an executable post-checkout hook, each background fill executes that hook inside the hidden pooled tree; Git documents that worktree add invokes it unless --no-checkout is used (githooks documentation). Claiming the tree then invokes the hook again through checkout, while hook-created untracked files are not cleaned, so a new thread can inherit stale or duplicated artifacts and arbitrary hook side effects run before the user requests that checkout. Suppress repository hooks during pool creation while retaining the hook invocation for the final claim.
Useful? React with 👍 / 👎.
| function dropPooled(repoPath, dir) { | ||
| gitTry(repoPath, ["worktree", "remove", "--force", dir]); | ||
| fs.rmSync(dir, { recursive: true, force: true }); |
There was a problem hiding this comment.
Preserve the fallback when pooled cleanup fails
When worktree move fails because a pooled directory is locked or otherwise cannot be renamed—particularly on Windows—the following rmSync can throw despite force: true. That exception escapes claimPooledWorktree instead of returning false, so setupWorktree reports a creation failure and never attempts the normal git worktree add fallback even though its destination may be usable. Treat cleanup as best-effort or quarantine the stale pool entry so a failed claim cannot abort foreground thread creation.
Useful? React with 👍 / 👎.
…tree-pool-for-instant-thr-1e6a15 # Conflicts: # electron/worktrees.js
Closes #192.
setupWorktreeclaims an idle pooled worktree (git worktree move+checkout -b <branch> <start>) instead of running a fullgit worktree add; falls back to the old path when the pool is empty or a claim fails.<worktree base>/.pool/<projectId>/, topped up in the background after every setup. Same filesystem as the base, so the move is a rename.worktrees-gcskips.pool, so the boot sweep / GC never reap idle pool trees.main.js; tests and other entry points keep pool size 0.Not included: WSL projects (skipped), pre-running project setup scripts in pooled trees, reaping pools of removed projects.
Test:
electron/test/worktree-pool.test.jswarms the pool, advances main, asserts the claim moved the pooled dir onto the new main with a clean tree, the pool refills, and the orphan sweep leaves it alone.🤖 Generated with Claude Code