fix(cli): short-circuit join <slug> when already a member (alpha.41)
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

If the arg isn't a URL and matches a mesh already in local config,
print a hint pointing at `launch --mesh <slug>` instead of treating
the slug as an invite code. Avoids the 501 invite_v2_disabled confusion
when users try to "enter" a mesh they already own.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-19 20:11:46 +01:00
parent a5347cebc0
commit 2abf86d540
2 changed files with 19 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "claudemesh-cli",
"version": "1.0.0-alpha.40",
"version": "1.0.0-alpha.41",
"description": "Peer mesh for Claude Code sessions — CLI + MCP server.",
"keywords": [
"claude-code",

View File

@@ -111,6 +111,24 @@ export async function runJoin(args: string[]): Promise<void> {
process.exit(1);
}
// Short-circuit: if the arg matches a mesh already in local config (slug
// or name), we're already joined. Don't go through the invite flow.
if (!link.includes("://")) {
const existing = readConfig().meshes.find(
(m) => m.slug === link || m.name === link,
);
if (existing) {
console.log(`Already in "${existing.slug}" on this machine.`);
console.log("");
console.log(`Use it in the current directory:`);
console.log(` claudemesh launch --mesh ${existing.slug}`);
console.log("");
console.log(`Or list peers:`);
console.log(` claudemesh peers --mesh ${existing.slug}`);
return;
}
}
// Try v2 first — short code / `/i/<code>` URL.
const v2Code = parseV2InviteInput(link);
if (v2Code) {