Skip to content

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

Review fixes: workspace hint where friends get the link, copy kept current

Lars Talianc31a03e277bd
diff --git a/src/daemon/update.rs b/src/daemon/update.rs
index e827bde..5922a0a 100644
--- a/src/daemon/update.rs
+++ b/src/daemon/update.rs
@@ -39,6 +39,11 @@ async fn update() -> Result<Option<String>> {
return Ok(None);
}
let dir = crate::util::current_exe()?.parent().map(|d| d.to_path_buf()).unwrap_or_default();
+ // A tincan copy still waiting to be moved over (see `migrate`) is a copy of this binary: it stays one.
+ let exe = dir.join(format!("{}{}", crate::AGENT_NAME, std::env::consts::EXE_SUFFIX));
+ let copy = crate::setup::legacy_exe(&exe);
+ let waiting = std::fs::symlink_metadata(&copy).is_ok_and(|m| m.is_file())
+ && std::fs::read(&copy).is_ok_and(|b| std::fs::read(&exe).is_ok_and(|o| o == b));
let mut cmd = tokio::process::Command::from(crate::installer(&dir));
cmd.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::piped())
@@ -65,9 +70,11 @@ async fn update() -> Result<Option<String>> {
if !out.status.success() {
bail!("install failed: {}", String::from_utf8_lossy(&out.stderr).trim());
}
+ if waiting && std::fs::remove_file(&copy).is_ok() {
+ let _ = std::fs::copy(&exe, &copy);
+ }
// Restart only on a binary that really is newer (a release tagged without bumping its version must not loop).
- let installed = dir.join(format!("{}{}", crate::AGENT_NAME, std::env::consts::EXE_SUFFIX));
- let installed = tokio::process::Command::new(installed).arg("--version").kill_on_drop(true).output();
+ let installed = tokio::process::Command::new(&exe).arg("--version").kill_on_drop(true).output();
let installed = tokio::time::timeout(Duration::from_secs(30), installed).await??;
let installed =
String::from_utf8_lossy(&installed.stdout).trim().rsplit(' ').next().unwrap_or_default().to_string();
diff --git a/src/main.rs b/src/main.rs
index 14b2616..a1708e3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -457,7 +457,7 @@ async fn cli(cmd: Cmd) -> Result<()> {
let who = if me { "another machine of yours" } else { "a teammate" };
println!("Invite code for {who}: {}\n", i.code);
let [unix, windows] = install_lines(&i.code);
- if managed() {
+ if managed() && !me {
println!("Teammates in your Reason workspace just run `reason network`. Anyone else:\n");
}
println!("They run this, which installs Reason Network (no account needed) and joins the team:\n");
diff --git a/src/migrate.rs b/src/migrate.rs
index 98fa713..97a0e25 100644
--- a/src/migrate.rs
+++ b/src/migrate.rs
@@ -67,7 +67,7 @@ pub async fn run(log: fn(&str)) {
#[cfg(unix)]
let service_moved = !legacy || swap;
#[cfg(windows)]
- let service_moved = true;
+ let service_moved = !setup::legacy_run_entry(&exe);
let left = setup::legacy_wiring(&exe);
if !left.is_empty() {
log(&format!("moved over from {LEGACY_NAME}: kept it for {} until they move over", left.join(", ")));
diff --git a/src/setup.rs b/src/setup.rs
index c17c6a5..a78ef7b 100644
--- a/src/setup.rs
+++ b/src/setup.rs
@@ -839,20 +839,26 @@ fn run_entry() -> Option<String> {
out.status.success().then(|| String::from_utf8_lossy(&out.stdout).into_owned())
}
-/// Moves the Run entry a standalone tincan install made over to this binary. True if there was one.
+/// The Run entry a standalone tincan install made, if it still starts this binary or the tincan it replaced.
#[cfg(windows)]
-pub fn move_legacy_run_entry(exe: &Path) -> bool {
+pub fn legacy_run_entry(exe: &Path) -> bool {
+ Command::new("reg")
+ .args(["query", RUN_KEY, "/v", "dev.tincan.daemon"])
+ .stdin(std::process::Stdio::null())
+ .output()
+ .is_ok_and(|o| o.status.success() && ours(&String::from_utf8_lossy(&o.stdout), exe))
+}
+
+/// Moves that Run entry over to this binary (ours first, then the old one goes).
+#[cfg(windows)]
+pub fn move_legacy_run_entry(exe: &Path) {
let reg = |args: &[&str]| Command::new("reg").args(args).stdin(std::process::Stdio::null()).output();
- let legacy = "dev.tincan.daemon";
- let had = reg(&["query", RUN_KEY, "/v", legacy])
- .is_ok_and(|o| o.status.success() && ours(&String::from_utf8_lossy(&o.stdout), exe));
- if had {
+ if legacy_run_entry(exe) {
let command = format!("\"{}\" daemon --service", exe.display());
if reg(&["add", RUN_KEY, "/v", &service_name(), "/d", &command, "/f"]).is_ok_and(|o| o.status.success()) {
- let _ = reg(&["delete", RUN_KEY, "/v", legacy, "/f"]);
+ let _ = reg(&["delete", RUN_KEY, "/v", "dev.tincan.daemon", "/f"]);
}
}
- had
}
#[cfg(windows)]
diff --git a/src/wizard.rs b/src/wizard.rs
index 5cefee0..4eb8611 100644
--- a/src/wizard.rs
+++ b/src/wizard.rs
@@ -252,6 +252,9 @@ pub async fn show_link(new: bool) -> Result<String> {
"Send it to your friends: one paste and their name, and they're in.\nIt works for everyone until `{CLI} link --new`."
),
)?;
+ if crate::managed() {
+ log::info("Teammates in your Reason workspace just run `reason network`; the link is for anyone else.")?;
+ }
Ok(l.url)
}
@@ -260,9 +263,6 @@ pub async fn show_code(me: bool) -> Result<()> {
let i: InviteInfo = Link::new(None).call(Request::Invite { me, hours: 24 }).await?;
let [unix, windows] = install_lines(&i.code);
let who = if me { "your other machine" } else { "your teammate" };
- if crate::managed() && !me {
- log::info("Teammates in your Reason workspace just run `reason network`.")?;
- }
note(
format!("Invite code: {}", i.code),
format!(