feat(worktree): delete worktrees from the Worktrees view #174

Merged
dries merged 2 commits from feat/worktree-delete into main 2026-06-28 23:02:09 +02:00
Owner

Summary

  • Adds a Delete action to each row in the Worktrees view — closes the gap where ocman created worktrees but never cleaned them up.
  • worktree.Remove shells out to git worktree remove [--force]; git enforces the guards (refuses the main checkout and a dirty tree), classified into ErrMainWorktree / ErrWorktreeDirty.
  • Wired through the hostsvc.Host seam (local + remote gRPC), so it works for remote hosts too. New RemoveWorktree RPC.
  • POST /api/worktree/remove (localhost-only): 404 non-repo, 409 main/dirty, 502 otherwise.
  • UI: per-row Delete with a two-step confirm, disabled on the main worktree, plus a Force delete retry when the tree is dirty (409).

Out of scope (deliberate)

  • Auto-reaper on session end — data-loss risk, needs the state.db ownership tracking v1 avoided. Add when manual delete proves insufficient.

Testing

  • make lint + make test green (1322 frontend tests, full Go suite).
  • New: worktree pkg (happy / main-refused / dirty+force / classify), local Host, 4 handler tests, 2 frontend api tests.
## Summary - Adds a **Delete** action to each row in the Worktrees view — closes the gap where ocman created worktrees but never cleaned them up. - `worktree.Remove` shells out to `git worktree remove [--force]`; git enforces the guards (refuses the main checkout and a dirty tree), classified into `ErrMainWorktree` / `ErrWorktreeDirty`. - Wired through the `hostsvc.Host` seam (local + remote gRPC), so it works for remote hosts too. New `RemoveWorktree` RPC. - `POST /api/worktree/remove` (localhost-only): 404 non-repo, 409 main/dirty, 502 otherwise. - UI: per-row Delete with a two-step confirm, disabled on the main worktree, plus a **Force delete** retry when the tree is dirty (409). ## Out of scope (deliberate) - Auto-reaper on session end — data-loss risk, needs the state.db ownership tracking v1 avoided. Add when manual delete proves insufficient. ## Testing - `make lint` + `make test` green (1322 frontend tests, full Go suite). - New: worktree pkg (happy / main-refused / dirty+force / classify), local Host, 4 handler tests, 2 frontend api tests.
feat(worktree): delete worktrees from the Worktrees view
Some checks failed
CI / Frontend (pull_request) Successful in 3m25s
CI / Backend (pull_request) Successful in 3m37s
CI / Build Desktop (macOS arm64) (pull_request) Successful in 50s
CI / Playwright E2E (pull_request) Successful in 7m18s
CI / Build (pull_request) Successful in 4m20s
CI / Semantic Tag (pull_request) Has been skipped
CI / Coverage Ratchet (pull_request) Failing after 5m19s
5f862e9178
Adds a Delete action to each worktree row, wired through the hostsvc.Host
seam so it works for remote hosts too.

- worktree.Remove shells out to `git worktree remove [--force]`; git
  enforces the guards (refuses the main checkout and a dirty tree),
  classified into ErrMainWorktree / ErrWorktreeDirty.
- Host.RemoveWorktree on the local + remote (gRPC) hosts; new
  RemoveWorktree RPC.
- POST /api/worktree/remove (localhost-only): 404 non-repo, 409
  main/dirty, 502 otherwise.
- UI: per-row Delete with two-step confirm and a Force delete retry on a
  dirty worktree.

Coverage ratchet: pass

Suite Baseline This PR Δ
go 69.40% 69.40% +0.00
frontend 56.96% 57.39% +0.43

Tolerance: -0.1%. Baseline stored on gh-pages.

<!-- coverage-ratchet --> ### Coverage ratchet: ✅ pass | Suite | Baseline | This PR | Δ | | |---|---|---|---|---| | go | 69.40% | 69.40% | +0.00 | ✅ | | frontend | 56.96% | 57.39% | +0.43 | ✅ | _Tolerance: -0.1%. Baseline stored on `gh-pages`._
test(worktree): cover WorktreesView delete flow
All checks were successful
CI / Backend (pull_request) Successful in 2m54s
CI / Frontend (pull_request) Successful in 3m18s
CI / Build Desktop (macOS arm64) (pull_request) Successful in 1m4s
CI / Playwright E2E (pull_request) Successful in 7m27s
CI / Build (pull_request) Successful in 4m39s
CI / Coverage Ratchet (pull_request) Successful in 7m20s
CI / Semantic Tag (pull_request) Has been skipped
db7cd7b18f
Exercises the new per-row delete: two-step confirm, success+reload, dirty
409 -> Force delete retry, and non-dirty error surfacing. Raises
WorktreesView.tsx line coverage from 0% (no prior test) to ~77%.
dries merged commit fa52450461 into main 2026-06-28 23:02:09 +02:00
Sign in to join this conversation.
No description provided.