Skip to content

Reason Network: your team's coding agents, talking to each other. The engine behind `reason network`.

The team reply carries team_id and team_name

Lars Taliane2eb4041342c
diff --git a/src/daemon/teamops.rs b/src/daemon/teamops.rs
index c7b20c2..fe93747 100644
--- a/src/daemon/teamops.rs
+++ b/src/daemon/teamops.rs
@@ -209,6 +209,7 @@ impl Daemon {
Ok(TeamInfo {
id: self.team_id().unwrap_or_default(),
name: name.into(),
+ team_name: name.into(),
relay,
relay_connected: None,
person,
@@ -292,6 +293,7 @@ impl Daemon {
let info = TeamInfo {
id: state.id.clone(),
name: state.name().into(),
+ team_name: state.name().into(),
relay: state.meta.body.relay.clone(),
relay_connected: None,
person: person.clone(),
@@ -429,6 +431,7 @@ impl Daemon {
Ok(TeamInfo {
id: team.id.clone(),
name: team.name().into(),
+ team_name: team.name().into(),
relay: team.meta.body.relay.clone(),
relay_connected: self.net().map(|n| n.relay_connected()),
person: self.person.clone(),
diff --git a/src/proto.rs b/src/proto.rs
index a4d5347..c95e3ff 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -330,9 +330,13 @@ pub struct MachineInfo {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TeamInfo {
- #[serde(default)]
+ /// The team's id, 32 hex digits (the Reason CLI and connector route by it).
+ #[serde(default, rename = "team_id")]
pub id: String,
pub name: String,
+ /// `name` again, under the name `team --json` gives it.
+ #[serde(default)]
+ pub team_name: String,
pub relay: Option<String>,
/// Whether this machine is on its relay right now (`None` while the network isn't up).
#[serde(default)]
@@ -416,3 +420,31 @@ pub struct Unread {
pub count: u32,
pub from: Vec<String>,
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_team_reply_names_the_team_by_id_and_name() {
+ let t = TeamInfo {
+ id: "00112233445566778899aabbccddeeff".into(),
+ name: "vibes".into(),
+ team_name: "vibes".into(),
+ relay: None,
+ relay_connected: None,
+ person: "alex".into(),
+ machine: "mbp".into(),
+ machines: vec![],
+ };
+ let v = serde_json::to_value(&t).unwrap();
+ assert_eq!(v["team_id"], "00112233445566778899aabbccddeeff");
+ assert_eq!((v["team_name"].as_str(), v["name"].as_str()), (Some("vibes"), Some("vibes")));
+ // A reply from a daemon before these fields still reads.
+ let old: TeamInfo =
+ serde_json::from_value(serde_json::json!({"name": "vibes", "relay": null, "person": "alex",
+ "machine": "mbp", "machines": []}))
+ .unwrap();
+ assert_eq!((old.id.as_str(), old.name.as_str()), ("", "vibes"));
+ }
+}