fix(polecat): kill orphan sessions and clear stale hooks during allocation (#448)
ReconcilePool now detects and kills orphan tmux sessions (sessions without corresponding polecat directories). This prevents allocation from being blocked by broken state from crashed polecats. Changes: - Add tmux to Manager to check for orphan sessions during reconciliation - Add ReconcilePoolWith for testable session/directory reconciliation logic - Always clear hook_bead slot when reopening agent beads (fixes stale hooks) - Prune stale git worktree entries during reconciliation Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -221,7 +221,8 @@ func runPolecatIdentityAdd(cmd *cobra.Command, args []string) error {
|
||||
// Generate name if not provided
|
||||
if polecatName == "" {
|
||||
polecatGit := git.NewGit(r.Path)
|
||||
mgr := polecat.NewManager(r, polecatGit)
|
||||
t := tmux.NewTmux()
|
||||
mgr := polecat.NewManager(r, polecatGit, t)
|
||||
polecatName, err = mgr.AllocateName()
|
||||
if err != nil {
|
||||
return fmt.Errorf("generating polecat name: %w", err)
|
||||
@@ -294,7 +295,7 @@ func runPolecatIdentityList(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// Check if worktree exists
|
||||
worktreeExists := false
|
||||
mgr := polecat.NewManager(r, nil)
|
||||
mgr := polecat.NewManager(r, nil, t)
|
||||
if p, err := mgr.Get(name); err == nil && p != nil {
|
||||
worktreeExists = true
|
||||
}
|
||||
@@ -396,7 +397,7 @@ func runPolecatIdentityShow(cmd *cobra.Command, args []string) error {
|
||||
// Check worktree and session
|
||||
t := tmux.NewTmux()
|
||||
polecatMgr := polecat.NewSessionManager(t, r)
|
||||
mgr := polecat.NewManager(r, nil)
|
||||
mgr := polecat.NewManager(r, nil, t)
|
||||
|
||||
worktreeExists := false
|
||||
var clonePath string
|
||||
|
||||
Reference in New Issue
Block a user