Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/forge_main/src/built_in_commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"description": "Display effective resolved configuration in TOML format"
},
{
"command": "config-model",
"description": "Switch the models [alias: cm]"
},
{
Expand Down Expand Up @@ -138,4 +139,4 @@
"command": "setup",
"description": "Setup zsh integration by updating .zshrc"
}
]
]
27 changes: 19 additions & 8 deletions crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,25 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI

// Update the app config with the new operating agent.
self.api.set_active_agent(agent.id.clone()).await?;

// Update model tracking to reflect the new agent's model
let model = self.get_agent_model(Some(agent.id.clone())).await;
self.update_model(model.clone());

let name = agent.id.as_str().to_case(Case::UpperSnake).bold();

let title = format!(
"∙ {}",
agent.title.as_deref().unwrap_or(MISSING_AGENT_TITLE)
)
.dimmed();
self.writeln_title(TitleFormat::action(format!("{name} {title}")))?;

// Show model info if agent uses a specific model
let model_info = model
.map(|m| format!(" ∙ model: {m}").dimmed().to_string())
.unwrap_or_default();

self.writeln_title(TitleFormat::action(format!("{name} {title}{model_info}")))?;

Ok(())
}
Expand Down Expand Up @@ -3716,8 +3727,13 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
.filter(|text| !text.trim().is_empty())
.and_then(|str| ConversationId::from_str(str.as_str()).ok());

let agent_id = std::env::var("_FORGE_ACTIVE_AGENT")
.ok()
.filter(|text| !text.trim().is_empty())
.map(AgentId::new);

// Make IO calls in parallel
let (model_id, conversation) = tokio::join!(self.api.get_default_model(), async {
let (model_id, conversation) = tokio::join!(self.get_agent_model(agent_id.clone()), async {
if let Some(cid) = cid {
self.api.conversation(&cid).await.ok().flatten()
} else {
Expand All @@ -3744,12 +3760,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
.unwrap_or(true); // Default to true

let rprompt = ZshRPrompt::from_config(&self.config)
.agent(
std::env::var("_FORGE_ACTIVE_AGENT")
.ok()
.filter(|text| !text.trim().is_empty())
.map(AgentId::new),
)
.agent(agent_id)
.model(model_id)
.token_count(conversation.and_then(|conversation| conversation.token_count()))
.cost(cost)
Expand Down
Loading