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();