[Bugfix #389] Fix: Kill shellper processes during af cleanup - #390
Merged
waleedkadous merged 1 commit intoFeb 17, 2026
Merged
Conversation
Previously, af cleanup relied solely on the Tower REST API to kill shellper processes. This silently failed when Tower wasn't running, the terminal was already removed from Tower's registry, or Tower was restarted — leaving shellper processes (and their PTY children like Claude) orphaned and consuming resources. Added killShellperProcesses() that searches ps output for shellper-main.js processes whose JSON config cwd matches the builder's worktree path, and kills them via process group signal (SIGTERM to -pid). This runs after the Tower API kill attempt as a reliable fallback for all non-shell builders.
waleedkadous
deleted the
builder/bugfix-389-af-cleanup-doesn-t-kill-shellp
branch
February 17, 2026 09:27
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
Fixes #389
Root Cause
af cleanuprelied exclusively on the Tower REST API (TowerClient.killTerminal()) to kill shellper processes. This silently fails when:In all these cases, the shellper process and its PTY children (Claude, bash) are left running as orphans.
Fix
Added
killShellperProcesses(worktreePath)incleanup.tsthat:ps -ww -eo pid,argsoutput forshellper-main.jsprocessescwdfield (prevents false positives from partial path prefixes)SIGTERMto-pid) to also terminate PTY childrenpsisn't available or no processes are foundTest Plan
cleanup-shellper-kill.test.ts, 9 tests)cleanup-task-builders.test.ts, 13 tests)