Repository navigation
New worktrees reuse the main checkout's node_modules when the lockfile matches - #1711
Conversation
…file matches (#396) Before an approved setup runs, clone the main checkout's node_modules with `cp -Rc` (APFS clonefile) when the worktree's lockfile is byte-identical. Setup still runs after, so `npm install`-style setups finish as a no-op and build steps still happen. Logged as `[setup] reused …`; a failed clone is cleaned up and setup runs normally. macOS only; per-project opt-out via `setupCacheOff`. 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: 44355da6a9
ℹ️ 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".
| try { | ||
| await cloneDirFn(src, dest); | ||
| } catch (err) { | ||
| fs.rmSync(dest, { recursive: true, force: true }); |
There was a problem hiding this comment.
Guard cleanup errors so a failed clone cannot skip setup
If a failed clone leaves a partial directory that cannot be removed, such as a populated read-only subdirectory, fs.rmSync throws even with force: true. This rejects reuseNodeModules, so kickWorktreeSetup never reaches runOne; the caller in worktrees-lifecycle.js silently swallows the rejection. An optional cache failure therefore prevents the configured setup from running instead of falling back to it. Handle cleanup failures explicitly and ensure the setup command still gets invoked.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6998c47: cleanup is wrapped in try/catch, and kickWorktreeSetup catches anything reuseNodeModules throws, so setup always runs. Covered by a new test that makes rmSync throw.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test resolved the previous test's stale resolver whenever the runner was reached after the waiting step appeared, leaving that test's setup hung and node:test cancelling the suite. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Part of #396 (setup output cached across threads).
New worktrees no longer start installs from zero. On macOS, when a new worktree's lockfile is byte-identical to the main checkout's, Solenta clones the main checkout's
node_modulesinto it withcp -Rc(APFS copy-on-write) before setup runs. The thread logs[setup] reused node_modules from the main checkout (package-lock.json 1a2b3c4d) in 0.4s.npm install/pnpm installsetup then finishes as a near no-op, build steps in it still happen, and a stale mainnode_modulesgets reconciled.npm ciwipesnode_modules, so it gains nothing.node_modulesyet, and the first lockfile found (package-lock.json,npm-shrinkwrap.json,pnpm-lock.yaml,yarn.lock,bun.lock[b]) matches. Otherwise setup runs exactly as before.[setup] cache miss: …, and runs the full setup.setupCacheOff.Not keyed on the setup command hash: setup always runs after the clone, so a changed setup is still honored.
Testing
electron/test/setup-cache.test.js: a hit (realcp -Rcon macOS, symlinks kept, setup sees the clone), a lockfile mismatch, an existingnode_modulesleft alone, the opt-out round trip, and a failed clone being cleaned up.memory-sup10s timeout under load; it passes on its own). Typecheck, the Edit Project renderer test andvite buildpass.🤖 Generated with Claude Code