get_agent_meta: include hive_name + swarm_name in response (#710)

This commit is contained in:
damocles 2026-05-31 12:45:10 +02:00 committed by Mara
commit a91cf4493f
6 changed files with 69 additions and 1 deletions

View file

@ -59,6 +59,8 @@ pub enum SocketReply {
hyperhive_rev: Option<String>,
status_text: Option<String>,
status_set_at: Option<i64>,
hive_name: Option<String>,
swarm_name: Option<String>,
},
}
@ -83,6 +85,8 @@ impl From<hive_sh4re::AgentResponse> for SocketReply {
hyperhive_rev,
status_text,
status_set_at,
hive_name,
swarm_name,
} => Self::AgentMeta {
name,
role,
@ -90,6 +94,8 @@ impl From<hive_sh4re::AgentResponse> for SocketReply {
hyperhive_rev,
status_text,
status_set_at,
hive_name,
swarm_name,
},
}
}
@ -118,6 +124,8 @@ impl From<hive_sh4re::ManagerResponse> for SocketReply {
hyperhive_rev,
status_text,
status_set_at,
hive_name,
swarm_name,
} => Self::AgentMeta {
name,
role,
@ -125,6 +133,8 @@ impl From<hive_sh4re::ManagerResponse> for SocketReply {
hyperhive_rev,
status_text,
status_set_at,
hive_name,
swarm_name,
},
}
}
@ -298,11 +308,23 @@ pub fn format_agent_meta(resp: Result<SocketReply, anyhow::Error>) -> String {
hyperhive_rev,
status_text,
status_set_at,
hive_name,
swarm_name,
}) => {
let rev = hyperhive_rev.as_deref().unwrap_or("<unknown>");
let run = if running { "yes" } else { "no" };
let mut out =
format!("name: {name}\nrole: {role}\nhyperhive_rev: {rev}\nrunning: {run}");
// #710: surface hive + swarm display names only when set,
// so single-hive deployments don't see noisy `<none>` lines.
if let Some(hn) = hive_name.as_deref() {
use std::fmt::Write as _;
let _ = write!(out, "\nhive_name: {hn}");
}
if let Some(sn) = swarm_name.as_deref() {
use std::fmt::Write as _;
let _ = write!(out, "\nswarm_name: {sn}");
}
match status_text {
None => out.push_str("\nstatus: <none>"),
Some(s) => {