Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/lib/team-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,20 @@ export async function listMembers(teamName: string): Promise<string[] | null> {
return config.members;
}

/** Kill all running workers for a team's members. Best-effort — continues on failure. */
export async function killTeamMembers(teamName: string): Promise<void> {
const config = await getTeam(teamName);
if (!config) return;

for (const member of config.members) {
try {
await killWorkersByName(member);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Scope member shutdown to the target team

Calling killWorkersByName(member) here can terminate workers from other teams because team memberships store generic role names (e.g. engineer, reviewer) and killWorkersByName matches globally on w.role === agentName || w.id === agentName rather than filtering by w.team; after this commit, running genie team done <name> or blocked <name> will now kill same-role agents in unrelated active teams.

Useful? React with 👍 / 👎.

} catch {
// Best-effort — continue with other members
}
}
Comment on lines +434 to +440

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved efficiency, you can parallelize killing the team members' workers using Promise.all. This will initiate all kill operations concurrently rather than sequentially, preventing a delay in killing one worker from blocking the others.

Suggested change
for (const member of config.members) {
try {
await killWorkersByName(member);
} catch {
// Best-effort — continue with other members
}
}
await Promise.all(
config.members.map((member) =>
killWorkersByName(member).catch(() => {
// Best-effort — continue with other members
}),
),
);

}

/** Set team lifecycle status. */
export async function setTeamStatus(teamName: string, status: TeamStatus): Promise<void> {
const filePath = teamFilePath(teamName);
Expand Down
10 changes: 6 additions & 4 deletions src/term-commands/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ export function registerTeamNamespace(program: Command): void {
// team done
team
.command('done <name>')
.description('Mark a team as done')
.description('Mark a team as done and kill all members')
.action(async (name: string) => {
try {
await teamManager.setTeamStatus(name, 'done');
console.log(`Team "${name}" marked as done.`);
await teamManager.killTeamMembers(name);
console.log(`Team "${name}" marked as done. All members killed.`);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error(`Error: ${message}`);
Expand All @@ -172,11 +173,12 @@ export function registerTeamNamespace(program: Command): void {
// team blocked
team
.command('blocked <name>')
.description('Mark a team as blocked')
.description('Mark a team as blocked and kill all members')
.action(async (name: string) => {
try {
await teamManager.setTeamStatus(name, 'blocked');
console.log(`Team "${name}" marked as blocked.`);
await teamManager.killTeamMembers(name);
console.log(`Team "${name}" marked as blocked. All members killed.`);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error(`Error: ${message}`);
Expand Down
Loading