Show the agent's model and effort in the app bar

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-09 15:05:12 -08:00
1 parent 02380fa6fe
commit b585eccd5a
4 files changed
+71 -5

No files matched your search

+18 -3
View File
@@ -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<PermissionMode>,
/// 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<String>,
/// The effort the agent was started with, when its kind takes one.
#[serde(skip_serializing_if = "Option::is_none")]
pub effort: Option<String>,
/// What the last Restart left for the dashboard, for the bar.
#[serde(rename = "briefNote", skip_serializing_if = "Option::is_none")]
pub brief_note: Option<String>,
@@ -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<String>, Option<String>) {
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(),
}
@@ -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();
+7
View File
@@ -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();
+3 -2
View File
@@ -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 @@
<button id="project-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="project-menu" hidden><span id="project-name"></span><span class="bar-caret" aria-hidden="true">&#9662;</span></button>
<!-- Whenever an agent exists, running or ended, just left of its menu. -->
<button id="agent-restart" hidden>New Session</button>
<button id="agent-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="agent-menu" hidden><span id="agent-dot" class="agent-dot" aria-hidden="true"></span><span id="agent-name"></span><span id="agent-ended" hidden>ended</span><span id="agent-bypass" title="Permission checks are off: the agent runs commands and changes files without asking" hidden>checks off</span><span class="bar-caret" aria-hidden="true">&#9662;</span></button>
<button id="agent-menu-button" class="bar-menu" aria-haspopup="menu" aria-expanded="false" aria-controls="agent-menu" hidden><span id="agent-dot" class="agent-dot" aria-hidden="true"></span><span id="agent-name"></span><span id="agent-model" title="The model and effort this agent was started with" hidden></span><span id="agent-ended" hidden>ended</span><span id="agent-bypass" title="Permission checks are off: the agent runs commands and changes files without asking" hidden>checks off</span><span class="bar-caret" aria-hidden="true">&#9662;</span></button>
<span id="agent-none">No agent</span>
<span id="agent-status" role="status"></span>
<span id="bar-grow"></span>