Repository navigation
Let Delete worktree warn and offer choices instead of blocking - #224
Merged
Merged
Conversation
The deletion gate now refuses only the main worktree. Dirt, a nested worktree, the base branch and an unreadable status become warnings, and the dialog offers Also delete branch (-d merged, -D unmerged with the commit count) and a required Discard checkbox that removes with --force. The agents the closing panes stop are listed once by name and state, the menu item is enabled on device rows and before Git is read, and every refusal or failure is shown in the dialog with the choices offered again.
…ead unmerged branch
…choice The confirmation now offers Discard (--force) and deleting an unmerged branch (-D), so the invariant checks that each force is tied to that recorded choice and that the Overview cleanup still never forces.
yansfil
added a commit
that referenced
this pull request
Sep 28, 2026
…every project (#228) Related: #224 (the dialog options this builds on) ## Summary After confirming `Delete worktree…`, the sidebar row looked untouched, and it stayed after the dialog said "Deleted" until every project's Git state was re-read. The row is now dimmed with a spinner from the confirmation, cannot be opened, and leaves within about a second of the removal finishing. A finished removal drops its row from the catalog in the same frame; only the removed repository is read again, not every project. The host moves the folder aside into the repository's Git directory, lets `git worktree remove` drop only the registration, and deletes the files in the background. Before, a 1.5 GB build folder with 400k files took 38.9 s in `git worktree remove`, past the 15 s Git read bound that killed it.  ## Review - **Needs your judgment**: the move-aside design. Chosen over a longer deadline because the row can leave as soon as Git forgets the worktree, however long the deletion takes. - **Needs your judgment**: a removed folder waits in `<git common dir>/hide-removed/` until a background thread deletes it. A leftover from a stopped process is swept by the next removal in that repository, not at startup. - **Needs your judgment**: while removing, the row's context menu opens nothing (empty), so `Open` and a second `Delete worktree…` are unreachable. - **Files to watch**: `hide-host/src/worktrees.rs` (failure path, destructive): `set_aside` moves only when Git would remove (registered, not main, not locked, clean unless forced); a refusal moves the folder back; `sweep_trash` deletes an entry only once Git's admin folder no longer registers it. - **Files to watch**: `herdr-core/src/runtime/projects.rs` (runtime mutex): `drop_removed_worktree` edits the catalog in memory under the lock; no Git or filesystem work was added there. - **Files to watch**: `herdr-core/src/session_sync/coordinator.rs`: the navigator is rebuilt on the 250 ms wake that sees `WorktreeRequest::removals` move, since the next read may find nothing new. - **Files to watch**: `herdr-core/src/worktrees.rs`: `removals` rides through the reader and back, so a read that started before the removal cannot bring the row back. ## Evidence - **Confirmed**: confirm-to-row-gone in the web shell against an isolated Herdr, 5 cloned projects with 2 extra worktrees each, a real 2.2 GB `target/` copied into the deleted worktree, 3 trials each (load average 7 to 10). | | row gone, idle | row gone, driven (commit every 300 ms in another project) | | --- | --- | --- | | before (bac8658) | 2.2 / 2.3 / 7.2 s | 9.0 / 9.7 / 9.8 s | | after | 0.49 / 0.72 / 1.03 s | 0.82 / 0.87 / 1.02 s | The dimmed row appears 10 to 23 ms after the confirm click; the dialog's "finished" arrives at 0.4 to 0.9 s in both builds. - **Confirmed**: host tests cover a 5,000-file build folder removed by setting it aside with the trash drained, Git's own dirty and locked refusals leaving the folder in place, and a stopped-midway entry kept until a retry drops the registration and deletes it once. - **Confirmed**: runtime tests cover the row dropped without a global re-read, an older read unable to restore it, a newer read restoring a re-created worktree, and a failed removal keeping its row. - **Confirmed**: `e2e/worktree-delete.spec.ts` now also observes the dimmed, spinner, disabled row during removal; `verify-cargo.sh test`, `verify-cargo.sh lint`, `verify-web.sh`, the design contract and the `scripts` lane checks pass locally. - **Not confirmed**: not run in the packaged desktop app; the measurements and screenshots are the web shell served by a dev `hided`. - **Not confirmed**: the cross-volume fallback (in place, 60 s `REMOVE_DEADLINE`) has no test; device removals are unchanged and still re-read the device's catalog. - **Not confirmed**: a trash entry whose deletion fails (for example a read-only folder inside it) stays until the next sweep and is only logged. <details><summary>More evidence</summary>  Review follow-ups not taken: a reader-level test that drives a real in-flight read across a removal, and a note that the clean check and the rename are two steps (the confirmation rechecks status just before). </details> **AI tooling**: mostly AI tooling; the removal states, timings and trash behavior were checked by hand against the screenshots, measurement output and test assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Delete worktree…was disabled whenever a worktree was dirty, held a nested worktree, sat on the base branch, could not be read, or lived on another device, so the operator had to leave hide to clean up.The item is now always enabled on a linked worktree, and the dialog shows what would be lost and lets the operator choose.
The core gate refuses only the main worktree. Everything else is a warning.
Also delete branchusesgit branch -dwhen the branch is merged and-D(with the commit count) when it is not.A required
Discard …checkbox removes a dirty or nested worktree withgit worktree remove --force.One line names every agent the closing panes stop, and each refusal or failure appears in the dialog with the choices offered again.
Review
Discard any uncommitted changes, and a branch whose merge state Git cannot tell is deleted with-Dunder a warning.hide-host/src/worktrees.rs(failure path, destructive):discard_changesskips the dirt, nested-worktree and ignored-repository rechecks and adds--force.herdr-core/src/runtime/projects.rs(runtime mutex):worktree_removal_allowedrefuses a discard the current row needs but the payload did not accept.protected_base_branchis dropped only for a worktree already on the base.scripts/check-worktree-removal-boundary.sh(gate changed): it forbade any-Dor--force, which is the policy the operator reversed. It now requires each force to be tied to the recorded choice (discard_changes,force_delete_branch), and still forbids any force in the Overview cleanup.hide-host/src/worktrees.rsConfirmedRemoval(device protocol): the new fields are#[serde(default)], so an older device helper does the safe non-force removal.Evidence
e2e/worktree-delete.spec.tscovers the same flow and checks the row leaves, the folder is gone and the branch is deleted.e2e/sidebar-menus.spec.tspasses.-D,-dkeeping an unmerged branch under discard, a nested worktree removed only with discard, and late dirt refused with the new plain message.worktree.remove_unacceptedwithout discard, then removed by the device helper with-Donce accepted.verify-cargo.sh test -p herdr-core -p hide-host(909 core tests),verify-cargo.sh lintandverify-web.shall pass.More evidence
Review follow-ups not taken in this PR: show a locked worktree as its own warning instead of Git's raw refusal, and mention ignored nested repositories in the Discard copy.
AI tooling: mostly AI tooling; the dialog states, warnings and removal outcomes were checked by hand against the native captures and test assertions.