Skip to content

fix(cli): print the "New leader" note after removing a team leader#295

Open
Osamaali313 wants to merge 1 commit into
TinyAGI:mainfrom
Osamaali313:fix/team-remove-new-leader-note
Open

fix(cli): print the "New leader" note after removing a team leader#295
Osamaali313 wants to merge 1 commit into
TinyAGI:mainfrom
Osamaali313:fix/team-remove-new-leader-note

Conversation

@Osamaali313

Copy link
Copy Markdown

Problem

In teamRemoveAgent (packages/cli/src/team.ts), when the removed agent is the team leader the command prompts for a replacement, then builds the success message with an always-false condition:

team.agents = remaining;
team.leader_agent = newLeader;   // leader_agent is now === newLeader
writeSettings(settings);

p.log.success(`Removed @${agentId} from team '${teamId}'.${newLeader !== team.leader_agent ? ` New leader: @${newLeader}.` : ''}`);

team.leader_agent was just assigned newLeader, so newLeader !== team.leader_agent is structurally always false. The New leader: @<x>. suffix therefore never prints — even when the removed agent was the leader and the user explicitly picked a replacement via the prompt. The function goes out of its way to detect leader removal and prompt for a new leader, which shows the note was meant to render.

Reproduction

Team dev = [alice, bob], leader alice; remove alice, choose bob:

  • Before: Removed @alice from team 'dev'.
  • After: Removed @alice from team 'dev'. New leader: @bob.

Fix

Capture the previous leader before the assignment and compare against it:

team.agents = remaining;
const previousLeader = team.leader_agent;
team.leader_agent = newLeader;
writeSettings(settings);

p.log.success(`Removed @${agentId} from team '${teamId}'.${newLeader !== previousLeader ? ` New leader: @${newLeader}.` : ''}`);

Severity note (being upfront): this is a genuine always-false-condition logic bug, but its only effect is a missing informational CLI line — team state is written correctly either way. I verified the corrected ternary RED→GREEN (changed leader → note prints; unchanged → no note). The function is interactive (@clack/prompts), and the repo has no test harness, so there's no unit test to add.

teamRemoveAgent picks a replacement leader, then does
`team.leader_agent = newLeader` and immediately tests
`newLeader !== team.leader_agent` to decide whether to append " New leader:
@x." to the success message. Because leader_agent was just assigned newLeader,
that comparison is always false, so the note never prints -- even when the
removed agent was the leader and the user explicitly chose a replacement.
Capture the previous leader before the assignment and compare against it.
Copilot AI review requested due to automatic review settings July 15, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants