()
| 574 | * Registered with gracefulShutdown from init.ts. |
| 575 | */ |
| 576 | export async function cleanupSessionTeams(): Promise<void> { |
| 577 | const sessionCreatedTeams = getSessionCreatedTeams() |
| 578 | if (sessionCreatedTeams.size === 0) return |
| 579 | const teams = Array.from(sessionCreatedTeams) |
| 580 | logForDebugging( |
| 581 | `cleanupSessionTeams: removing ${teams.length} orphan team dir(s): ${teams.join(', ')}`, |
| 582 | ) |
| 583 | // Kill panes first — on SIGINT the teammate processes are still running; |
| 584 | // deleting directories alone would orphan them in open tmux/iTerm2 panes. |
| 585 | // (TeamDeleteTool's path doesn't need this — by then teammates have |
| 586 | // gracefully exited and useInboxPoller has already closed their panes.) |
| 587 | await Promise.allSettled(teams.map(name => killOrphanedTeammatePanes(name))) |
| 588 | await Promise.allSettled(teams.map(name => cleanupTeamDirectories(name))) |
| 589 | sessionCreatedTeams.clear() |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Best-effort kill of all pane-backed teammate panes for a team. |
no test coverage detected