feat(#2039): list matrix identities in get_agent_meta

This commit is contained in:
damocles 2026-06-27 11:51:34 +02:00 committed by mara
commit 5b442796ca
3 changed files with 59 additions and 0 deletions

View file

@ -58,6 +58,7 @@ pub enum SocketReply {
status_set_at: Option<i64>,
hive_name: Option<String>,
swarm_name: Option<String>,
matrix_accounts: Vec<hive_sh4re::MatrixIdentity>,
},
/// `create_repo` result — the new repo's full name + clone URL.
RepoCreated {
@ -109,6 +110,7 @@ impl From<hive_sh4re::Response> for SocketReply {
status_set_at,
hive_name,
swarm_name,
matrix_accounts,
} => Self::AgentMeta {
name,
running,
@ -117,6 +119,7 @@ impl From<hive_sh4re::Response> for SocketReply {
status_set_at,
hive_name,
swarm_name,
matrix_accounts,
},
hive_sh4re::Response::RepoCreated {
full_name,
@ -452,6 +455,7 @@ pub fn format_agent_meta(resp: Result<SocketReply, anyhow::Error>) -> String {
status_set_at,
hive_name,
swarm_name,
matrix_accounts,
}) => {
let rev = hyperhive_rev.as_deref().unwrap_or("<unknown>");
let run = if running { "yes" } else { "no" };
@ -498,6 +502,22 @@ pub fn format_agent_meta(resp: Result<SocketReply, anyhow::Error>) -> String {
}
}
}
// Matrix identities the agent can act as (the `account` arg on
// the matrix tools). Listed only when matrix is provisioned, so
// non-matrix agents don't see an empty line.
if !matrix_accounts.is_empty() {
use std::fmt::Write as _;
out.push_str("\nmatrix_accounts:");
for acct in &matrix_accounts {
let uid = acct.user_id.as_deref().unwrap_or("?");
let primary = if acct.is_primary { " [primary]" } else { "" };
let _ = write!(
out,
"\n {} ({uid}) on {}{primary}",
acct.name, acct.homeserver
);
}
}
out
}
Ok(SocketReply::Err(m)) => format!("get_agent_meta failed: {m}"),