diff --git a/crates/forge_main/src/built_in_commands.json b/crates/forge_main/src/built_in_commands.json index c574c6f8a0..d73a40dee1 100644 --- a/crates/forge_main/src/built_in_commands.json +++ b/crates/forge_main/src/built_in_commands.json @@ -8,6 +8,7 @@ "description": "Display effective resolved configuration in TOML format" }, { + "command": "config-model", "description": "Switch the models [alias: cm]" }, { @@ -138,4 +139,4 @@ "command": "setup", "description": "Setup zsh integration by updating .zshrc" } -] +] \ No newline at end of file diff --git a/crates/forge_main/src/ui.rs b/crates/forge_main/src/ui.rs index 5ba5de69e4..414db4585d 100644 --- a/crates/forge_main/src/ui.rs +++ b/crates/forge_main/src/ui.rs @@ -192,6 +192,11 @@ impl 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!( @@ -199,7 +204,13 @@ impl A + Send + Sync> UI 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(()) } @@ -3716,8 +3727,13 @@ impl 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 { @@ -3744,12 +3760,7 @@ impl 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)