diff --git a/plan2code-app/src-tauri/src/agent_manager.rs b/plan2code-app/src-tauri/src/agent_manager.rs index 686b861..ce0724b 100644 --- a/plan2code-app/src-tauri/src/agent_manager.rs +++ b/plan2code-app/src-tauri/src/agent_manager.rs @@ -46,6 +46,13 @@ pub struct AgentSnapshot { /// The running (or last started) agent's permission mode, so the bar's /// note can name it instead of assuming bypass. pub mode: Option, + /// The model the agent was started on, shown beside its name. `None` when + /// it runs on its own default, which the app cannot know. + #[serde(skip_serializing_if = "Option::is_none")] + pub model: Option, + /// The effort the agent was started with, when its kind takes one. + #[serde(skip_serializing_if = "Option::is_none")] + pub effort: Option, /// What the last Restart left for the dashboard, for the bar. #[serde(rename = "briefNote", skip_serializing_if = "Option::is_none")] pub brief_note: Option, @@ -398,9 +405,9 @@ impl AgentManager { lock(&self.shared.inner).replay.clone() } - /// The model and effort the current (or last) start chose. The bar only - /// ever needs `snapshot`'s `kind` and `mode`; this exists so a test can - /// confirm Restart keeps the other two of the four just as unchanged. + /// The model and effort the current (or last) start chose, the same two + /// `snapshot` sends to the bar; a test uses this to confirm Restart keeps + /// them unchanged. pub fn model_and_effort(&self) -> (Option, Option) { match &lock(&self.shared.inner).last_start { Some((choice, _)) => (choice.model.clone(), choice.effort.clone()), @@ -482,6 +489,14 @@ impl Shared { .as_ref() .map(|(choice, _)| choice.kind.id().to_string()), mode: inner.last_start.as_ref().map(|(choice, _)| choice.mode), + model: inner + .last_start + .as_ref() + .and_then(|(choice, _)| choice.model.clone()), + effort: inner + .last_start + .as_ref() + .and_then(|(choice, _)| choice.effort.clone()), generation: self.generation.load(Ordering::SeqCst), brief_note: inner.brief_note.clone(), } diff --git a/plan2code-app/src-tauri/tests/agent_manager.rs b/plan2code-app/src-tauri/tests/agent_manager.rs index c09631c..5d2de6b 100644 --- a/plan2code-app/src-tauri/tests/agent_manager.rs +++ b/plan2code-app/src-tauri/tests/agent_manager.rs @@ -197,6 +197,49 @@ fn restart_keeps_the_previous_agent_kind_mode_model_and_effort() { h.manager.stop(); } +#[test] +fn snapshot_carries_the_model_and_effort_for_the_bar_only_when_known() { + let mut h = Harness::new(); + h.manager + .start( + Agent::Builtin(builtin_entry("codex").unwrap()), + Some("gpt-5".to_string()), + Some("high".to_string()), + PermissionMode::Checked, + None, + ) + .expect("start the fake agent"); + h.wait_for_output(READY, 1); + let known = h.manager.snapshot(); + assert_eq!(known.model.as_deref(), Some("gpt-5")); + assert_eq!(known.effort.as_deref(), Some("high")); + let json = serde_json::to_value(&known).unwrap(); + assert_eq!(json["model"], "gpt-5"); + assert_eq!(json["effort"], "high"); + h.manager.stop(); + + h.manager + .start( + Agent::Builtin(builtin_entry("codex").unwrap()), + None, + None, + PermissionMode::Checked, + None, + ) + .expect("start the fake agent on its own model"); + h.wait_for_output(READY, 2); + let unknown = h.manager.snapshot(); + assert_eq!(unknown.model, None); + assert_eq!(unknown.effort, None); + let json = serde_json::to_value(&unknown).unwrap(); + assert!(json.get("model").is_none(), "an unknown model is left out"); + assert!( + json.get("effort").is_none(), + "an unknown effort is left out" + ); + h.manager.stop(); +} + #[test] fn restart_between_steps_replaces_the_agent_at_once() { let mut h = Harness::new(); diff --git a/plan2code-app/ui/app.js b/plan2code-app/ui/app.js index b267c13..ce03d66 100644 --- a/plan2code-app/ui/app.js +++ b/plan2code-app/ui/app.js @@ -18,6 +18,7 @@ const agentDotEl = document.getElementById('agent-dot'); const agentNameEl = document.getElementById('agent-name'); const agentEndedEl = document.getElementById('agent-ended'); const agentBypassEl = document.getElementById('agent-bypass'); +const agentModelEl = document.getElementById('agent-model'); const agentNoneEl = document.getElementById('agent-none'); const agentStatusEl = document.getElementById('agent-status'); const restartBtn = document.getElementById('agent-restart'); @@ -166,6 +167,12 @@ function applyAgentState(next, { skipReset } = {}) { agentNameEl.textContent = active || ended ? label || 'The agent' : ''; agentDotEl.className = `agent-dot${active ? (bypassActive ? ' is-warn' : ' is-ok') : ''}`; agentEndedEl.hidden = !ended; + // The model and effort the app started it with, when it knows them: an agent + // on its own default model has none to show, and an effort needs a model. + const modelText = agent.model ? (agent.effort ? `${agent.model} ยท ${agent.effort}` : agent.model) : ''; + agentModelEl.textContent = active || ended ? modelText : ''; + agentModelEl.hidden = !agentModelEl.textContent; + agentModelEl.title = agentModelEl.textContent ? `Started on ${agentModelEl.textContent}` : ''; agentBypassEl.hidden = !bypassActive; renderAgentMenuHead(label || 'The agent', { active, ended, bypassActive }); if (agentMenu.hidden === false && agentMenuBtn.hidden) closeBarMenus(); diff --git a/plan2code-app/ui/index.html b/plan2code-app/ui/index.html index 995ab72..58d3ac2 100644 --- a/plan2code-app/ui/index.html +++ b/plan2code-app/ui/index.html @@ -45,7 +45,8 @@ .agent-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #666; } .agent-dot.is-ok { background: #6a9955; } .agent-dot.is-warn { background: #d7ba7d; } - #agent-ended { color: var(--ink-3); font-weight: 400; } + #agent-ended, #agent-model { color: var(--ink-3); font-weight: 400; } + #agent-model { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } #agent-bypass { flex: none; font-size: 11px; font-weight: 600; line-height: 1.3; padding: 0 7px; border-radius: 999px; border: 1px solid #d7ba7d; color: #d7ba7d; } #agent-none { color: var(--ink-3); } #agent-status { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 320px; } @@ -283,7 +284,7 @@ - + No agent