Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

hn 0.1.19: agent and model in the pane title; a new window's shell starts where it asked (#1034)

lingrda24cb526833b
diff --git a/tui/Cargo.lock b/tui/Cargo.lock
index 3dd7dbf4c..3b8ceb7cd 100644
--- a/tui/Cargo.lock
+++ b/tui/Cargo.lock
@@ -654,7 +654,7 @@ dependencies = [
[[package]]
name = "harness-tui"
-version = "0.1.18"
+version = "0.1.19"
dependencies = [
"alacritty_terminal",
"base64",
diff --git a/tui/Cargo.toml b/tui/Cargo.toml
index 021aad41a..0bf0c54f9 100644
--- a/tui/Cargo.toml
+++ b/tui/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "harness-tui"
-version = "0.1.18"
+version = "0.1.19"
edition = "2024"
[dependencies]
diff --git a/tui/src/agent_switch.rs b/tui/src/agent_switch.rs
index 48f591511..9861d6b7a 100644
--- a/tui/src/agent_switch.rs
+++ b/tui/src/agent_switch.rs
@@ -275,6 +275,9 @@ pub fn pane_supports(app: &App, pane: u64) -> bool {
&& app.fleet.machine(&a.machine_id).is_some_and(|m| !m.shared))
}
+pub fn pane_label(app: &App, pane: u64) -> String {
+ source_for(app, pane).map(|a| theme::engine_label(&a.engine).to_string()).unwrap_or_else(|| "Agent".into())
+}
fn engines(app: &App, source: &Agent) -> Vec<String> {
let all = crate::modal::ENGINES.iter().filter(|e| **e != "terminal").map(|e| e.to_string()).collect::<Vec<_>>();
diff --git a/tui/src/input.rs b/tui/src/input.rs
index b8a9e1eef..4558786cd 100644
--- a/tui/src/input.rs
+++ b/tui/src/input.rs
@@ -1411,13 +1411,16 @@ pub fn new_shell_with_picker(app: &mut App, focused: Option<(String, String)>, p
let local = crate::local::is_local(&machine);
if local { app.keep_local_shell_session() }
let context = command.is_none().then(|| crate::shell_context::prepare(app, focused.as_ref(), !matches!(placement, Placement::Fill(_))));
+ let cwd = shell_cwd(app, focused.as_ref(), &machine, cwd);
let init = context.as_ref().map(|token| {
- let cli = if local || app.fleet.machine(&machine).is_some_and(|m| m.local) { std::env::var("HARNESS_SHELL_CLI").ok() } else { None };
- let mut init = crate::shell_context::bootstrap(token, cli.as_deref(), local || app.fleet.machine(&machine).is_some_and(|m| m.local));
+ let here = local || app.fleet.machine(&machine).is_some_and(|m| m.local);
+ let cli = if here { std::env::var("HARNESS_SHELL_CLI").ok() } else { None };
+ let mut init = crate::shell_context::bootstrap(token, cli.as_deref(), here);
+ crate::shell_context::start_in(&mut init, cwd.as_deref(), here);
+ // (Last: the helper reads it as its last argument.)
if choose_agent && app.capture.is_none() && !app.headless { init.push("--pick-agent".into()); }
init
});
- let cwd = shell_cwd(app, focused.as_ref(), &machine, cwd);
let Some(link) = app.link(&machine) else { app.print_new = None; return app.error("That machine is not connected") };
let mut payload = json!({ "engine": "terminal", "creationId": uuid::Uuid::new_v4().to_string(), "bypassPermission": false });
if let Some(cwd) = &cwd { payload["cwd"] = json!(cwd) }
diff --git a/tui/src/main.rs b/tui/src/main.rs
index 41eaa7f28..c5c3be2da 100644
--- a/tui/src/main.rs
+++ b/tui/src/main.rs
@@ -74,6 +74,7 @@ mod bar;
mod bar_more;
// ── models: the Models view (step 6) ──
mod models;
+mod runtime_model;
mod autoname;
use std::io::{self, BufWriter, Write};
diff --git a/tui/src/models.rs b/tui/src/models.rs
index 612b28346..31ba9e3cc 100644
--- a/tui/src/models.rs
+++ b/tui/src/models.rs
@@ -429,6 +429,16 @@ pub fn pane_supports(app: &App, pane: u64) -> bool {
&& app.fleet.agent(&p.machine_id, &p.agent_id).is_some_and(|a| a.status != "stopped" && ["codex", "claude", "opencode"].contains(&a.engine.as_str()))
}
+/// The model the pane's harness runs, as its title names it: Grid's, or what the engine reported.
+pub fn pane_label(app: &App, pane: u64) -> String {
+ let observed = app.panes.get(&pane).and_then(|p| app.fleet.agent(&p.machine_id, &p.agent_id)).and_then(|a| {
+ if !a.grid_model.is_empty() { Some(a.grid_model.clone()) }
+ else { crate::runtime_model::details(&a.model, &a.id, &a.engine).map(|m| m.name) }
+ });
+ let label = observed.unwrap_or_else(|| "Model".into()).chars().filter(|c| !c.is_control()).collect::<String>();
+ crate::format::clip_middle(&label, 24)
+}
+
pub fn target(app: &App) -> Option<Target> {
let of = |machine: String, agent: String| -> Option<Target> {
if app.fleet.machine(&machine).is_some_and(|m| m.shared) { return None }
diff --git a/tui/src/runtime_model.rs b/tui/src/runtime_model.rs
new file mode 100644
index 000000000..38a0e4179
--- /dev/null
+++ b/tui/src/runtime_model.rs
@@ -0,0 +1,79 @@
+//! The desktop's observed model label contract. Metadata is scoped to an agent and engine;
+//! absent or stale metadata must not invent a model or an effort.
+use std::sync::OnceLock;
+use regex::Regex;
+
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct Details { pub name: String, pub effort: String }
+
+fn decode(value: &str) -> Option<String> {
+ let mut bytes = Vec::with_capacity(value.len());
+ let mut input = value.bytes();
+ while let Some(b) = input.next() {
+ bytes.push(if b == b'%' {
+ let high = (input.next()? as char).to_digit(16)?;
+ let low = (input.next()? as char).to_digit(16)?;
+ (high * 16 + low) as u8
+ } else { b });
+ }
+ String::from_utf8(bytes).ok()
+}
+
+fn title(value: &str) -> String {
+ let mut chars = value.chars();
+ chars.next().map(|first| first.to_uppercase().collect::<String>() + chars.as_str()).unwrap_or_default()
+}
+
+pub fn details(value: &str, agent: &str, engine: &str) -> Option<Details> {
+ if value.encode_utf16().count() > 1024 { return None }
+ static WIRE: OnceLock<Regex> = OnceLock::new();
+ static CLAUDE: OnceLock<Regex> = OnceLock::new();
+ static GPT: OnceLock<Regex> = OnceLock::new();
+ static PATH: OnceLock<Regex> = OnceLock::new();
+ let found = WIRE.get_or_init(|| Regex::new(r"(?i)^runtime-v1:([^:]+):([a-z0-9_-]+):([^@]+)@([a-z0-9_-]+)$").unwrap()).captures(value)?;
+ if !found[2].eq_ignore_ascii_case(engine) || decode(&found[1])? != agent { return None }
+ let mut name = decode(&found[3])?.trim().to_string();
+ if engine.eq_ignore_ascii_case("opencode") {
+ if let Some(path) = PATH.get_or_init(|| Regex::new(r" {3,}(?:/|~/|[A-Za-z]:[\\/])").unwrap()).find(&name) {
+ name.truncate(path.start());
+ }
+ }
+ if name.is_empty() || name == "<synthetic>" || name.encode_utf16().count() > 256 || name.chars().any(|c| c <= '\u{1f}' || c == '\u{7f}') { return None }
+ if let Some(c) = CLAUDE.get_or_init(|| Regex::new(r"(?i)^(?:claude-)?(fable|opus|sonnet|haiku)(?:-(\d+(?:[-.]\d{1,2})*))?(\[1m\])?$").unwrap()).captures(&name) {
+ name = format!("{}{}{}", title(&c[1].to_lowercase()), c.get(2).map(|v| format!(" {}", v.as_str().replace('-', "."))).unwrap_or_default(), c.get(3).map(|s| s.as_str()).unwrap_or(""));
+ } else if let Some(c) = GPT.get_or_init(|| Regex::new(r"(?i)^gpt-(\d+(?:\.\d+)*)(?:-(astra|sol|terra|luna|codex))?$").unwrap()).captures(&name) {
+ name = format!("GPT-{}{}", &c[1], c.get(2).map(|s| format!(" {}", title(&s.as_str().to_lowercase()))).unwrap_or_default());
+ }
+ Some(Details { name, effort: found[4].to_lowercase() })
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn names_match_desktop_and_never_infer_versions() {
+ for (engine, raw, want) in [
+ ("codex", "gpt-6-astra", "GPT-6 Astra"), ("codex", "gpt-5.6-sol", "GPT-5.6 Sol"), ("codex", "gpt-5.6", "GPT-5.6"),
+ ("claude", "fable", "Fable"), ("claude", "opus", "Opus"), ("claude", "claude-opus-5", "Opus 5"),
+ ("claude", "claude-sonnet-4-6%5B1m%5D", "Sonnet 4.6[1m]"),
+ ("claude", "claude-haiku-4-5-20251001", "claude-haiku-4-5-20251001"), ("opencode", "provider%2FModel-Next", "provider/Model-Next"),
+ ] {
+ let parsed = details(&format!("runtime-v1:a%3A1:{engine}:{raw}@HIGH"), "a:1", engine).unwrap();
+ assert_eq!(parsed, Details { name: want.into(), effort: "high".into() });
+ }
+ assert_eq!(details("runtime-v1:a:opencode:Model%20%20%20%20%2Fprivate%2Fwork@auto", "a", "opencode").unwrap().name, "Model");
+ assert_eq!(details("runtime-v1:a:opencode:Model%20%20%20C%3A%5Cwork@auto", "a", "opencode").unwrap().name, "Model");
+ assert_eq!(details("runtime-v1:a:opencode:provider%2FModel+Next@auto", "a", "opencode").unwrap().name, "provider/Model+Next");
+ }
+
+ #[test]
+ fn malformed_or_foreign_metadata_has_no_label() {
+ for value in ["", "gpt-6-astra", "runtime-v2:a:codex:gpt-6-astra@high", "runtime-v1:a:claude:opus@high", "runtime-v1:other:codex:model@high",
+ "runtime-v1:%ZZ:codex:model@high", "runtime-v1:a:codex:%ZZ@high", "runtime-v1:a:codex:%FF@high", "runtime-v1:a:codex:%C0%80@high",
+ "runtime-v1:a:codex:%20@high", "runtime-v1:a:codex:%3Csynthetic%3E@high", "runtime-v1:a:codex:model%0Aname@high"] {
+ assert!(details(value, "a", "codex").is_none(), "{value}");
+ }
+ for raw in ["x".repeat(257), "x".repeat(1025)] { assert!(details(&format!("runtime-v1:a:codex:{raw}@high"), "a", "codex").is_none()); }
+ }
+}
diff --git a/tui/src/shell_context.rs b/tui/src/shell_context.rs
index d0cbae82a..5c9ba5476 100644
--- a/tui/src/shell_context.rs
+++ b/tui/src/shell_context.rs
@@ -148,9 +148,28 @@ fn look_value_with(fzf_opts: &[String]) -> serde_json::Value {
fn look_arg() -> String { format!("--look={}", look_value()) }
/// Separate the `--look=` argument from the others.
-fn split_look(args: &[String]) -> (Vec<String>, Option<String>) {
- let look = args.iter().find_map(|a| a.strip_prefix("--look=")).map(String::from);
- (args.iter().filter(|a| !a.starts_with("--look=")).cloned().collect(), look)
+fn split_look(args: &[String]) -> (Vec<String>, Option<String>) { split_option(args, "--look=") }
+fn split_option(args: &[String], prefix: &str) -> (Vec<String>, Option<String>) {
+ let value = args.iter().find_map(|a| a.strip_prefix(prefix)).map(String::from);
+ (args.iter().filter(|a| !a.starts_with(prefix)).cloned().collect(), value)
+}
+
+/// The folder a new shell asked for, in its start arguments: on this computer only, where this
+/// build's own binary starts it (a remote's older hn would refuse the argument).
+pub fn start_in(init: &mut Vec<String>, cwd: Option<&str>, local: bool) {
+ if let Some(cwd) = cwd.filter(|c| local && !c.is_empty()) { init.push(format!("--cwd={cwd}")); }
+}
+
+/// Where the shell starts: the folder it asked for; else where it was started, if that is still
+/// a folder; else home. tmux (3.7c) starts a pane in its server's own folder, not the one asked for
+/// (-c), when the server's folder was deleted: its getcwd fails and it skips the chdir. A shell
+/// there is in a folder that is gone, and zsh-syntax-highlighting spins at its first redraw.
+fn start_folder(asked: Option<&str>) -> std::path::PathBuf {
+ use std::path::PathBuf;
+ asked.map(PathBuf::from).filter(|p| p.is_dir())
+ .or_else(|| std::env::current_dir().ok().filter(|d| d.is_dir()))
+ .or_else(|| std::env::var_os("HOME").map(PathBuf::from).filter(|h| h.is_dir()))
+ .unwrap_or_else(|| PathBuf::from("/"))
}
pub fn bootstrap(token: &str, cli: Option<&str>, local: bool) -> Vec<String> {
@@ -213,11 +232,13 @@ pub fn initialize(args: &[String]) -> std::io::Result<()> {
let pick_agent = args.last().is_some_and(|arg| arg == "--pick-agent");
let args = if pick_agent { &args[..args.len()-1] } else { args };
let (args, look) = split_look(args);
+ let (args, cwd) = split_option(&args, "--cwd=");
if args.len()>2 { return Err(std::io::Error::other("Invalid shell initialization arguments.")) }
let picker = std::env::current_exe()?;
let script = init_script(token, &picker.to_string_lossy(), args.get(1).map(String::as_str).unwrap_or("harness"), look.as_deref());
+ let folder = start_folder(cwd.as_deref());
let mut command = std::process::Command::new("/bin/sh");
- command.args(["-c", &script]);
+ command.args(["-c", &script]).current_dir(&folder).env("PWD", &folder);
if pick_agent { command.env("_HN_START_PICKER", "1"); }
Err(command.exec())
}
@@ -812,7 +833,8 @@ fn switch_host(app: &mut App, machine: &str) {
let machine = machine.to_string();
let local = app.fleet.machine(&machine).is_some_and(|m| m.local);
let cli = if local { std::env::var("HARNESS_SHELL_CLI").ok() } else { None };
- let init = bootstrap(&request.token, cli.as_deref(), local);
+ let mut init = bootstrap(&request.token, cli.as_deref(), local);
+ start_in(&mut init, app.homes.get(&machine).map(String::as_str), local);
let mut payload = json!({"engine":"terminal", "creationId":uuid::Uuid::new_v4().to_string(), "bypassPermission":false, "argv":init});
if let Some(home) = app.homes.get(&machine) { payload["cwd"] = json!(home); }
crate::input::configure_local_shell(app, &machine, &mut payload);
@@ -1360,6 +1382,30 @@ mod tests {
assert!(!init_script("tok","/bin/hn","harness",None).contains("HN_LOOK"));
}
#[test]
+ fn a_new_shell_starts_in_the_folder_it_asked_for_whatever_tmux_left_it_in() {
+ let mut local = bootstrap("tok", Some("cli"), true);
+ start_in(&mut local, Some("/work/project"), true);
+ let mut remote = bootstrap("tok", Some("cli"), false);
+ start_in(&mut remote, Some("/work/project"), false);
+ assert!(!remote.iter().any(|a| a.starts_with("--cwd=")), "a remote's older hn would refuse it");
+ let (args, look) = split_look(&local[2..]);
+ let (args, cwd) = split_option(&args, "--cwd=");
+ assert_eq!((args, cwd.as_deref()), (vec!["tok".to_string(), "cli".to_string()], Some("/work/project")));
+ assert!(look.is_some());
+ // The asked folder when it is one; else where the helper was started, while that is a folder.
+ let there = tempfile_dir();
+ assert_eq!(start_folder(Some(there.to_str().unwrap())), there);
+ let here = std::env::current_dir().unwrap();
+ assert_eq!(start_folder(Some("/no/such/folder/for/hn")), here);
+ assert_eq!(start_folder(None), here);
+ let _ = std::fs::remove_dir(&there);
+ }
+ fn tempfile_dir() -> std::path::PathBuf {
+ let dir = std::env::temp_dir().join(format!("hn-start-{}", uuid::Uuid::new_v4()));
+ std::fs::create_dir(&dir).unwrap();
+ dir
+ }
+ #[test]
fn the_look_travels_in_the_shell_start_arguments() {
let _l = crate::term_out::colours_lock();
let _restore = LookGuard;
diff --git a/tui/src/workspace_controls.rs b/tui/src/workspace_controls.rs
index 12880615e..eb5112f2e 100644
--- a/tui/src/workspace_controls.rs
+++ b/tui/src/workspace_controls.rs
@@ -9,7 +9,7 @@ use unicode_width::UnicodeWidthStr;
use crate::{app::App, draw::RangeKind, theme, workspace_menu as menu};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-pub enum Action { New, Menu, Account, Header(u64), PaneMenu(u64) }
+pub enum Action { New, Menu, Account, Header(u64), PaneMenu(u64), Agent(u64), Model(u64) }
/// The menu's glyph — at a pane's title, in the status line and the side bar: three dots up and
/// down, centred in the cell, drawn bold so it does not read thin. (A braille `⠇` is as big as the
@@ -71,8 +71,24 @@ pub fn register(app: &App, rect: Rect, action: Action) {
pub fn title_reserve(app: &App, window: usize, pane: u64, width: u16) -> u16 {
let tab = app.tabs.get(window).map(|t| t.id.as_str()).unwrap_or("");
if !enabled(app) || !app.mouse || width < 20 || app.options.has_window_override("pane-border-format", tab, pane) { return 0 }
- // (No agent or model label: the menu changes both.)
- MENU_COLS
+ MENU_COLS + identity_labels(app, pane, width).iter().map(|(label, _)| label.width() as u16 + 2).sum::<u16>()
+}
+
+/// The harness's agent and model, before the menu; each opens its picker. They keep the title's
+/// first 30 columns for its name and place: a narrower pane drops the model, then the agent.
+fn identity_labels(app: &App, pane: u64, width: u16) -> Vec<(String, Action)> {
+ let mut labels = Vec::new();
+ let mut available = width.saturating_sub(30);
+ if crate::agent_switch::pane_supports(app, pane) {
+ let label = crate::agent_switch::pane_label(app, pane);
+ let size = label.width() as u16 + 2;
+ if size <= available { available -= size; labels.push((label, Action::Agent(pane))); }
+ }
+ if crate::models::pane_supports(app, pane) {
+ let label = crate::models::pane_label(app, pane);
+ if label.width() as u16 + 2 <= available { labels.push((label, Action::Model(pane))); }
+ }
+ labels
}
/// Return the title's remaining space. The controls never add a row or resize a terminal.
@@ -83,7 +99,15 @@ pub fn title(buf: &mut Buffer, app: &App, pane: u64, rect: Rect, style: Style) -
register(app, rect, Action::Header(pane));
app.controls.grips.borrow_mut().push((Rect::new(rect.x, rect.y, rect.width - reserve, 1), pane));
let quiet = style.remove_modifier(Modifier::BOLD | Modifier::DIM).fg(theme::paint(theme::pane_palette().muted));
- let menu = Rect::new(rect.right() - reserve, rect.y, reserve, 1);
+ let mut x = rect.right() - reserve;
+ for (label, action) in identity_labels(app, pane, rect.width) {
+ let size = label.width() as u16 + 2;
+ let at = Rect::new(x, rect.y, size, 1);
+ Span::styled(format!(" {label} "), quiet).render(at, buf);
+ register(app, at, action);
+ x += size;
+ }
+ let menu = Rect::new(x, rect.y, MENU_COLS, 1);
Span::styled(format!(" {MENU_GLYPH} "), quiet.add_modifier(Modifier::BOLD)).render(menu, buf);
register(app, menu, Action::PaneMenu(pane));
Rect::new(rect.x, rect.y, rect.width - reserve, rect.height)
@@ -151,6 +175,8 @@ pub fn activate(app: &mut App, action: Action, at: Option<(u16, u16)>) {
Action::Account => crate::account::open(app),
Action::Header(pane) => { select_pane(app, pane); }
Action::PaneMenu(pane) => pane_menu(app, pane, at),
+ Action::Agent(pane) => if select_pane(app, pane) { crate::agent_switch::open(app, pane); },
+ Action::Model(pane) => if crate::models::pane_supports(app, pane) && select_pane(app, pane) { crate::input::run(app, "models"); },
}
}
@@ -198,7 +224,7 @@ pub fn mouse(app: &mut App, mouse: &MouseEvent) -> bool {
let at = Some((mouse.column, mouse.row.saturating_add(1)));
// A title is a border in line layouts and a pane's first row in boxed layouts.
// Either explicit binding takes precedence over the added header controls.
- let places: &[&str] = if matches!(action, Some(Action::Header(_) | Action::PaneMenu(_))) { &["Border", "Pane"] } else { &["Status"] };
+ let places: &[&str] = if matches!(action, Some(Action::Header(_) | Action::PaneMenu(_) | Action::Agent(_) | Action::Model(_))) { &["Border", "Pane"] } else { &["Status"] };
if let MouseEventKind::Down(button @ (MouseButton::Left | MouseButton::Right)) = mouse.kind {
let defaults = crate::keys::Keymap::tmux_defaults();
for place in places {
@@ -227,7 +253,7 @@ pub fn mouse(app: &mut App, mouse: &MouseEvent) -> bool {
return true;
},
MouseEventKind::Down(MouseButton::Right) => {
- let pane = match action { Some(Action::Header(p) | Action::PaneMenu(p)) => Some(p), _ => None };
+ let pane = match action { Some(Action::Header(p) | Action::PaneMenu(p) | Action::Agent(p) | Action::Model(p)) => Some(p), _ => None };
if let Some(pane) = pane { begin_press(app, MouseButton::Right); pane_menu(app, pane, at); return true; }
// A machine's heading in the side bar: what can be done on it.
if let Some(crate::bar::Hit::Machine(machine, _)) = crate::bar::hit_at(app, mouse.column, mouse.row) {
@@ -454,6 +480,12 @@ pub(crate) mod tests {
app.controls.hits.borrow().iter().find(|(_, action)| *action == wanted).unwrap_or_else(|| panic!("missing {wanted:?}")).0
}
+ /// Where a pane's title controls start: its agent and model labels, else the menu.
+ fn controls_x(app: &App, pane: u64) -> u16 {
+ app.controls.hits.borrow().iter().filter(|(_, a)| matches!(a, Action::Agent(p) | Action::Model(p) | Action::PaneMenu(p) if *p == pane))
+ .map(|(r, _)| r.x).min().unwrap_or_else(|| panic!("no controls for {pane}"))
+ }
+
fn send(app: &mut App, kind: MouseEventKind, x: u16, y: u16) {
crate::input::handle(app, Event::Mouse(MouseEvent { kind, column: x, row: y, modifiers: KeyModifiers::NONE }));
}
@@ -564,10 +596,11 @@ pub(crate) mod tests {
let (pane, other) = if status == "top" { (2, 1) } else { (1, 2) };
let probe = stacked(look, status);
let (title, name) = (hit(&probe, Action::Header(pane)), grip(&probe, pane));
- assert!(name.width > 0 && name.right() < title.right() - MENU_COLS, "{look:?} {status}: the grip is the name, not the whole row");
+ assert!(name.width > 0 && name.right() < controls_x(&probe, pane), "{look:?} {status}: the grip is the name, not the whole row");
let away = (hit(&probe, Action::Header(other)), grip(&probe, other));
- assert_eq!(away.1.width, away.0.width - MENU_COLS, "{look:?} {status}: a title on no divider drags from its whole row");
- let controls = [hit(&probe, Action::PaneMenu(pane))];
+ assert_eq!(away.1.right(), controls_x(&probe, other), "{look:?} {status}: a title on no divider drags from its whole row");
+ let controls: Vec<Rect> = probe.controls.hits.borrow().iter()
+ .filter(|(_, a)| matches!(a, Action::Agent(p) | Action::Model(p) | Action::PaneMenu(p) if *p == pane)).map(|(r, _)| *r).collect();
let before = probe.tab().root.as_ref().unwrap().to_tmux();
// 3 rows into its own pane, from each cell of the row
let to = if status == "top" { title.y + 3 } else { title.y - 3 };
@@ -684,8 +717,8 @@ pub(crate) mod tests {
app.fit_panes();
let buf = render(&mut app);
let title = hit(&app, Action::Header(1));
- // the blank part of the header, right of the name and left of the … × controls
- let x = title.right() - 8;
+ // the blank part of the header, right of the name and left of the agent, model and ⋮
+ let x = controls_x(&app, 1) - 2;
assert_eq!(buf[(x, title.y)].symbol(), " ", "this test needs a blank header cell right of the name");
send(&mut app, MouseEventKind::Down(MouseButton::Left), x, title.y);
send(&mut app, MouseEventKind::Drag(MouseButton::Left), x - 4, title.y + 3);
@@ -850,13 +883,25 @@ pub(crate) mod tests {
}
#[tokio::test]
- async fn the_pane_title_names_no_agent_or_model_and_its_menu_changes_both() {
+ async fn the_pane_title_names_its_agent_and_model_until_the_pane_is_narrow() {
let mut app = app(120);
app.fleet.agents.get_mut(&("local".into(), "a1".into())).unwrap().model = "runtime-v1:a1:codex:gpt-6-astra@max".into();
let buf = render(&mut app);
- let menu = hit(&app, Action::PaneMenu(1));
- let title: String = (0..buf.area.width).map(|x| buf[(x, menu.y)].symbol()).collect();
- assert!(!title.contains("GPT-6 Astra") && !title.contains("Codex"), "{title}");
+ let (agent, model, menu) = (hit(&app, Action::Agent(1)), hit(&app, Action::Model(1)), hit(&app, Action::PaneMenu(1)));
+ let cells = |r: Rect| -> String { (r.x..r.right()).map(|x| buf[(x, r.y)].symbol()).collect() };
+ assert_eq!((cells(agent), cells(model), cells(menu)), (" Codex ".into(), " GPT-6 Astra ".into(), format!(" {MENU_GLYPH} ")));
+ assert!(agent.right() == model.x && model.right() == menu.x, "agent, model, then the menu: {agent:?} {model:?} {menu:?}");
+ // Each label opens its picker for this pane.
+ click(&mut app, MouseButton::Left, model.x + 1, model.y);
+ assert!(matches!(app.modal, Some(crate::modal::Modal::Picker { kind: crate::modal::PickerKind::Models, .. })));
+ assert_eq!(crate::models::target(&app).unwrap().agent, "a1");
+ app.modal = None;
+ render(&mut app);
+ let agent = hit(&app, Action::Agent(1));
+ click(&mut app, MouseButton::Left, agent.x + 1, agent.y);
+ assert!(matches!(app.modal, Some(crate::modal::Modal::Picker { kind: crate::modal::PickerKind::AgentSwitch, .. })));
+ app.modal = None;
+ // The menu changes both too.
pane_menu(&mut app, 1, None);
let token = app.controls.target.as_ref().unwrap().token.clone();
run(&mut app, &token, "models");
@@ -869,6 +914,7 @@ pub(crate) mod tests {
assert!(matches!(app.modal, Some(crate::modal::Modal::Picker { kind: crate::modal::PickerKind::AgentSwitch, .. })));
app.modal = None;
app.size.0 = 32; app.fit_panes(); render(&mut app);
+ assert!(app.controls.hits.borrow().iter().all(|(_, a)| !matches!(a, Action::Agent(_) | Action::Model(_))), "a narrow pane keeps its name, not the labels");
assert!(app.controls.hits.borrow().iter().any(|(_, a)| *a == Action::PaneMenu(1)), "narrow panes retain the menu");
}
diff --git a/tui/tests/pane-ui.py b/tui/tests/pane-ui.py
index a5ab971a8..cf5b068b2 100644
--- a/tui/tests/pane-ui.py
+++ b/tui/tests/pane-ui.py
@@ -304,7 +304,7 @@ try:
x, y, w = map(int, value('#{pane_left} #{pane_top} #{pane_width}', second).split())
def waiting_heading():
return tmux('capture-pane', '-p', '-t', 'test').splitlines()[y - 1][x:x + w].strip()
- wait(lambda: re.search(r'\(2\) \?\s+⋮$', waiting_heading()), 'long pane names retain their suffix and waiting indicator before the menu control')
+ wait(lambda: re.search(r'\(2\) \?\s+Codex\s+(?:default\s+)?⋮$', waiting_heading()), 'long pane names retain their suffix and waiting indicator before the agent, model and menu controls')
assert '…' in waiting_heading()
assert value('#{pane_title}', second) == long_title, 'raw pane title must remain unchanged'
hn('select-pane', '-t', second, '-T', original_title)
@@ -336,7 +336,7 @@ try:
def context_before_controls():
heading = tmux('capture-pane', '-p', '-t', 'test').splitlines()[y - 1][x:x + w].rstrip()
suffix = heading.partition(branch_context)[2]
- return branch_context in heading and bool(re.fullmatch(r'\s+⋮', suffix))
+ return branch_context in heading and bool(re.fullmatch(r'\s+(?:Claude Code\s+default\s+)?⋮', suffix))
wait(context_before_controls, 'machine, project, branch and PR align beside the right-hand controls')
snapshot('panes-zoomed' if target == first else 'panes-remote-zoomed')
keys('C-b', 'z')
diff --git a/tui/tests/workspace-controls.py b/tui/tests/workspace-controls.py
index 09c06879c..fedf9d567 100644
--- a/tui/tests/workspace-controls.py
+++ b/tui/tests/workspace-controls.py
@@ -627,13 +627,12 @@ try:
assert not login_events()
wait(lambda: 'Continue with Google' not in screen(), 'back to local workspace')
- # The pane menu's agent and model act on the captured pane even if external focus changes.
+ # The title's agent and model labels act on the captured pane even if external focus changes.
x, y = map(int, value('#{pane_left} #{pane_top}', alpha).split())
- assert 'Codex' not in screen().splitlines()[y - 1] and 'GPT-6 Astra' not in screen().splitlines()[y - 1], 'no agent or model label in the title'
- pane_menu_item('Change agent…', row=y - 1)
+ click_text('Codex', row=y - 1)
alpha_agent_picker()
keys('Escape')
- pane_menu_item('Change model…', row=y - 1)
+ click_text('GPT-6 Astra', row=y - 1)
shown('Fixture local model')
hn('select-pane', '-t', beta)
click_text('Fixture local model', before=85)