Skip to content

Show a deleting worktree at once and drop its row without re-reading every project - #228

Merged
yansfil merged 2 commits into
mainfrom
fix/worktree-delete-latency
Sep 28, 2026
Merged

yansfil merged 2 commits into
mainfrom
fix/worktree-delete-latency

Conversation

@yansfil

@yansfil yansfil commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

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.

The chore/old-experiment row is dimmed with a spinner while its worktree is deleted

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.

More evidence

After the removal: the row is gone and the notice reports the deletion

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).

AI tooling: mostly AI tooling; the removal states, timings and trash behavior were checked by hand against the screenshots, measurement output and test assertions.

…every project

The checkout row dims with a spinner from confirmation until Git answers.
A finished removal takes its row out of the catalog in the same frame and
counts itself in the worktree request, so a read that began earlier cannot
bring the row back and only the removed repository is read again.
The host moves the folder aside into the repository's Git directory before
git worktree remove drops the registration, and deletes it in the
background, so a large build folder no longer outlasts the 15 s Git read
bound.
@yansfil
yansfil merged commit 3c891ab into main Sep 28, 2026
7 checks passed
@yansfil
yansfil deleted the fix/worktree-delete-latency branch September 28, 2026 05:49
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.

1 participant