Skip to content

Let the cleanup sheet choose worktrees left with only finished agent panes - #406

Merged
yansfil merged 3 commits into
mainfrom
fix/cleanup-finished-agent-panes
Oct 4, 2026
Merged

yansfil merged 3 commits into
mainfrom
fix/cleanup-finished-agent-panes

Conversation

@yansfil

@yansfil yansfil commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Closes #394
Related: #390

Summary

A merged worktree whose only panes are an agent that finished or a shell prompt could not be picked in the disk cleanup sheet, because any live pane excluded it.
Now only real use blocks it, and the confirmation closes the leftover panes before removing the folder (never forced).

  • In use: an agent working or waiting on the operator (question, approval, blocked, unknown activity), a delegated agent working or waiting in any checkout or device, a non-shell program in a terminal pane, a listening port.
  • Not in use: finished or idle agents, shell prompts.
  • The worktree cell shows the pane count (terminal mark and number) and the confirm button reads pane N개 닫고 워크트리 M개와 캐시 정리.
  • Each row is re-read right before its panes close; a pane that will not close leaves the row failed (close_refused).

Screenshot of the confirmation (finished agent, 1 pane) is in the local run record; no image is attached.

Review

  • 판단해 주세요: A waiting agent, and an agent whose activity Herdr does not report, also block cache cells, since in_use is shared; judged safer than guessing idle.
  • 판단해 주세요: Descendants that are finished and run in another checkout are not closed with the parent's worktree; they become their own roots.
  • 조심해서 볼 파일: herdr-core/src/worktree_cleanup.rs - close_checkout re-reads use and panes right before pane.close (stale-idle race); confirm order is close then remove.
  • 조심해서 볼 파일: herdr-core/src/runtime/projects.rs - checkout_facts runs under the runtime lock, in-memory only, and walks lineage children (not the close list, which drops unreachable devices).
  • 조심해서 볼 파일: herdr-core/src/worktree_control.rs - only visibility changed on close_checkout_panes, the delete path's close; the primary workspace last-tab rule applies to it as before and a refusal shows as close_refused.
  • 조심해서 볼 파일: herdr-core/src/wire.rs - cleanup_usage_paths now pairs each folder with its pane id.
  • 겹침: worktree_cleanup.rs and the same UI_BEHAVIOR.md section are also edited by the cleanup-main change (verified_merge); I did not touch that function.

Evidence

  • 확인한 것: live::cleanup unit tests (35) cover finished agent and shell pass, waiting/blocked/unknown block, delegated descendant blocks, non-shell program blocks, stranger pane excluded, panes close before removal, close failure keeps the folder, and a pane opened or gone since the review. a_checkout_stays_in_use... (2) cover descendants across checkouts and devices, including a stale device.
  • 확인한 것: web diskCleanup.test.ts 43 passed (pane counts in the plan, waiting agent blocks). Full web unit suite 944 passed, typecheck, lint, build, design contract, removal-boundary and off-lock checks pass.
  • 확인한 것: web/e2e/disk-cleanup.spec.ts 3 passed against an isolated Herdr and hided; the new spec (blocked agent keeps the worktree, finished agent is chosen, its pane closes, folder gone, branch stays) ran 20 times in a row with no failure, as did the 20 repeats of the new core and web unit tests.
  • 확인하지 못한 것: no check against the installed app or the operator's Herdr; the real primary-workspace last-tab refusal on pane.close was not reproduced.
  • 확인하지 못한 것: hide-kit process tests and hided opener_lifecycle failed once in a loaded full cargo test run and passed alone; they are outside this diff.

…panes

In use now means an agent working or waiting, a delegated agent working or waiting anywhere, a non-shell program or a listening port. A worktree with only finished agents and shells is chosen, and the confirmation closes its panes through the delete path before removing without force.
@yansfil
yansfil force-pushed the fix/cleanup-finished-agent-panes branch from ba27676 to f1d3266 Compare October 4, 2026 17:06
@yansfil
yansfil merged commit e8eb354 into main Oct 4, 2026
29 checks passed
@yansfil
yansfil deleted the fix/cleanup-finished-agent-panes branch October 4, 2026 17:26
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.

작업이 끝난 에이전트 pane이 남은 워크트리는 정리 시트에서 고를 수 없다

1 participant