Skip to content

Commit eb9cb29

Browse files
author
Your Name
committed
Only show short name if multiple instances of the name exist
1 parent ca49121 commit eb9cb29

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

cecli/commands/switch_agent.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,19 @@ def get_completions(cls, io, coder, args) -> List[str]:
8787

8888
# Add sub-agent names, excluding the currently active one
8989
if agent_service and agent_service.sub_agents:
90+
# First pass: count name occurrences
91+
name_counts = {}
92+
for uuid, sub_agent_info in agent_service.sub_agents.items():
93+
name_counts[sub_agent_info.name] = name_counts.get(sub_agent_info.name, 0) + 1
94+
95+
# Second pass: only show UUID prefix when name appears multiple times
9096
for uuid, sub_agent_info in agent_service.sub_agents.items():
9197
if uuid != foreground_uuid:
9298
name = sub_agent_info.name
93-
# Always include UUID prefix for sub-agents
94-
names.append(f"{name} ({uuid[:3]})")
99+
if name_counts[name] > 1:
100+
names.append(f"{name} ({uuid[:3]})")
101+
else:
102+
names.append(name)
95103

96104
current_arg = args.strip().lower()
97105
if current_arg:

cecli/tui/widgets/input_container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def _format_sub_agent_pills(sub_agents: list, show_squares: bool = False) -> str
110110
A string like ``"◍ primary ◆ reviewer (a6b)"``.
111111
"""
112112
parts = []
113+
name_counts = {}
114+
for sa in sub_agents:
115+
name_counts[sa["name"]] = name_counts.get(sa["name"], 0) + 1
113116

114117
for sa in sub_agents:
115118
active = sa.get("active", False)
@@ -124,7 +127,7 @@ def _format_sub_agent_pills(sub_agents: list, show_squares: bool = False) -> str
124127

125128
name = sa["name"]
126129
display_name = name
127-
if name != "primary":
130+
if name != "primary" and name_counts[name] > 1:
128131
display_name = f"{name} ({sa['uuid'][:3]})"
129132

130133
parts.append(f"{icon} {display_name}")

0 commit comments

Comments
 (0)