Skip to content

Commit b0074b8

Browse files
fix(command-list): deduplicate agent names in list commands porcelain output (#3011)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 2ef9159 commit b0074b8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/forge_main/src/model.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,18 @@ impl AppCommand {
759759
| AppCommand::Rename { .. }
760760
)
761761
}
762+
763+
/// Returns true for variants that are pure agent-switch shorthands whose
764+
/// canonical name matches a built-in agent (forge, muse, sage). These
765+
/// commands are already emitted as AGENT rows by the agent-info loop in
766+
/// `on_show_commands`, so they must be excluded from the COMMAND loop to
767+
/// avoid duplicate entries in `list commands --porcelain`.
768+
pub fn is_agent_switch(&self) -> bool {
769+
matches!(
770+
self,
771+
AppCommand::Forge | AppCommand::Muse | AppCommand::Sage
772+
)
773+
}
762774
}
763775

764776
#[cfg(test)]

crates/forge_main/src/ui.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,10 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
13331333
// the list always stays in sync with what the REPL actually supports.
13341334
// Internal/meta variants (Message, Custom, Shell, AgentSwitch, Rename)
13351335
// are excluded via is_internal().
1336-
for cmd in AppCommand::iter().filter(|c| !c.is_internal()) {
1336+
// Agent-switch shorthands (forge, muse, sage) are excluded via
1337+
// is_agent_switch() because they are already emitted as AGENT rows
1338+
// by the agent-info loop below, and must not appear twice.
1339+
for cmd in AppCommand::iter().filter(|c| !c.is_internal() && !c.is_agent_switch()) {
13371340
info = info
13381341
.add_title(cmd.name())
13391342
.add_key_value("type", CommandType::Command)

0 commit comments

Comments
 (0)