Skip to content

armgit / muxin

Public Imported from GitHub
0

All your machines, one app. For you and your AI agents: agent sessions, desktops, files, logs and GitHub across your Macs, Linux and Windows machines, with an MCP server.

Say why a machine can't be reached once, and say it right

Adib Hannae3dba2457523
diff --git a/src/fleet/build.rs b/src/fleet/build.rs
index 3c4219c..5130041 100644
--- a/src/fleet/build.rs
+++ b/src/fleet/build.rs
@@ -414,7 +414,24 @@ pub fn explain_unreachable(spec: &MachineSpec, p: &ProbeResult, retrying: bool,
let again = if retrying { "Reconnects when it's back." } else { "Check again when it's back." };
let (title, detail, hint) = match kind {
"offline" => (format!("{name} is offline"), format!("Shut down, asleep, or off the network. {again}"), None),
- "refused" => (format!("{name} isn't accepting connections"), "Starting up, or Remote Login (ssh) is off.".to_string(), None),
+ // ssh got to the machine it goes through (ProxyJump), and nothing
+ // answered behind it.
+ "refused" if ["stdio forwarding failed", "open failed: connect failed"].iter().any(|w| error.contains(w)) => {
+ (format!("{name} isn't answering"), format!("The machine it's reached through is up, but nothing answers behind it: {name} is off, or its ssh server isn't running."), None)
+ }
+ "refused" => {
+ let os = p.os.as_deref().or(spec.platform.as_deref()).unwrap_or("").to_ascii_lowercase();
+ let ssh = if os.starts_with("darwin") || os.starts_with("macos") {
+ "Remote Login (ssh) is off"
+ } else if os.starts_with("windows") {
+ "OpenSSH Server isn't running"
+ } else if os.is_empty() {
+ "ssh is off"
+ } else {
+ "its ssh server isn't running"
+ };
+ (format!("{name} isn't accepting connections"), format!("Starting up, or {ssh}."), None)
+ }
"auth" => {
// "[email protected]: Permission denied (...)": who ssh signed in as.
let user = error
@@ -1251,6 +1268,24 @@ mod tests {
assert!(u.hint.unwrap().starts_with("ssh-copy-id -i "));
}
+ #[test]
+ fn says_why_ssh_was_refused() {
+ let inv = inventory("[[machine]]\nname = \"Win11\"\nhost = \"win11\"\n");
+ let refused = |error: &str, os: Option<&str>| ProbeResult { ok: false, error: Some(error.into()), os: os.map(Into::into), ..Default::default() };
+
+ // Through a jump host that's up, with nothing behind it.
+ let p = refused("channel 0: open failed: connect failed: Connection refused\nstdio forwarding failed\nConnection closed by UNKNOWN port 65535", None);
+ let u = explain_unreachable(&inv.machines[0], &p, true, None, None);
+ assert_eq!(u.kind, "refused");
+ assert!(u.detail.contains("reached through is up"), "{}", u.detail);
+
+ // Straight to it: what's off depends on its OS.
+ let p = refused("ssh: connect to host win11 port 22: Connection refused", Some("windows"));
+ assert!(explain_unreachable(&inv.machines[0], &p, true, None, None).detail.contains("OpenSSH Server"));
+ let p = refused("ssh: connect to host win11 port 22: Connection refused", Some("Darwin"));
+ assert!(explain_unreachable(&inv.machines[0], &p, true, None, None).detail.contains("Remote Login"));
+ }
+
#[test]
fn names_why_a_machine_cant_be_reached() {
for (error, kind) in [
diff --git a/src/ui/overview.rs b/src/ui/overview.rs
index 1ae0e89..bc238f7 100644
--- a/src/ui/overview.rs
+++ b/src/ui/overview.rs
@@ -42,7 +42,7 @@ impl Root {
if let Some(err) = &s.inventory.error {
body = body.child(callout(&theme, "error", "config.toml has an error", err.clone(), None));
}
- if !s.attention.is_empty() {
+ if s.attention.iter().any(|a| !on_cards(a)) {
body = body.child(self.heads_up(&theme, &s, content_width, cx));
}
body.child(self.render_machine_grid(&theme, &s, content_width, cx)).child(self.render_agents(&theme, &s, cx))
@@ -107,11 +107,11 @@ impl Root {
/// What needs a look, one compact line each; the first few unless opened.
fn heads_up(&self, theme: &Theme, s: &Snapshot, width: f32, cx: &mut Context<Self>) -> impl IntoElement {
const SHOWN: usize = 3;
- let hidden = if self.heads_up_open { 0 } else { s.attention.len().saturating_sub(SHOWN) };
- let mut rows: Vec<AnyElement> = s
- .attention
+ let items: Vec<_> = s.attention.iter().filter(|a| !on_cards(a)).collect();
+ let hidden = if self.heads_up_open { 0 } else { items.len().saturating_sub(SHOWN) };
+ let mut rows: Vec<AnyElement> = items
.iter()
- .take(s.attention.len() - hidden)
+ .take(items.len() - hidden)
.enumerate()
.map(|(i, a)| {
let color = theme.level(&a.level);
@@ -149,7 +149,7 @@ impl Root {
.into_any_element()
})
.collect();
- if s.attention.len() > SHOWN {
+ if items.len() > SHOWN {
let label = if hidden > 0 { format!("Show {hidden} more") } else { "Show fewer".to_string() };
rows.push(
div()
@@ -246,12 +246,15 @@ impl Root {
now.push(now_row_owned(theme, kit::tile("workflow", rf, rt, 18.).into_any_element(), label, state, color, inner));
}
}
+ // The subtitle already says it can't be reached: this line says why.
let empty_line = if offline {
Some(match &m.unreachable {
+ _ if m.is_disconnected() => "Connect to it from its page to see what's running.".into(),
Some(u) if u.kind == "offline" => match u.last_seen_at {
Some(t) => format!("Asleep or off the network. Last seen {}.", format::ago(Some(t))),
None => "Asleep or off the network.".into(),
},
+ Some(u) if !u.detail.is_empty() => u.detail.clone(),
Some(u) => u.title.clone(),
None => "Can't connect.".into(),
})
@@ -340,7 +343,7 @@ impl Root {
.flex_col()
.min_h(px(NOW_ROW_H * NOW_ROWS as f32))
.children(now)
- .children(empty_line.map(|t| div().pt(px(4.)).text_size(px(12.)).text_color(if offline && !format::is_just_offline(m) { theme.error } else { theme.text_placeholder }).child(t))),
+ .children(empty_line.map(|t| div().pt(px(4.)).text_size(px(12.)).text_color(theme.text_placeholder).child(t))),
)
.child(div().pt(px(10.)).border_t_1().border_color(theme.border_variant).child(footer))
.on_mouse_down(gpui::MouseButton::Right, {
@@ -708,3 +711,8 @@ fn job_title(theme: &Theme, j: &Job, width: Option<f32>) -> impl IntoElement {
j.branch.as_ref().map(|b| format!(" · {b}")).unwrap_or_default()
)))
}
+
+/// Shown on the machine cards below the heads-up, so not repeated in it.
+fn on_cards(a: &crate::fleet::model::Attention) -> bool {
+ a.id == "unreachable"
+}