fix(agents): show cloud builtin in /agents UI

This commit is contained in:
James Peter
2025-10-06 10:14:03 +10:00
parent 4cf2ddf493
commit a3d14642e8
4 changed files with 33 additions and 24 deletions
+4
View File
@@ -4,6 +4,10 @@
//! explicit per‑mode args configured) and by the TUI editor (to prefill the
//! read‑only/write parameter fields with sensible defaults).
/// Canonical list of built-in agent names used when no `[[agents]]` entries
/// are configured.
pub const DEFAULT_AGENT_NAMES: &[&str] = &["claude", "gemini", "qwen", "code", "cloud"];
/// Return default CLI arguments (excluding the prompt flag) for a given agent
/// `name` and access mode.
///
+3 -4
View File
@@ -58,8 +58,7 @@ use crate::protocol::WebSearchCompleteEvent;
use code_protocol::mcp_protocol::AuthMode;
use crate::account_usage;
use crate::auth_accounts;
const DEFAULT_AGENT_MODELS: &[&str] = &["claude", "gemini", "qwen", "code", "cloud"];
use crate::agent_defaults::DEFAULT_AGENT_NAMES;
use code_protocol::models::WebSearchAction;
use code_protocol::protocol::RolloutItem;
use shlex::split as shlex_split;
@@ -3185,7 +3184,7 @@ async fn submission_loop(
config.tools_web_search_allowed_domains.clone();
let mut agent_models: Vec<String> = if config.agents.is_empty() {
DEFAULT_AGENT_MODELS
DEFAULT_AGENT_NAMES
.iter()
.map(|s| (*s).to_string())
.collect()
@@ -3193,7 +3192,7 @@ async fn submission_loop(
get_enabled_agents(&config.agents)
};
if agent_models.is_empty() {
agent_models = DEFAULT_AGENT_MODELS
agent_models = DEFAULT_AGENT_NAMES
.iter()
.map(|s| (*s).to_string())
.collect();
+2 -7
View File
@@ -1,3 +1,4 @@
use crate::agent_defaults::DEFAULT_AGENT_NAMES;
use crate::config_types::AgentConfig;
use crate::config_types::SubagentCommandConfig;
@@ -17,13 +18,7 @@ pub fn get_enabled_agents(agents: &[AgentConfig]) -> Vec<String> {
/// Get default models if no agents are configured
fn get_default_models() -> Vec<String> {
vec![
"claude".to_string(),
"gemini".to_string(),
"qwen".to_string(),
"code".to_string(),
"cloud".to_string(),
]
DEFAULT_AGENT_NAMES.iter().map(|name| (*name).to_string()).collect()
}
/// Resolution result for a subagent command.
+24 -13
View File
@@ -24,6 +24,7 @@ use code_common::elapsed::format_duration;
use code_common::model_presets::ModelPreset;
use code_common::model_presets::builtin_model_presets;
use code_core::ConversationManager;
use code_core::agent_defaults::DEFAULT_AGENT_NAMES;
use code_core::config::Config;
use code_core::git_info::CommitLogEntry;
use code_core::config_types::AgentConfig;
@@ -10732,14 +10733,16 @@ impl ChatWidget<'_> {
}
let name = a.name.clone();
let cmd = a.command.clone();
let builtin = matches!(cmd.as_str(), "code" | "codex");
let builtin = matches!(cmd.as_str(), "code" | "codex" | "cloud");
to_check.push((name, cmd, builtin));
}
} else {
to_check.push(("claude".to_string(), "claude".to_string(), false));
to_check.push(("gemini".to_string(), "gemini".to_string(), false));
to_check.push(("qwen".to_string(), "qwen".to_string(), false));
to_check.push(("code".to_string(), "code".to_string(), true));
for name in DEFAULT_AGENT_NAMES {
let name = (*name).to_string();
let cmd = name.clone();
let builtin = matches!(name.as_str(), "code" | "codex" | "cloud");
to_check.push((name, cmd, builtin));
}
}
// Helper: PATH presence + resolved path
@@ -10979,9 +10982,18 @@ impl ChatWidget<'_> {
}
}
fn is_builtin_agent(name: &str, command: &str) -> bool {
name.eq_ignore_ascii_case("code")
|| name.eq_ignore_ascii_case("codex")
|| name.eq_ignore_ascii_case("cloud")
|| command.eq_ignore_ascii_case("code")
|| command.eq_ignore_ascii_case("codex")
|| command.eq_ignore_ascii_case("cloud")
}
let mut agent_rows: Vec<(String, bool, bool, String)> = Vec::new();
// Desired presentation order for known agents
let preferred = ["code", "claude", "gemini", "qwen"];
// Desired presentation order for known agents, matching CLI defaults.
let preferred = DEFAULT_AGENT_NAMES;
// Name -> config lookup
let mut extras: Vec<String> = Vec::new();
for a in &self.config.agents {
@@ -10991,10 +11003,7 @@ impl ChatWidget<'_> {
}
extras.sort();
// Build ordered list of names
let mut ordered: Vec<String> = Vec::new();
for p in preferred {
ordered.push(p.to_string());
}
let mut ordered: Vec<String> = preferred.iter().map(|p| (*p).to_string()).collect();
for e in extras {
if !ordered.iter().any(|n| n.eq_ignore_ascii_case(&e)) {
ordered.push(e);
@@ -11008,7 +11017,8 @@ impl ChatWidget<'_> {
.iter()
.find(|a| a.name.eq_ignore_ascii_case(name))
{
let installed = command_exists(&cfg.command);
let builtin = is_builtin_agent(&cfg.name, &cfg.command);
let installed = builtin || command_exists(&cfg.command);
agent_rows.push((
cfg.name.clone(),
cfg.enabled,
@@ -11018,7 +11028,8 @@ impl ChatWidget<'_> {
} else {
// Default command = name, enabled=true, installed based on PATH
let cmd = name.clone();
let installed = command_exists(&cmd);
let builtin = is_builtin_agent(name, &cmd);
let installed = builtin || command_exists(&cmd);
// Keep display name as given (e.g., "code")
agent_rows.push((name.clone(), true, installed, cmd));
}