Skip to content
Merged
3 changes: 3 additions & 0 deletions browser-host/relay-broker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ async function relayAuthority(fetch, relay) {
channelIdentity:
Array.isArray(nip11.supported_extensions) &&
nip11.supported_extensions.includes("nip-cl"),
soloMemberRoleUpdates:
Array.isArray(nip11.supported_extensions) &&
nip11.supported_extensions.includes("buzz-solo-member-role"),
// NIP-AR sync: REQ with `"artifact": "current"` keeps a set current.
artifactSync: nip11.artifacts?.sync?.version === 1,
artifactSupport:
Expand Down
5 changes: 5 additions & 0 deletions docs/buzz-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ and are asked to sign in again in Buzz.
the chat; anyone else outside the chat is only named: not added and not
notified, and the picker row says so. People already in the chat are notified
as usual. The toolbar's agent menu lists agents only.
In a **Private** Solo chat on a relay that supports role updates, the owner can
use a current member’s menu in **Share access** to lower their access.
The owner can restore **Participating** for a verified
agent and grant **Admin** to their own verified agents. **Viewing only**
gives read-only access to that chat.
New chats start **Ongoing** unless **Chat settings** chooses **Temporary**,
which archives the chat after a set time without activity. To start every new
chat temporary, open the community's **Settings → Local settings** and choose
Expand Down
27 changes: 16 additions & 11 deletions docs/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,10 @@ to its underlying conversation/message without that panel.

The header **Access** button opens the one access dialog every conversation uses.
It is titled **Channel access** in channels and **Chat access** in a Solo chat (see
[Sharing a Solo chat](solo/sharing.md)). A Solo chat owner can remove people and
agents there but cannot change roles.
[Sharing a Solo chat](solo/sharing.md)). A Solo chat owner can remove current
non-owner members. In a Private Solo chat on a relay that supports role updates,
the owner can lower their access, restore participation for verified agents,
and grant Admin to their own verified agents.
Comment thread
tellaho marked this conversation as resolved.
Resolved
One search field, with an accessible name but no visible label, filters current
members and lists people, agents and Teams to invite under **Not in this channel**.
With an empty query, channels and Solo chats show invitations only when the viewer is
Expand Down Expand Up @@ -1298,18 +1300,21 @@ disposal, but cannot retract a request already sent. Unsent work is canceled;
recovery is in-memory, not durable across session disposal or restart.

The development broker and native transport advertise a separate
`memberAdministration` capability and admit only exact `9000` Admin/Member/Guest
changes, the signer's own ownership transfer or `9001` other-member removals
through purpose-bound routes. Generic
invitation signing is unchanged; the relay still enforces the authoritative ACL.
`memberAdministration` capability. Its purpose-bound routes admit ordinary
channel `9000` Admin/Member/Guest changes and the signer's own ownership transfer,
as well as `9001` other-member removals. The relay enforces the authoritative ACL.
Hosts without this writer can read verified roles but expose no management controls.
Native support requires a rebuilt binary; no unrestricted writer fallback is used.

**Accepted protocol limitation:** role commands are existing relay upserts, not
conditional updates. A departure after final preflight can be undone by the role
command re-adding the target; a concurrent role edit can be overwritten. Client
checks/readback reduce uncertainty but do not provide atomic conflict rejection.
Preventing these races requires separately scoped relay support.
In Private Solo chats, the writer uses kind `9050` for role changes when the
relay advertises `buzz-solo-member-role` in its NIP-11 information document.
The command includes the target's expected current role. The relay updates an
existing member only if that role still matches, so it rejects the edit if the
member left or their role changed before the write.

Ordinary channel `9000` role changes are unconditional relay upserts. A command
can re-add a member who departed after the final preflight or overwrite a
concurrent role edit. Client checks and readback reduce uncertainty.

Regression coverage lives in `administration.test.ts`,
`MemberAdministration.test.tsx`, `native.test.ts`, and `browser-host/relay-broker-api.test.mjs`;
Expand Down
10 changes: 8 additions & 2 deletions docs/solo/sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ Where the viewer cannot add agents, a note says to mention an agent in the chat
instead.
Current access uses the channel groups (**People**, **Agents**) with Owner and
Admin tags, and each row has the channel members' actions menu, so the chat owner
can remove someone. The verified roster shows loading or failure, never treating a
failed read as an empty audience.
can remove someone. In a Private chat on a relay that supports Solo role updates,
the owner can confirm a lower role for any current non-owner, including people
and agents.
**Viewing only** gives read-only access
to the chat. A verified agent can move from **Viewing only** to **Participating**,
and the chat owner can grant **Admin** to their own verified agents. The
verified roster shows loading or failure, never treating a failed read as an
empty audience.

Invitations use the same groups and controls as channels: **Your agents** first,
then **People**, **Other agents** and **Your other agents**, omitting empty groups.
Expand Down
30 changes: 21 additions & 9 deletions src-tauri/src/relay/channel_writes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,27 @@ fn archive(event: &EventTemplate) -> bool {
.all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase())
}
fn member_administration(event: &EventTemplate) -> bool {
matches!(event.kind, 9000 | 9001)
&& event.content.is_empty()
&& event.created_at <= 9_007_199_254_740_991
&& event.tags.len() == if event.kind == 9000 { 3 } else { 2 }
&& tag(event, 0, "h").is_some_and(uuid)
&& (ownership_transfer(event).is_some()
|| (tag(event, 1, "p").is_some_and(super::hex_key)
&& (event.kind == 9001
|| matches!(tag(event, 2, "role"), Some("admin" | "member" | "guest")))))
if !event.content.is_empty()
|| event.created_at > 9_007_199_254_740_991
|| !tag(event, 0, "h").is_some_and(uuid)
{
return false;
}
let target = tag(event, 1, "p").is_some_and(super::hex_key);
let role = matches!(tag(event, 2, "role"), Some("admin" | "member" | "guest"));
match (event.kind, event.tags.len()) {
(9000, 3) => ownership_transfer(event).is_some() || (target && role),
(9001, 2) => target,
(9050, 4) => {
target
&& role
&& matches!(
tag(event, 3, "expected_role"),
Some("admin" | "member" | "guest" | "bot")
)
}
_ => false,
}
}
/// The stepping-down owner of `[h, ["p", heir, "owner"], ["p", owner, "admin"]]`.
fn ownership_transfer(event: &EventTemplate) -> Option<&str> {
Expand Down
119 changes: 117 additions & 2 deletions src/bundled/channels/MemberAdministration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ async function setup(
messageNavigation = true,
initialReads?: { names?: Promise<void>; roster?: Promise<void> },
ownership?: "own" | "other" | "invalid",
visibility: "private" | "public" = "private",
visibility: "private" | "public" | "solo" | "view-only-solo" = "private",
targetPicture?: string,
targetProfiled = true,
) {
const solo = visibility === "solo" || visibility === "view-only-solo";
const visibilityFlag =
visibility === "solo"
? "private"
: visibility === "view-only-solo"
? "public"
: visibility;
const viewer = keypair(),
relay = keypair(),
target = keypair(),
Expand Down Expand Up @@ -116,7 +123,14 @@ async function setup(
kind: 39000,
created_at: tick,
content: "",
tags: [["d", id], ["t", "stream"], [visibility], ["name", "Design"]],
tags: [
["d", id],
["t", "stream"],
[visibilityFlag],
...(solo ? [["t", "buzz.solo"]] : []),
...(visibility === "view-only-solo" ? [["join_role", "guest"]] : []),
["name", "Design"],
],
}),
signed(relay, {
kind: 39001,
Expand Down Expand Up @@ -184,6 +198,7 @@ async function setup(
memberAdministration: {
sign: async (template) => signed(viewer, template),
publish,
...(solo ? { soloMemberRoleUpdates: true as const } : {}),
},
}
: {}),
Expand Down Expand Up @@ -773,6 +788,106 @@ it("keeps resolved rows and focus while refreshing, and reopens warm without a s
}
});

it.each([
["owner", true, true],
["owner", false, true],
["admin", true, false],
] as const)(
"Solo %s sees downgrade controls for a current Admin (agent=%s)",
async (actor, agent, allowed) => {
const t = await setup(
actor,
"admin",
true,
undefined,
agent,
undefined,
false,
true,
undefined,
undefined,
"solo",
);
await t.user.click(
screen.getByRole("button", { name: /^Actions for Morgan$/ }),
);
await screen.findByRole("menuitem", { name: "View profile" });
expect(screen.queryAllByRole("menuitemradio")).toHaveLength(
allowed ? 3 : 0,
);
expect(
screen.queryByRole("menuitem", { name: "Transfer ownership" }),
).not.toBeInTheDocument();
if (!allowed) return;
await t.user.click(
screen.getByRole("menuitemradio", { name: "Viewing only" }),
);
const dialog = await screen.findByRole("dialog", {
name: "Change access to Viewing only?",
});
expect(t.publish).not.toHaveBeenCalled();
await t.user.click(
within(dialog).getByRole("button", { name: "Set to viewing only" }),
);
await vi.waitFor(() =>
expect(
t.session.memberAdministration.snapshot(id).operation?.status,
).toBe("confirmed"),
);
expect(t.publish).toHaveBeenCalledOnce();
expect(t.publish.mock.calls[0]?.[0]).toMatchObject({
kind: 9050,
tags: expect.arrayContaining([["expected_role", "admin"]]),
});
},
);
it("offers only a downgrade for a Solo participant with an unattested agent profile", async () => {
const t = await setup(
"owner",
"member",
true,
undefined,
true,
undefined,
false,
true,
undefined,
undefined,
"solo",
);
await t.user.click(
screen.getByRole("button", { name: /^Actions for Morgan$/ }),
);
await screen.findByRole("menuitemradio", { name: "Viewing only" });
expect(
screen.getByRole("menuitemradio", { name: "Participating" }),
).toHaveAttribute("aria-checked", "true");
expect(
screen.queryByRole("menuitemradio", { name: "Admin" }),
).not.toBeInTheDocument();
});
it("keeps removal in a View only Solo chat without showing role choices", async () => {
const t = await setup(
"owner",
"admin",
true,
undefined,
false,
undefined,
false,
true,
undefined,
undefined,
"view-only-solo",
);
await t.user.click(
screen.getByRole("button", { name: "Actions for Morgan" }),
);
expect(
await screen.findByRole("menuitem", { name: "Remove from chat" }),
).toBeInTheDocument();
expect(screen.queryAllByRole("menuitemradio")).toHaveLength(0);
});
it("presents verified roles, protects owners/self, and confirms a separate deliberate role intent", async () => {
const t = await setup();
await expectProfileOnly(t.user, "Carl");
Expand Down
42 changes: 29 additions & 13 deletions src/bundled/channels/MemberAdministration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "react";
import type { RelaySession } from "../../features/relay/session";
import {
canManageMember,
canSetMemberRole,
canRemoveMember,
canTransferOwnership,
editableMemberRoles,
Expand Down Expand Up @@ -316,8 +316,21 @@ export function MemberRow({
const role = state.authority.roles[pubkey] ?? "unknown";
const permitted =
!invitationAction && capability.available && state.status === "ready";
const canEdit =
permitted && canManageMember(state.authority, session.viewer ?? "", pubkey);
const currentAccess = role === "bot" ? "member" : role;
const roleChanges = permitted
? editableMemberRoles.filter(
(next) =>
next !== currentAccess &&
canSetMemberRole(
state.authority,
session.viewer ?? "",
pubkey,
next,
verifiedOwner,
),
)
: [];
const canEdit = roleChanges.length > 0;
const canTransfer =
permitted &&
canTransferOwnership(state.authority, session.viewer ?? "", pubkey, agent);
Expand Down Expand Up @@ -371,23 +384,26 @@ export function MemberRow({
<MenuSeparator />
{canEdit && (
<MenuRadioGroup
value={role === "bot" ? "member" : role}
value={currentAccess}
onValueChange={(next) => {
const target = editableMemberRoles.find(
(value) => value === next,
);
if (target && target !== role) {
const target = roleChanges.find((value) => value === next);
if (target) {
// The shared popup outlives the choice; the confirmation takes over.
menus.close();
choose(target);
}
}}
>
{editableMemberRoles.map((next) => (
<MenuRadioItem key={next} value={next}>
{memberAccessLabel(next)}
</MenuRadioItem>
))}
{editableMemberRoles
.filter(
(next) =>
next === currentAccess || roleChanges.includes(next),
)
.map((next) => (
<MenuRadioItem key={next} value={next}>
{memberAccessLabel(next)}
</MenuRadioItem>
))}
</MenuRadioGroup>
)}
{canEdit && <MenuSeparator />}
Expand Down
Loading
Loading