Skip to content

Commit 88b471b

Browse files
author
Greyforge Admin
committed
Clarify agent list hidden counts
1 parent 7954d02 commit 88b471b

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

  • src/cortex-cli/src/agent_cmd/handlers

src/cortex-cli/src/agent_cmd/handlers/list.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ pub async fn run_list(args: ListArgs) -> Result<()> {
3232

3333
let agents = load_all_agents()?;
3434

35-
// Filter agents
36-
let mut filtered: Vec<_> = agents
35+
// Apply mode and name filters first, then hide hidden agents unless --all is set.
36+
// The footer uses this same matching population so hidden counts and role counts
37+
// describe the same set of agents.
38+
let matching_agents: Vec<_> = agents
3739
.iter()
3840
.filter(|a| {
39-
// Filter by visibility
40-
if !args.all && a.hidden {
41-
return false;
42-
}
4341
// Filter by mode
4442
if args.primary && !matches!(a.mode, AgentMode::Primary | AgentMode::All) {
4543
return false;
@@ -56,6 +54,11 @@ pub async fn run_list(args: ListArgs) -> Result<()> {
5654
true
5755
})
5856
.collect();
57+
let mut filtered: Vec<_> = matching_agents
58+
.iter()
59+
.copied()
60+
.filter(|a| args.all || !a.hidden)
61+
.collect();
5962

6063
// Sort by display_name (if present) or name for user-friendly ordering
6164
// This ensures agents are listed in the order users expect (by visible name)
@@ -118,26 +121,31 @@ pub async fn run_list(args: ListArgs) -> Result<()> {
118121
);
119122
}
120123

121-
let primary_count = filtered
124+
let hidden_count = if args.all {
125+
0
126+
} else {
127+
matching_agents.iter().filter(|a| a.hidden).count()
128+
};
129+
let count_population = if hidden_count > 0 {
130+
&matching_agents
131+
} else {
132+
&filtered
133+
};
134+
135+
let primary_count = count_population
122136
.iter()
123137
.filter(|a| matches!(a.mode, AgentMode::Primary | AgentMode::All))
124138
.count();
125-
let subagent_count = filtered
139+
let subagent_count = count_population
126140
.iter()
127141
.filter(|a| matches!(a.mode, AgentMode::Subagent | AgentMode::All))
128142
.count();
129143

130-
// Calculate hidden agents count
131-
let hidden_count = if !args.all {
132-
agents.len() - filtered.len()
133-
} else {
134-
0
135-
};
136-
137144
if hidden_count > 0 {
138145
println!(
139-
"\nShowing {} agents ({} primary, {} subagents, {} hidden - use --all to show all)",
146+
"\nShowing {} of {} agents ({} primary, {} subagents total, {} hidden - use --all to show all)",
140147
filtered.len(),
148+
matching_agents.len(),
141149
primary_count,
142150
subagent_count,
143151
hidden_count

0 commit comments

Comments
 (0)