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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(tui): a machine back online is dialled again, and a command dials one that is up (#1571)
lingrd84da4e32c88f
diff --git a/tui/Cargo.lock b/tui/Cargo.lockindex 37fd9de42..65421e58f 100644--- a/tui/Cargo.lock+++ b/tui/Cargo.lock@@ -661,7 +661,7 @@ dependencies = [[[package]]name = "harness-tui"-version = "0.1.41"+version = "0.1.42"dependencies = ["alacritty_terminal","base64",diff --git a/tui/Cargo.toml b/tui/Cargo.tomlindex 8dc7024bd..19939e8c7 100644--- a/tui/Cargo.toml+++ b/tui/Cargo.toml@@ -1,6 +1,6 @@[package]name = "harness-tui"-version = "0.1.41"+version = "0.1.42"edition = "2024"[dependencies]diff --git a/tui/src/app.rs b/tui/src/app.rsindex 4b07d77ca..46a84c1f5 100644--- a/tui/src/app.rs+++ b/tui/src/app.rs@@ -1389,16 +1389,33 @@ impl App {}// This computer first, then the ones that are up.app.fleet.machines.sort_by_key(|m| (!m.local, !m.online(), m.name.to_lowercase()));- let ids: Vec<String> = app.fleet.machines.iter()- .filter(|m| m.online() && (matches!(m.reach, Reach::Unknown | Reach::Error(_)) || (m.reach == Reach::NeedsLink && app.fleet.shares.contains_key(&m.id))))- .map(|m| m.id.clone()).collect();- for id in ids { app.connect(&id) }- for machine in app.fleet.machines.iter_mut() { if !machine.online() && machine.reach == Reach::Unknown { machine.reach = Reach::Offline } }+ app.dial_listed();crate::workspace_controls::refresh_workspace(app);crate::input::refill(app);});}+ /// The machines the list says are up that hn has no link to are dialled; the others are offline.+ /// Offline is among them: a link that dropped while the list read the machine offline (its daemon+ /// restarting for an update, the Mac asleep) is given up (redial_due), and only this dials it again.+ /// Left out, the machine read "offline" while up until hn restarted (a shared Mac, 2026-10-22).+ pub fn dial_listed(&mut self) {+ let ids: Vec<String> = self.fleet.machines.iter()+ .filter(|m| m.online() && (matches!(m.reach, Reach::Unknown | Reach::Error(_) | Reach::Offline) || (m.reach == Reach::NeedsLink && self.fleet.shares.contains_key(&m.id))))+ .map(|m| m.id.clone()).collect();+ for id in ids { self.connect(&id) }+ for machine in self.fleet.machines.iter_mut() { if !machine.online() && machine.reach == Reach::Unknown { machine.reach = Reach::Offline } }+ }++ /// Dial [machine_id] when nothing is dialling it: no link, no retry pending (its backoff decides when), and this+ /// computer's daemon, which every link goes through, is up. For a dial asked on demand (composition `wake`),+ /// which a waiting command asks again every 100 ms.+ pub fn dial_if_idle(&mut self, machine_id: &str) -> bool {+ if self.daemon_down || self.links.get(machine_id).is_some_and(|s| s.link.is_some() || s.retry_at.is_some()) { return false }+ self.connect(machine_id);+ true+ }+pub fn connect(&mut self, machine_id: &str) {if let Some(state) = self.links.get(machine_id) {if state.link.is_some() { return }@@ -7525,6 +7542,49 @@ mod recovery_tests {}}+ /// Its link dropped while the list read it offline (its daemon restarting for an update, the Mac asleep),+ /// so hn stopped dialling and kept it Offline. The list saying it is up again never dialled it: only+ /// Unknown and Error were, and a shell's `claude @<it>` answered "That computer is offline" until hn+ /// restarted (a shared Mac, 2026-10-22).+ #[tokio::test]+ async fn a_machine_back_online_is_dialled_again_after_hn_gave_up_on_it() {+ let mut app = fixture();+ undialled(&mut app);+ app.connect("test-peer");+ app.fleet.machine_mut("test-peer").unwrap().status = "offline".into();+ fail(&mut app, "test-peer", "DISCONNECTED");+ redial(&mut app, "test-peer");+ assert_eq!(app.fleet.machine("test-peer").unwrap().reach, Reach::Offline);+ assert!(app.links["test-peer"].link.is_none() && app.links["test-peer"].retry_at.is_none(), "given up while offline");+ app.fleet.machine_mut("test-peer").unwrap().status = "online".into();+ app.dial_listed();+ assert!(app.links["test-peer"].link.is_some(), "the list says it is up: dial it");+ assert_eq!(app.fleet.machine("test-peer").unwrap().reach, Reach::Connecting);+ app.links["test-peer"].link.as_ref().unwrap().close();+ }++ /// A composed command dials a computer that is up but not linked (composition `wake`), and asks again every+ /// 100 ms while it waits up to 25 s. A dial that fails at once was redialled on each ask, past its backoff:+ /// some 250 dials (review of #1571). It dials only a machine with no link and no retry pending, and not while+ /// this computer's daemon, which every link goes through, is down.+ #[tokio::test]+ async fn dialling_on_demand_keeps_the_backoff() {+ let mut app = fixture();+ undialled(&mut app);+ assert!(app.dial_if_idle("test-peer"));+ assert!(!app.dial_if_idle("test-peer"), "dialling already");+ fail(&mut app, "test-peer", "TIMEOUT");+ assert!(app.links["test-peer"].retry_at.is_some(), "the backoff is on");+ assert!(!app.dial_if_idle("test-peer"), "the backoff decides when it dials again");+ assert!(app.links["test-peer"].link.is_none());+ app.links.get_mut("test-peer").unwrap().retry_at = None;+ app.daemon_down = true;+ assert!(!app.dial_if_idle("test-peer"), "nothing reaches it while this computer's daemon is down");+ app.daemon_down = false;+ assert!(app.dial_if_idle("test-peer"));+ app.links["test-peer"].link.as_ref().unwrap().close();+ }+/// A shared machine refused until one of the two daemons reads the sharing (#1381) was redialled/// on the 15 s backoff for good, each refusal a remote_connect failed (2026-10-16).#[tokio::test]diff --git a/tui/src/shell_context/composition.rs b/tui/src/shell_context/composition.rsindex ae85c1429..7b845d055 100644--- a/tui/src/shell_context/composition.rs+++ b/tui/src/shell_context/composition.rs@@ -13,6 +13,20 @@ pub(super) struct Catalog {seed: Vec<Row>,revision: String,}+/// A composed command's computer, when the list says it is up and hn has no link to it (one that dropped while it+/// read offline, an error, or never dialled), is dialled now: `launch` then waits for it as for one still connecting.+/// It answered "That computer is offline" while it was up (a shared Mac, 2026-10-22). A dial already pending or in+/// its backoff is left to it (`dial_if_idle`): the waiting command asks again every 100 ms.+fn wake(app: &mut App, name: &str) {+ let mut found = app.fleet.machines.iter()+ .filter(|m| !m.shared && (m.id == name || m.name.eq_ignore_ascii_case(name)));+ let (Some(m), None) = (found.next(), found.next()) else { return };+ if m.online() && matches!(m.reach, crate::fleet::Reach::Unknown | crate::fleet::Reach::Offline | crate::fleet::Reach::Error(_)) {+ let id = m.id.clone();+ app.dial_if_idle(&id);+ }+}+fn host(app: &App, source: &str, name: Option<&str>, connecting: bool) -> Result<String, String> {let Some(name) = name else {return Ok(source.into());@@ -490,6 +504,7 @@ pub(super) fn launch(app: &mut App, request: Request) {else {return;};+ if let Some(name) = launch.host.as_deref() { wake(app, name) }let machine = match host(app, &source.0, launch.host.as_deref(), true) {Ok(m) => m,Err(e) => return reply(app, &request, 1, &e),@@ -784,6 +799,31 @@ mod tests {assert_eq!((row("grid-dev").right.as_str(), row("grid-dev").label_dim, row("grid-dev").tier), (crate::shell_picker::OFFLINE, 8, 1));}+ /// `claude @<computer>` on a computer the list says is up, which hn has no link to (dropped while it read+ /// offline, or never dialled), answered "That computer is offline". It is dialled now, and the launch+ /// waits for it as for one still connecting; one the list says is down is still offline.+ #[tokio::test]+ async fn a_composed_command_dials_a_computer_that_is_up_but_not_linked_yet() {+ let (sink, _) = tokio::sync::mpsc::unbounded_channel();+ let mut app = App::new(19449, sink, (100, 35));+ use crate::fleet::Reach;+ for (id, name, status, reach) in [("m1", "MacBooks-MacBook-Pro-9.local", "online", Reach::Offline), ("m2", "grid-dev", "online", Reach::Error("DISCONNECTED".into())),+ ("m3", "lab", "offline", Reach::Offline), ("m4", "air", "online", Reach::Ready)] {+ app.fleet.machines.push(crate::fleet::Machine { id: id.into(), name: name.into(), shared: false, local: false, status: status.into(), reach });+ }+ for name in ["MacBooks-MacBook-Pro-9.local", "grid-dev"] {+ wake(&mut app, name);+ let id = app.fleet.machines.iter().find(|m| m.name == name).unwrap().id.clone();+ assert_eq!(app.fleet.machine(&id).unwrap().reach, Reach::Connecting, "{name} is dialled");+ assert!(host(&app, "m4", Some(name), true).is_ok(), "{name}: the launch waits for it");+ }+ wake(&mut app, "lab");+ assert_eq!(app.fleet.machine("m3").unwrap().reach, Reach::Offline);+ assert_eq!(host(&app, "m4", Some("lab"), true).unwrap_err(), "That computer is offline. The command was not started.");+ wake(&mut app, "air");+ assert_eq!(app.fleet.machine("m4").unwrap().reach, Reach::Ready, "a linked computer is left as it is");+ }+#[tokio::test]async fn connecting_remote_launch_waits_and_cancellation_prevents_late_work() {let (sink, mut events) = tokio::sync::mpsc::unbounded_channel();