Repository navigation
feat(space): add a prune action for stale worktree registrations - #8910
brennanb2025 wants to merge 3 commits into
Conversation
Prunable registrations are omitted from Space rows (#8409), but they still pin their branches as checked out with no in-app remedy — a macOS reboot that clears /private/tmp can leave a whole batch behind. Count them during the Space scan and surface a notice with a Prune button that runs git's own `worktree prune` per affected repo (locked registrations survive; branches and commits are untouched). The relay gains a dedicated git.pruneWorktrees op since generic git.exec is deliberately read-only; an older deployed relay without it gets a clear error instead of a protocol failure.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds stale worktree registration counts to workspace-space analysis and implements pruning through local Git execution, SSH relay RPCs, desktop IPC, and preload APIs. The workspace-space slice and panel now invoke pruning, display progress and results, and refresh analysis. Web clients report the operation as unavailable. Tests cover Git pruning behavior, IPC routing and errors, analysis counts, and updated data fixtures. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 05a7b96d-edee-4286-884c-bbb7a90af47d
📒 Files selected for processing (21)
src/main/git/worktree-list-paths.test.tssrc/main/git/worktree.tssrc/main/ipc/workspace-space.test.tssrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/providers/ssh-git-provider.tssrc/main/workspace-space-analysis.test.tssrc/main/workspace-space-analysis.tssrc/preload/api-types.tssrc/preload/index.tssrc/relay/git-handler.tssrc/renderer/src/components/status-bar/WorkspaceSpaceManagerPanel.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/workspace-space.test.tssrc/renderer/src/store/slices/workspace-space.tssrc/renderer/src/web/web-preload-api.tssrc/shared/workspace-space-types.ts
|
This is the fix for #10951, and the multi-host shape of git.pruneWorktrees looks right. One question about coverage: The relay op is described as handling local, WSL and SSH hosts. Does it also route for Remote Orca Server runtime environments? That's a different transport (paired websocket relay, not an SSH target), and it's the case where the client has no local git at all to prune against — a monitor-only client paired to several servers holds zero owned repos/projects/worktreeMeta, so every worktree row it shows belongs to a remote. If Remote Orca Server hosts don't route through this op, the configuration that needs the Prune button most is the one that won't get it. Related: does the prune also drop the matching workspaceSessionsByHostId records? Clearing the sidebar row while the persisted per-worktree session survives leaves the resurrection surface in #12920 / #12447 in place, and adds to the blast radius in #12918. On one client here that's 79 orphan session records across three paired servers, one of which has never dropped a single record in three days. Detail and evidence in #10951. Happy to test a build against a 3-server fleet (Linux servers, Windows client, Tailscale) if that's useful. |
|
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-08-07T07:50:54Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes. |
Summary
Follow-up to #8409. That PR stopped surfacing prunable worktree registrations (git registry entry whose directory was deleted without
git worktree prune) as live workspaces — including in the Space page, which no longer renders them as dead "Missing" rows. But those registrations still pin their branches as checked out, and there was no in-app way to clean them up.This adds that affordance. It was flagged on #8409 by a reviewer who hit it on macOS: a reboot cleared 16 worktree directories under
/private/tmpwhile their registrations remained, blocking 15 branches, withgit worktree prunein a terminal the only remedy.With this change, the Space scan counts prunable registrations (instead of only dropping them) and shows a small notice when any exist:
Prune runs git's own
git worktree prunefor each affected repo. Git only drops registrations whose directory is gone and preserves locked ones (Orca locks worktrees for active agent sessions), so nothing live is touched; branches and their commits are untouched by design.Screenshots
The new UI is a single notice on the Space page when prunable registrations exist, with a Prune button:
Full page — notice in context (2 stale registrations here; rows still show only the live worktrees):
After clicking Prune — the notice is gone, git's registry is reconciled, and the pruned branches survive:
Captured from a Playwright + Electron run on this branch (rebased onto
mainafter #8409 merged).Implementation
staleRegistrationCountadded toWorkspaceSpaceRepoSummary/WorkspaceSpaceAnalysis; the existing prunable filter now counts what it omits.pruneWorktrees()(local + WSL, read-cache invalidation) and a dedicated relaygit.pruneWorktreesop for SSH. The genericgit.execrelay channel is deliberately read-only, so remote prune needs its own op. An older deployed relay that predates it rejects with "Method not found" → the IPC surfaces a clear "reconnect to update, or rungit worktree prunethere" message instead of a protocol error.worktrees:pruneStaleRegistrationsprunes every store repo matching the id (multi-host-safe), then notifies worktree-change; the store action refreshes the scan. Web/paired clients get an explicit unsupported-here error, matching the existingforgetLocalpattern.Testing
pnpm typecheckpnpm lintpnpm testfor the touched areas (space analysis, git worktree paths, worktree IPC, store slice, web preload)New coverage:
worktree-list-paths.test.ts).pruneWorktrees; SSH repo → provider; old relay ("Method not found") → clear error (worktrees.test.ts).workspace-space-analysis.test.ts).Electron validation: fixture repo with a live worktree + stale registrations; the banner showed the count, a real click on Prune cleared it, git's registry went from N+live to just
main+ live, and everystale-*branch survived. Local review screenshots (uncommitted) are undervalidation-screenshots/.