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.

The composer's @ list reaches offline computers: dim, ranked last, never chosen (#1262)

lingrd66b52f0da71e
diff --git a/tui/Cargo.lock b/tui/Cargo.lock
index 728835d47..5098a92c6 100644
--- a/tui/Cargo.lock
+++ b/tui/Cargo.lock
@@ -654,7 +654,7 @@ dependencies = [
[[package]]
name = "harness-tui"
-version = "0.1.24"
+version = "0.1.25"
dependencies = [
"alacritty_terminal",
"base64",
diff --git a/tui/Cargo.toml b/tui/Cargo.toml
index 84fac545e..57f2c67fa 100644
--- a/tui/Cargo.toml
+++ b/tui/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "harness-tui"
-version = "0.1.24"
+version = "0.1.25"
edition = "2024"
[dependencies]
diff --git a/tui/src/new_harness.rs b/tui/src/new_harness.rs
index b7e4817f6..e1d3bc5c6 100644
--- a/tui/src/new_harness.rs
+++ b/tui/src/new_harness.rs
@@ -2149,6 +2149,29 @@ mod tests {
} } }
}
+ /// `@` in the task (or the Machine field) lists the machines; ↑ ↓ move through them and stay
+ /// where they were moved to through the refreshes that follow.
+ #[tokio::test]
+ async fn arrows_move_through_the_machines_at_lists() {
+ let mut app = app();
+ for (id, name) in [("lap", "laptop"), ("box", "gpu-box")] {
+ app.fleet.machines.push(crate::fleet::Machine { shared: false, id: id.into(), name: name.into(), local: false,
+ status: "online".into(), reach: crate::fleet::Reach::Ready });
+ }
+ open(&mut app, None, Some("/home/dev/project".into()));
+ press(&mut app, KeyCode::Char('@'));
+ fn current(app: &App) -> Option<String> { form_of(app).child.as_ref().and_then(|c| c.picker.current_id()) }
+ let first = current(&app);
+ press(&mut app, KeyCode::Down);
+ let second = current(&app);
+ assert_ne!(second, first, "↓ moves");
+ crate::new_harness::refresh(&mut app);
+ assert_eq!(current(&app), second, "a refresh keeps the row ↓ moved to");
+ press(&mut app, KeyCode::Up);
+ crate::new_harness::refresh(&mut app);
+ assert_eq!(current(&app), first, "↑ moves back");
+ }
+
#[tokio::test]
async fn at_colon_percent_in_the_task_open_their_choosers() {
let mut app = app();
diff --git a/tui/src/settings.rs b/tui/src/settings.rs
index 22340ab9e..145c07f07 100644
--- a/tui/src/settings.rs
+++ b/tui/src/settings.rs
@@ -873,7 +873,12 @@ impl PanelList<'_> {
let hint: String = if details { row.detail.iter().map(|s| s.content.as_ref()).collect() } else { String::new() };
let hx = at + 28;
let with_hint = !hint.is_empty() && hx + 8 < end;
- at += put(buf, at, y, if with_hint { 26 } else { end.saturating_sub(at) }, &row.label, style);
+ // A label's dim part (`label_dim`: an offline computer's whole name) in the quiet colour,
+ // as fzf's own lists draw it; the cursor's row keeps its highlight.
+ let label_w = if with_hint { 26 } else { end.saturating_sub(at) };
+ let split = row.label.char_indices().nth(row.label_dim).map_or(row.label.len(), |(i, _)| i);
+ let dim = put(buf, at, y, label_w, &row.label[..split], if here { style } else { c.muted });
+ at += dim + put(buf, at + dim, y, label_w.saturating_sub(dim), &row.label[split..], style);
let quiet = if here { style.remove_modifier(Modifier::BOLD) } else { c.muted };
if with_hint { put(buf, hx.max(at + 2), y, end - hx.max(at + 2), &hint, quiet); }
else if !details && at + 10 < end {
@@ -1342,7 +1347,10 @@ pub(crate) mod oracle {
let hint: String = if details { row.detail.iter().map(|s| s.content.as_ref()).collect() } else { String::new() };
let hx = at + 28;
let with_hint = !hint.is_empty() && hx + 8 < end;
- at += put(buf, at, y, if with_hint { 26 } else { end.saturating_sub(at) }, &row.label, style);
+ let label_w = if with_hint { 26 } else { end.saturating_sub(at) };
+ let split = row.label.char_indices().nth(row.label_dim).map_or(row.label.len(), |(i, _)| i);
+ let dim = put(buf, at, y, label_w, &row.label[..split], if here { style } else { c.muted });
+ at += dim + put(buf, at + dim, y, label_w.saturating_sub(dim), &row.label[split..], style);
let quiet = if here { style.remove_modifier(Modifier::BOLD) } else { c.muted };
if with_hint { put(buf, hx.max(at + 2), y, end - hx.max(at + 2), &hint, quiet); }
else if !details && at + 10 < end {
diff --git a/tui/src/shell_context/composition.rs b/tui/src/shell_context/composition.rs
index 588296e41..7145f938b 100644
--- a/tui/src/shell_context/composition.rs
+++ b/tui/src/shell_context/composition.rs
@@ -187,33 +187,7 @@ pub(super) fn list(app: &mut App, request: Request) {
);
}
if kind == "host" {
- // "This computer" stands in for this computer only until it has its own name: once the
- // daemon has registered it, that row is the same computer a second time.
- let named = app.fleet.registered_local_machine().is_some();
- let rows = app
- .fleet
- .machines
- .iter()
- .filter(|m| !m.shared && !(named && crate::local::is_local(&m.id)))
- .map(|m| {
- let unique = app
- .fleet
- .machines
- .iter()
- .filter(|other| other.name.eq_ignore_ascii_case(&m.name))
- .count()
- == 1
- && !m.name.contains(':');
- let id = if unique {
- m.name.as_str()
- } else {
- m.id.as_str()
- };
- let mut row = Row::new(id, &m.name).extra(&m.id).right(if m.usable() { "connected" } else { "offline" });
- row.disabled = !m.usable();
- row
- })
- .collect();
+ let rows = host_rows(app);
return data(app, &request, rows, String::new());
}
if !["folder", "model"].contains(&kind) {
@@ -645,10 +619,58 @@ pub(super) fn launch(app: &mut App, request: Request) {
});
}
+/// The composer's `@ computer` rows.
+fn host_rows(app: &App) -> Vec<Row> {
+ // "This computer" stands in for this computer only until it has its own name: once the
+ // daemon has registered it, that row is the same computer a second time.
+ let named = app.fleet.registered_local_machine().is_some();
+ app.fleet
+ .machines
+ .iter()
+ .filter(|m| !m.shared && !(named && crate::local::is_local(&m.id)))
+ .map(|m| {
+ let unique = app
+ .fleet
+ .machines
+ .iter()
+ .filter(|other| other.name.eq_ignore_ascii_case(&m.name))
+ .count()
+ == 1
+ && !m.name.contains(':');
+ let id = if unique {
+ m.name.as_str()
+ } else {
+ m.id.as_str()
+ };
+ // An offline computer stays a row the arrows reach (disabled, the list stood still
+ // on the one connected computer), dim and after the connected ones a search finds;
+ // choosing it says why it cannot be used.
+ let mut row = Row::new(id, &m.name).extra(&m.id).right(if m.usable() { "connected" } else { crate::shell_picker::OFFLINE });
+ if !m.usable() { row.label_dim = m.name.chars().count(); row.tier = 1 }
+ row
+ })
+ .collect()
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ #[test]
+ fn offline_computers_are_listed_dim_after_the_connected_ones_never_disabled() {
+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();
+ let mut app = App::new(19449, sink, (100, 35));
+ for (id, name, reach) in [("m1", "Mac Auto", crate::fleet::Reach::Ready), ("m2", "grid-dev", crate::fleet::Reach::Offline)] {
+ app.fleet.machines.push(crate::fleet::Machine { id: id.into(), name: name.into(), shared: false, local: false,
+ status: if reach == crate::fleet::Reach::Ready { "running" } else { "offline" }.into(), reach });
+ }
+ let rows = host_rows(&app);
+ let row = |name: &str| rows.iter().find(|r| r.label == name).unwrap();
+ assert!(rows.iter().all(|r| !r.disabled), "every computer is reachable");
+ assert_eq!((row("Mac Auto").right.as_str(), row("Mac Auto").label_dim, row("Mac Auto").tier), ("connected", 0, 0));
+ assert_eq!((row("grid-dev").right.as_str(), row("grid-dev").label_dim, row("grid-dev").tier), (crate::shell_picker::OFFLINE, 8, 1));
+ }
+
#[tokio::test]
async fn connecting_remote_launch_waits_and_cancellation_prevents_late_work() {
let (sink, mut events) = tokio::sync::mpsc::unbounded_channel();
diff --git a/tui/src/shell_picker.rs b/tui/src/shell_picker.rs
index d8ed2ebbb..708de2cf6 100644
--- a/tui/src/shell_picker.rs
+++ b/tui/src/shell_picker.rs
@@ -447,6 +447,12 @@ impl Drop for Screen {
}
}
+/// What a computer row that cannot be used right now says on its right (`list-compose` host rows).
+pub(crate) const OFFLINE:&str="offline";
+/// The offline computer Enter is on, by name: it is listed so ↑ ↓ reach it, never chosen.
+fn offline_choice(picker:&Picker,kind:&str)->Option<String> {
+ picker.current().filter(|r|kind=="host" && r.right==OFFLINE).map(|r|r.label.clone())
+}
fn edit(picker:&mut Picker,key:event::KeyEvent)->crate::input::End {
use crate::input::End;
let ctrl=key.modifiers.contains(KeyModifiers::CONTROL);
@@ -749,6 +755,7 @@ pub fn run(args:&[String])->io::Result<i32> {
continue
}
if let Some(current)=&draft { if kind!="sessions" {
+ if let Some(name)=offline_choice(&picker,kind) {picker.say(format!("{name} is offline"));continue}
if let Some(row)=picker.current().filter(|r|!r.disabled) {
if kind=="host" && host_changed(current,row,items.as_ref()) {
let (line,cursor)=current.change_host(&row.id).map_err(io::Error::other)?;
@@ -838,6 +845,40 @@ mod tests {
fn look(bg:&str,fg:&str,accent:&str,lists:&str)->Look {
Look{background:bg.into(),foreground:fg.into(),accent:accent.into(),lists:lists.into()}
}
+ /// `@ computer` with one connected computer and the rest offline (reported: the list stood still on
+ /// "Mac Auto", counting 5/1 — the offline ones were disabled rows): ↓ ↑ reach every computer, an
+ /// offline one is drawn dim and Enter on it says so instead of choosing it.
+ #[test]
+ fn offline_computers_are_reachable_dim_and_never_chosen() {
+ let key=|code| event::KeyEvent::new(code,KeyModifiers::NONE);
+ let mut hosts=Picker::new("","");
+ configure(&mut hosts,false);
+ hosts.query="@".into();hosts.qend();
+ compose_scope_with(&mut hosts,"host",true);
+ let mut offline=Row::new("grid-dev","grid-dev").right(OFFLINE);offline.label_dim=8;
+ hosts.set_rows(vec![Row::new("Mac Auto","Mac Auto").right("connected"),Row::new("box","box").right("connected"),offline]);
+ // Drawn dim, as the list's other quiet text: the cursor is on the first row, so the two
+ // unselected rows compare.
+ let area=Rect::new(0,0,60,8);
+ let mut buf=Buffer::empty(area);
+ crate::ui::inline_fzf(&mut buf,area,&mut hosts,false,vec![],false);
+ let fg=|name:&str|(0..8).find_map(|y|{let line=row_text(&buf,y,60);line.find(name).map(|x|buf[(line[..x].chars().count() as u16,y)].fg)}).unwrap();
+ assert_ne!(fg("grid-dev"),fg("box"),"an offline computer is dim");
+ assert_eq!(hosts.visible.len(),3,"every computer counted: 3/3, not 3/2");
+ assert_eq!(offline_choice(&hosts,"host"),None);
+ edit(&mut hosts,key(KeyCode::Down));
+ edit(&mut hosts,key(KeyCode::Down));
+ assert_eq!(hosts.current_id().as_deref(),Some("grid-dev"),"↓ reaches an offline computer");
+ assert_eq!(offline_choice(&hosts,"host").as_deref(),Some("grid-dev"));
+ assert_eq!(offline_choice(&hosts,"folder"),None);
+ edit(&mut hosts,key(KeyCode::Up));
+ assert_eq!(hosts.current_id().as_deref(),Some("box"),"↑ comes back");
+ // Typed, a connected computer ranks ahead of an offline one that matches as well.
+ hosts.set_rows(vec![Row::new("dev","dev").right(OFFLINE).tier(1),Row::new("devbox","devbox").right("connected")]);
+ hosts.query="@dev".into();hosts.qend();hosts.refilter();
+ assert_eq!(hosts.current_id().as_deref(),Some("devbox"),"not the offline exact match");
+ theme::fzf_reset();
+ }
fn reset_look() {
crate::term_out::set_theme_colours(None);crate::term_out::set_accent_override(None);apply_look(&look("","","",""));
}