Skip to content

Add manual cleanup for worktree Electron storage - #27414

Merged
nwparker merged 2 commits into
mainfrom
nwparker/orca-worktree-space-package-boxing-glove
Oct 11, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/orca-worktree-space-package-boxing-glove

Conversation

@nwparker

@nwparker nwparker commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​161 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​227 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​216

ELI5

Old development app bundles and separate Electron copies can accumulate across worktrees. This adds one local command to preview reclaimable storage and another to apply the cleanup. Cleanup runs only when requested; pnpm dev does not start background maintenance.

What Changed

pnpm run reclaim:worktree-space          # Preview
pnpm run reclaim:worktree-space --apply  # Apply
  • The combined command reuses the existing scripts to share complete Electron distributions through the repository cache and remove idle macOS development bundles. Git's registered worktrees determine scope, including worktrees outside Orca's workspace directory. --repo DIRECTORY selects another local repository.
  • A repository lock prevents concurrent combined cleanups. Dev bundle removal rechecks active processes and build state immediately before deleting each bundle, refuses removal when process ownership cannot be checked, and reports failures. The underlying bundle command also supports an age limit and an excluded worktree.
  • Native dependency setup now lets healthy Electron installs join the existing shared cache, rather than waiting for a missing binary or an Electron upgrade. The downloader loads only when a download is needed.
  • Output describes logical file sizes, since shared blocks mean those sizes are not guaranteed disk savings. Usage and scope are documented in docs/readme/worktree-storage-maintenance.md.

Why

Starting the dev app previously reclaimed old bundles only in the current worktree, leaving output from inactive branches behind. Healthy dependency installs also skipped the opportunity to share their existing Electron distribution. Reusing the existing cache and cleanup scripts addresses both without deleting whole worktrees or replacing their dependency installations. Keeping the sweep manual lets developers choose when to reclaim storage.

Linked Issue

N/A — maintainer-requested maintenance work; no linked issue.

Visual Proof

N/A — local command and dependency setup changes; no rendered UI changes.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

On macOS, ran the combined preview against the local repository without applying it to existing worktrees. Tested actual preview/apply removal in a disposable Git repository, including age retention. Focused tests cover competing cleanup commands, failure recovery, active-process/build protection, Electron installation, and the existing sharing mechanisms.

  • 99 tests passed; 6 platform-specific tests skipped across seven focused suites.
  • ORCA_BACKGROUND_LAUNCH=1 pnpm tc passed.
  • ORCA_BACKGROUND_LAUNCH=1 pnpm run check:code-quality:changed passed; commit hooks also run lint and formatting.
  • Linux, Windows, and SSH were not exercised live for this PR. The command acts on its execution host and does not enumerate remote machines. Folder workspaces without Git have no repository-wide sweep. Dev bundle cleanup remains macOS-only, and existing distribution-sharing code handles platform differences.

Full application build and full-repository lint were not run locally; CI covers those checks.

Review

Self-reviewed the selected changes, default preview behavior, deletion checks, lock release, and PR scope.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No background cleanup hook, timer, or scheduling mode is included. Historical release-test cache sharing and the tracked-source cloning experiment are outside this PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 11, 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: f19b2dab-cc6a-40b9-8c62-e06cad4d1539

📥 Commits

Reviewing files that changed from the base of the PR and between 5517903 and 30370b3.


📒 Files selected for processing (5)
  • config/scripts/reclaim-dev-electron-bundles.mjs
  • config/scripts/reclaim-dev-electron-bundles.test.ts
  • config/scripts/reclaim-worktree-space.mjs
  • config/scripts/reclaim-worktree-space.test.mjs
  • docs/readme/worktree-storage-maintenance.md

🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/readme/worktree-storage-maintenance.md
  • config/scripts/reclaim-worktree-space.test.mjs

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



📝 Walkthrough

Walkthrough

The changes add shared Electron distribution handling and age-aware development-bundle reclamation. A new worktree command runs both cleanup operations under a lock. The command supports preview and apply modes and has accompanying tests and usage documentation.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 30370

The worktree cleanup command is ready to merge after normal checks; no actionable risk remains from this review.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 9 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding manual cleanup for Electron storage across worktrees.
Description check Passed The description follows the required template and explains the user impact, changes, rationale, testing, scope, limitations, and checklist status. The missing linked issue is justified as maintainer-r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 9 files. (1 skipped: 1 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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74f8b5e8-b6dc-4682-8ff0-e1d878ad5084
📥 Commits

Reviewing files that changed from the base of the PR and between 0024735 and 5517903.

📒 Files selected for processing (11)
  • config/scripts/dev-electron-bundle-cache.mjs
  • config/scripts/dev-electron-bundle-cache.test.ts
  • config/scripts/install-electron-package-binary.mjs
  • config/scripts/rebuild-native-deps.mjs
  • config/scripts/reclaim-dev-electron-bundles.mjs
  • config/scripts/reclaim-dev-electron-bundles.test.ts
  • config/scripts/reclaim-electron-dists.mjs
  • config/scripts/reclaim-worktree-space.mjs
  • config/scripts/reclaim-worktree-space.test.mjs
  • docs/readme/worktree-storage-maintenance.md
  • package.json

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

@nwparker
nwparker merged commit c69f9d2 into main Oct 11, 2026
36 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.

1 participant