{"version":84,"agent":"speed","message":"whoami and doctor pick the server as join does\n\nAfter abso login --server <url>, whoami and doctor still looked at https://api.abso.dev outside a folder, so they said you weren't signed in, and doctor checked the wrong server. Both now take --server, then ABSO_SERVER, then the folder's server, then the server this box signed in to with abso login, then https://api.abso.dev. A box signed in to more than one server is asked to say which with --server, as join does. Help text says so. Test in client/test/doctor.test.ts.","time":1791615855140,"timeIso":"2026-10-10T07:04:15.140Z","changes":3,"change":880,"files":["client/src/doctor.ts","client/src/main.ts","client/test/doctor.test.ts"],"draft":null,"diff":[{"path":"client/src/doctor.ts","added":26,"removed":1,"diff":"--- a/client/src/doctor.ts\n+++ b/client/src/doctor.ts\n@@ -3,9 +3,12 @@\n // when one fails. Neither prints a credential. plainError words the commonest failures the same way.\n \n import { ApiError } from \"./api-error.ts\";\n-import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox } from \"./box.ts\";\n+import { UsageError } from \"./args.ts\";\n+import { type Answer, type BoxRecord, boxGet, boxText, originOf, readBox, signedInServers } from \"./box.ts\";\n import { builtCopy } from \"./client-version.ts\";\n import { type Config, credentialLabel, findRoot, readConfig } from \"./config.ts\";\n+import { TOKEN_SERVERS } from \"./core.ts\";\n+import { fromEnv } from \"./env-names.ts\";\n \n /** The lowest Node major each kind of copy runs on: the npm package is built for 20, a checkout runs its .ts as is. */\n export function nodeNeeded(built: boolean): number {\n@@ -39,6 +42,28 @@\n \t}\n }\n \n+/**\n+ * The server whoami and doctor look at, in the order join picks one: --server, then ABSO_SERVER, then this\n+ * folder's server, then the one this box signed in to with abso login, then https://api.abso.dev. A box signed\n+ * in to more than one server has to say which.\n+ */\n+export function checkServer(\n+\tflag: string | undefined,\n+\tcwd: string,\n+\tenv: Readonly<Record<string, string | undefined>>,\n+\thome?: string,\n+\tnow = Date.now(),\n+): string {\n+\tconst named = flag ?? fromEnv(env, \"SERVER\");\n+\tif (named) return named;\n+\tconst folder = folderOf(cwd, env)?.config?.server;\n+\tif (folder) return folder;\n+\tconst signedIn = signedInServers(home, now);\n+\tif (signedIn.length > 1)\n+\t\tthrow new UsageError(`this box is signed in to ${signedIn.join(\" and \")}: say which with --server <url>`);\n+\treturn signedIn[0] ?? TOKEN_SERVERS[0]!;\n+}\n+\n const day = (ms: number) => new Date(ms).toISOString().slice(0, 16).replace(\"T\", \" \");\n \n /** The server's view of this box: GET /box, as the box. */"},{"path":"client/src/main.ts","added":5,"removed":5,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -39,7 +39,7 @@\n } from \"./commands.ts\";\n import { configPath, findRoot, installKey, readConfig, readToken } from \"./config.ts\";\n import { newsBlockLines, newsShown, TOKEN_SERVERS } from \"./core.ts\";\n-import { doctor, doctorText, plainError, realProbe, whoami } from \"./doctor.ts\";\n+import { checkServer, doctor, doctorText, plainError, realProbe, whoami } from \"./doctor.ts\";\n import { runDraftSync, runLand, runSwitch } from \"./drafts.ts\";\n import { runExport } from \"./export.ts\";\n import { runBlame, runWhere, runWho, runWhy } from \"./history.ts\";\n@@ -208,9 +208,9 @@\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso whoami [--server <url>]\",\n \t\tabout:\n-\t\t\t\"Who and where you're signed in: this box's sign-in, as the server sees it (so a revoked one shows), its projects, roles and expiry, and this folder's project, agent and kind of key. Never a credential.\",\n+\t\t\t\"Who and where you're signed in: this box's sign-in, as the server sees it (so a revoked one shows), its projects, roles and expiry, and this folder's project, agent and kind of key. Never a credential. The server is --server, else ABSO_SERVER, else this folder's, else the one this box signed in to with abso login, else https://api.abso.dev.\",\n \t\trun: async (args, env) => {\n-\t\t\tconst out = await whoami(boxServer(args, env), env.cwd, env.env, realProbe());\n+\t\t\tconst out = await whoami(checkServer(str(args, \"server\"), env.cwd, env.env), env.cwd, env.env, realProbe());\n \t\t\treturn { text: out.text, json: out.json };\n \t\t},\n \t},\n@@ -218,9 +218,9 @@\n \t\tflags: { server: \"string\" },\n \t\tusage: \"abso doctor [--server <url>]\",\n \t\tabout:\n-\t\t\t\"Checks what commands need, one line each: Node's version, that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project. A failed check says what to do next, and the exit is 1. Never prints a credential.\",\n+\t\t\t\"Checks what commands need, one line each: Node's version, that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project. A failed check says what to do next, and the exit is 1. Never prints a credential. It picks the server as whoami does.\",\n \t\trun: async (args, env) => {\n-\t\t\tconst checks = await doctor(boxServer(args, env), env.cwd, env.env, realProbe());\n+\t\t\tconst checks = await doctor(checkServer(str(args, \"server\"), env.cwd, env.env), env.cwd, env.env, realProbe());\n \t\t\tconst failed = checks.some((c) => c.result === \"fail\");\n \t\t\treturn { text: doctorText(checks), json: { checks }, ...(failed ? { exit: EXIT.error } : {}) };\n \t\t},"},{"path":"client/test/doctor.test.ts","added":24,"removed":1,"diff":"--- a/client/test/doctor.test.ts\n+++ b/client/test/doctor.test.ts\n@@ -8,7 +8,7 @@\n import { test } from \"node:test\";\n import { ApiError } from \"../src/api-error.ts\";\n import { writeBox } from \"../src/box.ts\";\n-import { doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from \"../src/doctor.ts\";\n+import { checkServer, doctor, doctorText, nodeNeeded, type Probe, plainError, whoami } from \"../src/doctor.ts\";\n \n const SERVER = \"https://staging.abso.example\";\n const CREDENTIAL = \"abso_bx_the-secret-credential\";\n@@ -227,3 +227,26 @@\n \tassert.equal(plainError(new ApiError(\"GET /log answered 500: boom\", 500), true), undefined);\n \tassert.equal(plainError(new Error(\"anything else\"), true), undefined);\n });\n+\n+test(\"whoami and doctor pick the server as join does: --server, ABSO_SERVER, the folder's, the box's sign-in, then abso.dev\", () => {\n+\tconst outside = temp(\"outside\");\n+\tconst empty = temp(\"home\");\n+\tassert.equal(checkServer(undefined, outside, {}, empty, NOW), \"https://api.abso.dev\");\n+\tconst home = temp(\"home\");\n+\twriteBox(box(), home);\n+\tassert.equal(checkServer(undefined, outside, {}, home, NOW), SERVER);\n+\tassert.equal(checkServer(undefined, folder(), {}, empty, NOW), SERVER);\n+\tassert.equal(checkServer(undefined, outside, { ABSO_SERVER: \"http://env.example\" }, home, NOW), \"http://env.example\");\n+\tassert.equal(\n+\t\tcheckServer(\"http://flag.example\", folder(), { ABSO_SERVER: \"http://env.example\" }, home, NOW),\n+\t\t\"http://flag.example\",\n+\t);\n+\tconst expired = temp(\"home\");\n+\twriteBox(box(NOW - 1), expired);\n+\tassert.equal(checkServer(undefined, outside, {}, expired, NOW), \"https://api.abso.dev\");\n+\twriteBox({ ...box(), server: \"https://api.abso.dev\" }, home);\n+\tassert.throws(\n+\t\t() => checkServer(undefined, outside, {}, home, NOW),\n+\t\t/signed in to .* and .*: say which with --server/,\n+\t);\n+});"}],"ci":null}