Skip to content

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

Joining a team after installing tincan on its own

Lars Talian7312f5394246
diff --git a/Cargo.lock b/Cargo.lock
index 3263960..72a4051 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3608,7 +3608,7 @@ dependencies = [
[[package]]
name = "tincan"
-version = "0.6.1"
+version = "0.6.2"
dependencies = [
"anyhow",
"blake3",
diff --git a/Cargo.toml b/Cargo.toml
index 223b9e4..106add2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tincan"
-version = "0.6.1"
+version = "0.6.2"
edition = "2024"
description = "Team directory and message bus for coding agents across machines"
license = "MIT OR Apache-2.0"
diff --git a/README.md b/README.md
index 4be8ed6..0649278 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,9 @@ continue". Gemini CLI only runs hooks and MCP servers in trusted folders.
Or let your agent do it: tell it "join my tincan team: <link>" (the join page has that line ready to copy).
+Already installed tincan on its own? Run `tincan join '<link>'` (or the link's command again). If you started a
+team by yourself first, joining swaps it for the new one; if others are in your team, `tincan leave` first.
+
On a Mac, tincan sits in the menu bar while it runs: two speech bubbles, filled while a teammate is connected,
with the number of messages waiting for you. Its menu lists each machine's sessions and what they're doing,
and copies the team link. "Hide menu bar icon" turns it off (`tincan setup` turns it back on).
diff --git a/src/daemon/teamops.rs b/src/daemon/teamops.rs
index 2ca4df7..58edf84 100644
--- a/src/daemon/teamops.rs
+++ b/src/daemon/teamops.rs
@@ -179,9 +179,33 @@ impl Daemon {
/// Joins with an invite code (`plum-tiger-lake-orbit`) or a long `tincan1…` ticket.
pub(super) async fn join_team(self: &Arc<Self>, invite_text: &str, person: &str) -> Result<TeamInfo> {
+ let mut solo = false;
if let Some(t) = self.team_state() {
- bail!("already in team '{}'; run `tincan leave` first", t.name());
+ let me = self.key.public();
+ let mut others: Vec<String> = t.active().filter(|m| m.endpoint != me).map(|m| m.person.clone()).collect();
+ others.dedup();
+ if !others.is_empty() {
+ bail!(
+ "already in team '{}' (with {}). To switch, run `tincan leave`, then join again",
+ t.name(),
+ others.join(", ")
+ );
+ }
+ // A team of one that nobody joined: switching loses nothing. It stays until the join succeeds.
+ solo = true;
+ let old = self.net.write().unwrap().take();
+ if let Some(net) = old {
+ net.shutdown().await;
+ }
}
+ let res = self.join_with(invite_text, person).await;
+ if res.is_err() && solo {
+ let _ = self.start_net().await;
+ }
+ res
+ }
+
+ async fn join_with(self: &Arc<Self>, invite_text: &str, person: &str) -> Result<TeamInfo> {
let person = util::slug(person);
if person.is_empty() {
bail!("your name needs letters or digits");
diff --git a/src/wizard.rs b/src/wizard.rs
index c42dbed..b0c1f76 100644
--- a/src/wizard.rs
+++ b/src/wizard.rs
@@ -89,6 +89,17 @@ pub async fn onboard(start: Option<bool>, team: Option<String>, invite: Option<S
sp.stop(format!("Joined team {} as {} on {}.", t.name, t.person, t.machine));
break;
}
+ Err(e) if e.to_string().starts_with("already in team") => {
+ let why = e.to_string();
+ sp.error(format!("You're {}.", why.split(". To switch").next().unwrap_or(&why)));
+ if !confirm("Leave it and join this team instead?").initial_value(false).interact()? {
+ return Err(anyhow!("not joined; you're still in your old team"));
+ }
+ let pid = crate::daemon_pid();
+ link.call::<String>(Request::Leave { force: false }).await?;
+ crate::wait_exit(pid).await;
+ invite = Some(text);
+ }
Err(e) if e.to_string().contains("already in this team") => {
sp.error(format!("Someone in the team is already called {person}."));
person = util::slug(&input("Pick another name").validate(|s: &String| name_ok(s)).interact::<String>()?);
diff --git a/tests/e2e/two_machines.py b/tests/e2e/two_machines.py
index a2fb9b8..15ccf06 100644
--- a/tests/e2e/two_machines.py
+++ b/tests/e2e/two_machines.py
@@ -90,7 +90,15 @@ check("joiner sees alex connected", re.search(r"alex\s+laptop\s+(direct|relay)",
out = cli("alex", "team")
check("founder sees alice connected", re.search(r"alice\s+desktop\s+(direct|relay)", out) is not None, out)
out = cli("alice", "join", link.group(1), "--as", "bob", "--no-setup")
-check("second join is refused (already in a team)", "already in team" in out, out)
+check("joining a second team is refused while yours has others, and says how to switch",
+ "already in team 'vibes' (with alex)" in out and "tincan leave" in out, out)
+# Installed on its own and started a team by itself first: the team link still just works.
+sam = dict(env("alice"), TINCAN_HOME=os.path.join(D, "sam"), TINCAN_MACHINE="mini")
+r = subprocess.run([BIN, "init", "solo", "--as", "sam", "--no-setup"], env=sam, capture_output=True, text=True, timeout=90)
+r = subprocess.run([BIN, "join", link.group(1), "--as", "sam", "--no-setup"], env=sam, capture_output=True, text=True, timeout=90)
+check("a team of one is swapped for the team you join", "Joined team vibes as sam on mini." in r.stdout, r.stdout + r.stderr)
+subprocess.run([BIN, "leave"], env=sam, capture_output=True, timeout=60)
+subprocess.run([BIN, "stop"], env=sam, capture_output=True)
os.makedirs(os.path.join(D, "bob"), exist_ok=True)
bob = dict(env("alice"), TINCAN_HOME=os.path.join(D, "bob"), TINCAN_MACHINE="nuc")
out = cli("alex", "invite", "--code")