Skip to content
Open
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
27 changes: 19 additions & 8 deletions crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,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 @@ -4362,9 +4373,14 @@ 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, reasoning_effort) = tokio::join!(
async { self.api.get_session_config().await.map(|c| c.model) },
self.get_agent_model(agent_id.clone()),
async {
if let Some(cid) = cid {
self.api.conversation(&cid).await.ok().flatten()
Expand Down Expand Up @@ -4402,12 +4418,7 @@ impl<A: API + ConsoleWriter + 'static, F: Fn(ForgeConfig) -> A + Send + Sync> UI
.and_then(|s| s.parse::<usize>().ok());

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