fix(cli): print the "New leader" note after removing a team leader#295
Open
Osamaali313 wants to merge 1 commit into
Open
fix(cli): print the "New leader" note after removing a team leader#295Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.leader_agentwas just assignednewLeader, sonewLeader !== team.leader_agentis structurally alwaysfalse. TheNew 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], leaderalice; removealice, choosebob:Removed @alice from team 'dev'.Removed @alice from team 'dev'. New leader: @bob.Fix
Capture the previous leader before the assignment and compare against it:
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.