Skip to content

Lock Supacode worktrees so prune can't drop them#339

Merged
sbertix merged 2 commits into
mainfrom
sbertix/338-prune-worktree
May 19, 2026
Merged

Lock Supacode worktrees so prune can't drop them#339
sbertix merged 2 commits into
mainfrom
sbertix/338-prune-worktree

Conversation

@sbertix
Copy link
Copy Markdown
Collaborator

@sbertix sbertix commented May 19, 2026

Summary

Resolves the disappearing-worktree bug behind #338 by tagging every Supacode-managed worktree with an owned git worktree lock, so any git worktree prune (manual, scheduled, or kicked off by Supacode itself) skips them entirely. Backfill happens on every repo load and the lock is released only when Supacode itself removes the worktree.

  • Lock mechanism (commit 1): writes a JSON-tagged locked payload (owner: "supacode", version/build forensics) to each worktree's git admin entry. Reload reconciles instead of pruning; a transiently offline working dir no longer vanishes from the sidebar.
  • Orphan worktree UX (commit 1): missing-dir worktrees stay visible with an isMissing flag, orange warning icon, and a dedicated detail view offering Delete as the only action. Every shell-spawning path (terminal create/split, run script, deeplinks) is gated so an orphan row can't pivot to a broken cd; CLI deeplinks surface a real error instead of silent ok=true.
  • Failed-repository UI (commit 2): repos that fail to load now get the same orphan treatment — pink-triangle sidebar section that mirrors a healthy repo, Repository unavailable detail view with selectable monospaced path, and a Remove Repository… confirmation alert (Cmd+Enter aware) that drops persisted customization to match the healthy-repo flow.

Test plan

  • make test (lock round-trip, orphan discovery, deeplink-action matrix, failed-repo alert + helper, WindowTitle.failedRepository branch — all pass locally)
  • Create a worktree in Supacode, run `git -C worktree prune` from the CLI: the worktree stays
  • `mv` a worktree directory out from under Supacode: the row stays with an orange triangle; Delete cleans up the admin entry
  • Remove a repo whose path was renamed: the pink-triangle row + detail view show; `Remove Repository` (or Cmd+Enter) clears it
  • Bare-repo regression check: create a worktree in a bare repo layout, hit the same prune scenario

Closes #338

sbertix added 2 commits May 19, 2026 21:23
Resolves #338 by writing a JSON-tagged `locked` payload (`owner: "supacode"`)
to every Supacode-managed worktree's git admin entry. The lock survives any
`git worktree prune` (locked entries are skipped), and Supacode-initiated
removal is the sole release path. Reload reconciles instead of pruning, so
a transiently offline working dir no longer disappears from the sidebar.

Missing-dir worktrees are surfaced explicitly with an `isMissing` flag,
orange warning icon, and a dedicated detail view that offers Delete (the
only sensible action). All shell-spawning entry points (terminal create,
split, run script, deeplink) are gated so an orphan row can't pivot to a
broken `cd`. The CLI socket response surfaces a real error instead of silent
ok=true.

Includes lock-round-trip tests, orphan-discovery tests, and a deeplink test
pinning at least one spawning and one cleanup case of the action matrix.
Repositories that fail to load now get the same orphan treatment as missing
worktrees: a dedicated pink-triangle sidebar section that mirrors a healthy
repository (header, ellipsis menu, selectable row) and a `Repository
unavailable` detail view showing the original path as a monospaced,
selectable line. The path's `.help()` tooltip carries the underlying load
failure for diagnostics.

Removal flows through a `Remove Repository…` confirmation alert that honors
Cmd+Enter, drops the persisted sidebar customization, clears a stale
`.failedRepository` selection from every reload entry point, and matches
the healthy-repo phrasing (`Nothing on disk is changed.`). The window title,
sidebar header, and confirmation alert all resolve a custom title via the
shared `Repository.sidebarDisplayName` helper.

Includes reducer tests for the alert + helper, plus a `WindowTitle` case
for the failed-repository selection branch.
@sbertix sbertix enabled auto-merge (squash) May 19, 2026 19:31
@tuist
Copy link
Copy Markdown

tuist Bot commented May 19, 2026

🛠️ Tuist Run Report 🛠️

Builds 🔨

Scheme Status Duration Commit
supacode 2m 33s 2fe9041da

@sbertix sbertix merged commit 7f1b2bb into main May 19, 2026
2 checks passed
@sbertix sbertix deleted the sbertix/338-prune-worktree branch May 19, 2026 19:39
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.

Setting to prevent worktree prune on worktree create

1 participant