Skip to content

Reclaim idle worktree space automatically on dev startup - #28864

Merged
nwparker merged 5 commits into
mainfrom
nwparker/dev-storage-reclaim
Oct 14, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/dev-storage-reclaim

Conversation

@nwparker

@nwparker nwparker commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​215 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​198
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​188 $\color{#cf222e}{\Huge{\mathbf{−}}}$​59 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129

ELI5

Idle Electron bundles in other branches used to accumulate until someone ran cleanup manually. Starting pnpm dev now starts safe cleanup across the repository in the background. pnpm reclaim-space replaces the three package commands and lets you apply the preview by answering Y.

What Changed

  • Dev and stable-name dev launches start an independent cleanup worker after the dev process starts, excluding the worktree being launched. Worker output is suppressed so it cannot hold captured dev output open. Cleanup never prompts or blocks startup; failures leave dev running. ORCA_SKIP_DEV_STORAGE_RECLAIM=1 opts out.
  • pnpm reclaim-space previews and offers [y/N] in a terminal. --apply runs directly; redirected input/output stays preview-only unless --apply is supplied.
  • Historical test caches require --tests-stopped in both preview and apply. Automatic cleanup never touches them, even with that flag.

The PR also fixes a test recently merged into main: spying on every filesystem export replaced real stream internals and caused ten CI timeouts. The test now spies only on the content-read functions it observes.

Why

Reuses the existing sweep, repository lock, process checks, and atomic Electron sharing instead of introducing another cleaner. Running it in a separate worker avoids adding the filesystem sweep to startup and lets the worker release its lock if the dev app exits. Keeping historical test caches explicit protects older test runners that still import them.

Linked Issue

Fixes #28863

Visual Proof

Captured terminal transcripts from a disposable macOS repository before the command was renamed to reclaim-space; the bundle remained after preview and was removed only after Y. These images render the recorded text; they are not Orca window screenshots.

Before:
Before: preview exits without confirmation

After:
After: Y applies the preview

Testing

  • Manually tested the real preview → Y → apply flow in a disposable repository on macOS; checked pnpm reclaim-space --help.
  • Automated tests added/updated: 76 passing tests across cleanup, confirmation, exclusion through filesystem aliases, cache retention, and dev-runner suites. Test launches used ORCA_BACKGROUND_LAUNCH=1.
  • A real-process regression test reproduced captured dev output hanging before the stream fix, then passed after it. All 34 tests in the confirmation, background-worker, and dev-runner suites passed after the review fixes.
  • After bringing in current main, all 53 transcript-search tests in the four affected suites passed, including the 13 cases in the previously failing suite.
  • pnpm tc:node, pnpm run check:code-quality:changed, pnpm run check:max-lines-ratchet, and commit lint/format checks passed.
  • Linux and Windows execution, full build, and remaining checks are left to CI. Cleanup runs on the local execution host; no remote protocol changes.

Review

Self-reviewed lock release, failed preview, redirected input, startup failure, current-worktree exclusion, and test-cache retention.

Agent skill upstream boundary

  • Not applicable; no upstream skill source or resources copied.

Checklist

  • Focused on repository storage maintenance
  • Explained the before/after, mechanism, and choice of approach
  • Before/after terminal proof attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH, and folder-workspace impact considered
  • Full lint, all typechecks/tests, and build: CI will cover; targeted local checks listed above passed

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df43b1ba-ab9a-4418-8126-489571abf324
📥 Commits

Reviewing files that changed from the base of the PR and between c45d4b5 and 63563b2.

📒 Files selected for processing: 4
  • config/scripts/dev-storage-reclaim.mjs
  • config/scripts/dev-storage-reclaim.test.mjs
  • docs/readme/release-source-sharing.md
  • docs/readme/worktree-storage-maintenance.md
🚧 Files skipped from review as they are similar to previous changes: 4
  • config/scripts/dev-storage-reclaim.mjs
  • config/scripts/dev-storage-reclaim.test.mjs
  • docs/readme/release-source-sharing.md
  • docs/readme/worktree-storage-maintenance.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The changes add a unified pnpm reclaim-space command with preview and interactive apply behavior. Cleanup can exclude a worktree and retains historical test caches unless --tests-stopped is set. Eligible dev launches start a detached cleanup worker that excludes the launched worktree and reports failures without stopping dev. The worker can be disabled with ORCA_SKIP_DEV_STORAGE_RECLAIM=1.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 63563

No actionable merge-blocking risk remains in the reviewed cleanup and dev-startup paths; merge after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The change to src/main/ai-vault-search/session-search-transcript-dependencies.test.ts narrows node:fs spies to preserve stream internals. The change fixes an unrelated transcript-search test regre… Remove this unrelated test fix from this pull request, or submit it in a separate pull request.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 13 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Linked Issues check Passed Issue #28863 is closed and completed. It provides historical context only. No active directly linked issue supplies coding requirements for this pull request.
Title check Passed The title clearly summarizes the primary change: automatic reclamation of idle worktree space during development startup.
Description check Passed The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, visual proof, testing, review notes, and checklist status. It also clearly identifies check…
Full details: Out of Scope Changes check

Explanation

The change to src/main/ai-vault-search/session-search-transcript-dependencies.test.ts narrows node:fs spies to preserve stream internals. The change fixes an unrelated transcript-search test regression and does not support storage reclamation or dev startup.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 13 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔇 Additional comments: 1
config/scripts/reclaim-worktree-command.mjs-70-70: 1

70-70: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Do not prompt in a non-interactive CI job with a pseudo-terminal.

If CI supplies TTY streams but no operator input, this condition waits indefinitely after the preview. Check CI indicators before creating the prompt, and leave that run preview-only. Based on learnings, Node.js CLI tools should check CI indicators rather than gate prompts solely on TTY status.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0761782c-4954-4d35-a4fe-f20c7bb1234f
📥 Commits

Reviewing files that changed from the base of the PR and between ebd4f00 and 984c142.

📒 Files selected for processing: 15
  • config/scripts/dev-storage-reclaim.mjs
  • config/scripts/dev-storage-reclaim.test.mjs
  • config/scripts/reclaim-electron-dists.mjs
  • config/scripts/reclaim-electron-dists.test.ts
  • config/scripts/reclaim-release-test-caches.mjs
  • config/scripts/reclaim-worktree-command.mjs
  • config/scripts/reclaim-worktree-command.test.mjs
  • config/scripts/reclaim-worktree-space.mjs
  • config/scripts/reclaim-worktree-space.test.mjs
  • config/scripts/run-electron-vite-dev.mjs
  • docs/readme/release-source-sharing.md
  • docs/readme/worktree-storage-maintenance.md
  • package.json
  • src/main/startup/run-electron-vite-dev-web.test.ts
  • src/main/startup/run-electron-vite-dev.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread config/scripts/dev-storage-reclaim.mjs Resolved
Comment thread docs/readme/release-source-sharing.md Resolved
@nwparker
nwparker merged commit 7244bf3 into main Oct 14, 2026
44 checks passed
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.

Automatically reclaim idle worktree bundles on dev startup

1 participant