MCPcopy
hub / github.com/codeaashu/claude-code / cleanupSessionTeams

Function cleanupSessionTeams

src/utils/swarm/teamHelpers.ts:576–590  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

574 * Registered with gracefulShutdown from init.ts.
575 */
576export 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.

Callers 1

init.tsFile · 0.85

Calls 5

getSessionCreatedTeamsFunction · 0.85
logForDebuggingFunction · 0.85
cleanupTeamDirectoriesFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected