You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 24, 2026. It is now read-only.
Worktrees accumulate silently over time and are never automatically cleaned up. Each worktree can consume 1-12 GB of disk space. After several sessions, users can end up with many orphaned worktrees from completed/abandoned work (branches deleted from remote, sessions no longer active, etc.).
Today, cleanup requires the user to manually run git worktree list, cross-reference against active sessions, and git worktree remove each stale one.
Proposed Solution
Add automatic worktree cleanup logic, triggered on app startup or new session creation:
List all worktrees on disk under ~/.polypilot/worktrees/
Cross-reference against active sessions (check _sessions dictionary and Organization.Sessions)
Identify orphaned worktrees — those with no active session pointing to them
Classify orphans by risk level:
Safe to auto-remove: Clean (no dirty files) + remote branch gone ([gone] tracking status)
Prompt before removing: Has uncommitted changes or untracked files
Keep: Has active session or running processes
Auto-remove safe orphans (or at minimum, surface them to the user with an option to clean up)
Run git worktree prune after cleanup to remove stale git refs
Additional Context
RepoManager already has RemoveWorktreeAsync — this work is primarily about adding the discovery/reconciliation logic and hooking it into the session lifecycle.
Problem
Worktrees accumulate silently over time and are never automatically cleaned up. Each worktree can consume 1-12 GB of disk space. After several sessions, users can end up with many orphaned worktrees from completed/abandoned work (branches deleted from remote, sessions no longer active, etc.).
Today, cleanup requires the user to manually run
git worktree list, cross-reference against active sessions, andgit worktree removeeach stale one.Proposed Solution
Add automatic worktree cleanup logic, triggered on app startup or new session creation:
~/.polypilot/worktrees/_sessionsdictionary andOrganization.Sessions)[gone]tracking status)git worktree pruneafter cleanup to remove stale git refsAdditional Context
RepoManageralready hasRemoveWorktreeAsync— this work is primarily about adding the discovery/reconciliation logic and hooking it into the session lifecycle.Key files:
PolyPilot/Services/RepoManager.cs— worktree creation/removalPolyPilot/Services/CopilotService.cs— session creation (CreateSessionAsync)