Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

fix: separate external invitations from the user roster (#1234)

Joshua France32b65879bb45
diff --git a/plugins/admin/public/index.html b/plugins/admin/public/index.html
index 1198e7c68..1c687455d 100644
--- a/plugins/admin/public/index.html
+++ b/plugins/admin/public/index.html
@@ -14263,7 +14263,7 @@
};
const pInput = document.createElement("input");
pInput.type = "text";
- pInput.placeholder = "principal id (e.g. U07ABCD)";
+ pInput.placeholder = "[email protected] or U07ABCD";
pInput.spellcheck = false;
pInput.autocapitalize = "none";
const grantBtn = document.createElement("button");
@@ -14284,8 +14284,12 @@
"err",
);
};
- form.append(mkField("grow", "Principal id", pInput), grantBtn);
- const formCard = dataCard("Grant org admin", "Promote a principal to org admin. Org admins only.", form);
+ form.append(mkField("grow", "Email or principal ID", pInput), grantBtn);
+ const formCard = dataCard(
+ "Grant org admin",
+ "Enter their email or principal ID. They do not need to appear in the Users table first. Org admins only.",
+ form,
+ );
const st = document.createElement("p");
st.className = "status";
st.id = "st-users";
@@ -14444,9 +14448,9 @@
const addBtn = document.createElement("button");
addBtn.type = "button";
addBtn.className = "rowbtn";
- addBtn.textContent = "+";
- addBtn.title = "Add external user";
- addBtn.setAttribute("aria-label", "Add external user");
+ addBtn.textContent = "Invite external user";
+ addBtn.title = "Invite external user";
+ addBtn.setAttribute("aria-label", "Invite external user");
addBtn.setAttribute("aria-expanded", "false");
addBtn.onclick = () => {
const open = !invite.classList.toggle("hidden");
@@ -14538,9 +14542,6 @@
"Everyone who has used the agent — click a row for their activity, artifacts, and config.",
roster,
);
- usersCard.querySelector(".head h2").append(" ", addBtn);
- usersCard.querySelector(".body").prepend(invite);
- usersCard.querySelector(".body").appendChild(externalSt);
lists.appendChild(usersCard);
const external = actionTable(
@@ -14560,15 +14561,17 @@
],
externalUsers.length
? "No external users match."
- : "No external users. Use + on the Users card to invite one.",
+ : "No external users. Use Invite external user to invite an outside collaborator.",
);
- lists.appendChild(
- dataCard(
- "External users",
- "Outside collaborators invited by email. They sign in at the portal with that address until it expires.",
- external,
- ),
+ const externalCard = dataCard(
+ "External users",
+ "Outside collaborators invited by email until an expiry date. Org members do not need an external invite.",
+ external,
);
+ externalCard.querySelector(".head h2").append(" ", addBtn);
+ externalCard.querySelector(".body").prepend(invite);
+ externalCard.querySelector(".body").appendChild(externalSt);
+ lists.appendChild(externalCard);
};
drawLists();
}
diff --git a/plugins/admin/test/user-invite-placement.test.ts b/plugins/admin/test/user-invite-placement.test.ts
new file mode 100644
index 000000000..1c434df14
--- /dev/null
+++ b/plugins/admin/test/user-invite-placement.test.ts
@@ -0,0 +1,54 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import vm from "node:vm";
+
+const html = readFileSync(new URL("../public/index.html", import.meta.url), "utf8");
+
+class Container {
+ children: unknown[] = [];
+ append(...children: unknown[]) {
+ this.children.push(...children);
+ }
+ appendChild(child: unknown) {
+ this.append(child);
+ }
+ prepend(child: unknown) {
+ this.children.unshift(child);
+ }
+}
+
+test("external invitation controls and feedback belong to External users, not the activity roster", () => {
+ const start = html.indexOf("const usersCard = dataCard(");
+ const end = html.indexOf("\n };\n drawLists();", start);
+ assert.ok(start >= 0 && end > start);
+ const cards = new Map<string, { heading: Container; body: Container }>();
+ const addBtn = {};
+ const invite = {};
+ const externalSt = {};
+ vm.runInNewContext(html.slice(start, end), {
+ dataCard(title: string, _description: string, content: unknown) {
+ const heading = new Container();
+ const body = new Container();
+ body.append(content);
+ cards.set(title, { heading, body });
+ return { querySelector: (selector: string) => (selector === ".head h2" ? heading : body) };
+ },
+ actionTable: () => ({}),
+ lists: new Container(),
+ roster: {},
+ addBtn,
+ invite,
+ externalSt,
+ filteredExternal: [],
+ externalUsers: [],
+ });
+ const users = cards.get("Users")!;
+ const external = cards.get("External users")!;
+ assert.ok(external.heading.children.includes(addBtn), "invite control is on External users");
+ assert.ok(external.body.children.includes(invite), "form is on External users");
+ assert.ok(external.body.children.includes(externalSt), "feedback is on External users");
+ assert.ok(!users.heading.children.includes(addBtn));
+ assert.ok(!users.body.children.includes(invite));
+ assert.ok(!users.body.children.includes(externalSt));
+});
diff --git a/skills-seed/admin/SKILL.md b/skills-seed/admin/SKILL.md
index 52684e29f..aeca77d7c 100644
--- a/skills-seed/admin/SKILL.md
+++ b/skills-seed/admin/SKILL.md
@@ -167,7 +167,8 @@ where the admin acts directly. If asked, point them there — don't try the API
answer: the dashboard.
- `409 that address already belongs to a member of the org …` — org email domain, Slack
directory, sign-in allow-list, or someone who has already used the agent. They are not
- external; point the admin at Users / Admins for that person instead.
+ external; to promote them, point the admin at Grant org admin in the dashboard and
+ tell them to enter the email as the principal ID. The person need not appear in Users first.
- `409 that address holds an org admin grant of its own …` — the admin manages that grant
under Admins in the dashboard first.
- `403 capability token not valid for this route` — this core predates agent admin
diff --git a/src/api/routes/admin/users.ts b/src/api/routes/admin/users.ts
index 724c6e447..36f08d536 100644
--- a/src/api/routes/admin/users.ts
+++ b/src/api/routes/admin/users.ts
@@ -22,7 +22,7 @@ const USER_FILES_MAX = 200;
const EXTERNAL_ORG_ADMIN_PORTAL_ONLY =
"granting or removing org admin for an external user is portal-only — the agent cannot manage who governs the org";
const ALREADY_A_MEMBER =
- "that address already belongs to a member of the org — manage them under Users and Admins, not as an external user";
+ "that address already belongs to a member of the org and does not need an external invite. To make them an admin, use Grant org admin in the admin dashboard and enter their email as the principal ID.";
const HOLDS_OWN_GRANT =
"that address holds an org admin grant of its own — revoke it under Admins first, or re-invite with role org_admin";
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
diff --git a/test/admin-external-users.test.ts b/test/admin-external-users.test.ts
index 803903719..8fcb829d9 100644
--- a/test/admin-external-users.test.ts
+++ b/test/admin-external-users.test.ts
@@ -224,7 +224,7 @@ test("an address that already belongs to an org member cannot be invited", async
]) {
const r = await invite(s.base, { email, expiresAt });
assert.equal(r.status, 409, email);
- assert.match(((await r.json()) as any).message, /already belongs to a member/);
+ assert.match(((await r.json()) as any).message, /already belongs to a member.*Grant org admin.*email/s);
assert.equal(s.built.identity.externalMember(email), undefined, email);
}
assert.equal(adminStatusFromGrants(await s.built.admin.listGrants(), "[email protected]").isAdmin, true);