{"draft":null,"from":68,"to":69,"files":[{"path":"client/src/join-commands.ts","added":22,"removed":2,"diff":"--- a/client/src/join-commands.ts\n+++ b/client/src/join-commands.ts\n@@ -16,6 +16,7 @@\n import { clearKnown, loadIgnore, readFolder, writeKnown } from \"./folder.ts\";\n import { modInstalled } from \"./install.ts\";\n import { type FullMode, foldModes, writeKnownModes } from \"./modes.ts\";\n+import { siteOf } from \"./orgs.ts\";\n import { projectFileName, readProjectFile, startingProjectFileText, writeStartingProjectFile } from \"./project-file.ts\";\n import { refusedText } from \"./safety.ts\";\n import { OLD_STATE_DIR, STATE_DIR, stateDir } from \"./state-dir.ts\";\n@@ -123,6 +124,22 @@\n \treturn sub;\n }\n \n+/**\n+ * Why a join failed signed out. The client reads only as an agent, which needs a\n+ * sign-in; a public project is read signed out on the website. Whether the\n+ * project is public is asked of the server with no credentials.\n+ */\n+async function signedOut(server: string, project: string): Promise<string> {\n+\tlet open = false;\n+\ttry {\n+\t\tconst response = await fetch(new URL(`/p/${project}/status`, server), { signal: AbortSignal.timeout(3000) });\n+\t\topen = response.ok;\n+\t} catch {}\n+\treturn open\n+\t\t? `${project} is public: read it at ${siteOf(server)}/p/${project} (every page is also JSON). The client needs a sign-in, even to read: abso login.`\n+\t\t: `This box isn't signed in to ${server}. abso login signs it in.`;\n+}\n+\n export async function runJoin(args: Parsed, env: Env): Promise<Output> {\n \tif (args.positionals.length !== 1) throw new UsageError(\"join takes the project name: abso join <project>\");\n \tconst project = args.positionals[0]!;\n@@ -144,7 +161,10 @@\n \t\tminted = box && !hasKey ? await mintKey(box, project, agent) : undefined;\n \t} else {\n \t\t// No --agent: the box's name, or the next free -2, -3.\n-\t\tif (!box) throw new UsageError(\"abso login signs this box in first (or give --agent <name>)\");\n+\t\tif (!box)\n+\t\t\tthrow new UsageError(\n+\t\t\t\t`${await signedOut(server, project)} (A folder that already has a key joins with --agent <name>.)`,\n+\t\t\t);\n \t\tif (hasKey) throw new UsageError(`${root} already has a key: give its agent's name with --agent <name>`);\n \t\tconst free = await mintFreeName(box, project, defaultAgentName());\n \t\tagent = free.agent;\n@@ -165,7 +185,7 @@\n \t} catch (error) {\n \t\tif (!(error instanceof ApiError && error.status === 401 && !box && !settings.token)) throw error;\n \t\trmSync(stateDir(root), { recursive: true, force: true });\n-\t\tthrow new UsageError(`This box isn't signed in to ${config.server}. abso login signs it in.`);\n+\t\tthrow new UsageError(await signedOut(config.server, project));\n \t}\n \treturn {\n \t\ttext: ["}],"unmatched":[]}