buzz icon indicating copy to clipboard operation
buzz copied to clipboard

[Bug] Community name remains device-local instead of syncing from relay

Open TheAngryPit opened this issue 4 months ago • 3 comments

Problem

Buzz Desktop treats a community's human-readable name as device-local configuration rather than community state.

When the same owner identity connects to the same self-hosted community from a second Desktop installation, the second device does not receive the name chosen on the first device. It derives a new label from the relay hostname instead. For an observed private IPv4 relay whose first octet was 100, the derived name was 100.

Every installation must therefore rename the same community independently. The result is especially confusing because the relay already provides other per-community presentation state, including the workspace icon, and Buzz's architecture describes the relay as the source of truth.

The local label is not authorization state, and this behavior does not change owner/admin roles. The problem is that users cannot establish one canonical community name that follows the community across supported clients.

Evidence And Reproduction

Environment

  • Observed Desktop release: v0.4.25
  • Release commit: e8105d1446834f522c75d628bf1d9e77c9c077a4
  • Observed OS: macOS on two separate installations
  • Relay: self-hosted Buzz relay reached through a private IP WebSocket URL
  • Identity: the same imported Nostr owner identity on both installations
  • Current main rechecked at: 9cc9652c7dec9145b0bf0ce2c4b46c8191d215f8

Minimal reproduction

  1. Connect Desktop installation A to a self-hosted Buzz community.
  2. Rename the locally displayed community to TheHive.
  3. On Desktop installation B, import the same Nostr identity.
  4. Connect installation B to the same relay URL.
  5. Observe that channels, messages, profile, and membership load from the relay.
  6. Open the community editor on installation B.
  7. Observe that the community name was not received from the relay. For a relay addressed by a private IPv4 host beginning with 100, Desktop derives 100.
  8. Rename installation B to TheHive.
  9. Observe that the rename affects only installation B and does not establish canonical community state for future installations.

Current result

  • The same community can have unrelated names on different Desktop installations.
  • Each installation persists its own name in buzz-communities local storage.
  • deriveCommunityName() splits the relay hostname and uses its first segment, producing 100 for the example IP.
  • The relay's community record has stable id and host fields plus per-community icon, but no canonical name.
  • NIP-11 exposes a name field, but Buzz currently serves the static value Buzz Relay rather than the requesting community's name.
  • Desktop fetches and caches the relay-provided community icon but has no equivalent community-name read path.

Evidence classification

Observed

  • Two macOS Desktop installations using the same owner identity and relay displayed different locally configured community names.
  • The second installation loaded relay-backed channels and history but derived 100 as its community name.
  • Both installations required a manual rename.

Code-proven

  • desktop/src/features/communities/communityStorage.ts persists community records in local storage and derives an unnamed community from the first hostname segment.
  • crates/buzz-db/src/lib.rs::CommunityRecord models only the stable community id and host; the current community presentation column is icon.
  • crates/buzz-relay/src/nip11.rs::RelayInfo::build emits the static name Buzz Relay while accepting a host-scoped community icon.
  • desktop/src-tauri/src/commands/workspace.rs::fetch_workspace_icon reads only the NIP-11 icon.
  • The same behavior remains on current main at the SHA above.

Documented

  • NIP-11 defines a human-readable relay name.
  • PR #2549 explicitly describes Desktop community records as device-scoped and persisted in local storage.
  • Issue #2667 proposes syncing community ordering or falling back to local storage, but does not define or synchronize a canonical community name.

Not yet runtime-proven in this report

  • No raw relay database row or NIP-11 response from the observed private deployment is attached. The absence of a canonical name field and the static NIP-11 value are code-proven at the release and current-main commits.

Duplicate search

Open and closed issues and pull requests were searched for:

  • canonical community name
  • "community name" sync devices
  • NIP-11 name desktop
  • "device-scoped" community name
  • community name sync
  • rename community

No dedicated issue for canonical community-name synchronization was found as of 2026-07-25.

Expected Behavior

Buzz should have one owner/admin-controlled canonical name for each community.

  • The canonical name is relay-backed community state.
  • A fresh supported client displays that name after connecting.
  • Renaming the community through a supported owner/admin path becomes visible on other clients after refresh or reconnect.
  • The name is scoped to the host-derived community and cannot leak across communities in a multi-tenant deployment.
  • Unauthorized members cannot change it.
  • Community id, host, membership, channels, messages, icon, and other state are preserved during rename.
  • If local aliases remain supported, they are explicitly labeled as local and never silently replace or mutate the canonical name.
  • A relay with no canonical name has a documented compatibility fallback; an IP address is not presented as an intentional community name without explanation.

The exact wire representation is a design decision. The visible invariant is that users name the community once, not once per device.

Scope

  • Relay-backed, per-community canonical presentation metadata for the name.
  • Owner/admin authorization for setting or changing the canonical name.
  • A tenant-safe client read/discovery path.
  • Buzz Desktop onboarding, community storage, refresh, editing, and fallback behavior.
  • Migration and compatibility behavior for existing communities and existing Desktop local names.
  • Focused relay, Desktop, and two-installation validation.

Owner boundary: the block/buzz community-presentation contract across its relay and Desktop implementations.

Non-Goals

  • Making a community name globally unique.
  • Changing the community's stable id, hostname, relay URL, owner identity, or membership roles.
  • Synchronizing user-specific community ordering, colors, notification preferences, repository directories, API credentials, or local archives.
  • Public DNS, TLS, NIP-05, or hosted-community provisioning.
  • Broad community-settings redesign.
  • Reworking the already relay-backed workspace-icon contract.
  • Implementing cross-relay account synchronization.
  • Selecting a new event kind or database schema before the contract is accepted.

Acceptance Criteria

  • [ ] An owner or admin can set a canonical community name through a supported path.
  • [ ] A regular member cannot change the canonical name.
  • [ ] Two clean Desktop installations connected to the same community display the same canonical name without manually duplicating it.
  • [ ] A rename on installation A becomes visible on installation B after the documented refresh/reconnect boundary.
  • [ ] The relay read path returns only the name of the host-derived community.
  • [ ] Two communities served by shared infrastructure can use different names without leakage or cache-key collision.
  • [ ] A failed or unauthorized rename preserves the previous canonical name and all unrelated community state.
  • [ ] Retrying an accepted rename is safe and idempotent.
  • [ ] Existing communities without canonical names remain accessible and use a documented fallback.
  • [ ] Existing local Desktop names are migrated or reconciled without silently overwriting an intentional local alias.
  • [ ] Offline or temporarily unreachable clients may show cached presentation state but clearly reconcile with relay truth when connectivity returns.
  • [ ] Community icon, membership, channel, message, profile, and relay connection behavior remain compatible.

Validation Plan

  • Add focused unit tests for canonical name validation, authorization, persistence, and idempotent rename.
  • Add multi-community tests proving host-scoped reads and writes cannot cross tenant boundaries.
  • Add migration tests for communities created before the canonical-name contract.
  • Add Desktop tests for first connect, cached display, refresh/reconnect, rename, unauthorized failure, offline fallback, and any explicit local-alias behavior.
  • Add a supported-path integration test using two clean Desktop storage profiles against one relay.
  • Prove the exact relay response/state before and after rename and the operator-visible value on both clients.
  • Run the repository-required focused suites, relay integration tests, Desktop E2E tests, and just ci.
  • Record exact-head evidence and migration/recovery proof in the implementation PR. Auto-review belongs to that PR and is not pre-claimed by this issue.

Security And Compatibility

  • The canonical name must use existing owner/admin authority and must not create a second administration plane.
  • No private keys, API tokens, repository paths, private channel content, or unredacted deployment data are required.
  • If the name is published through unauthenticated NIP-11, it becomes intentionally public to anyone who can reach that community host. That exposure must be documented and accepted as part of the contract.
  • Multi-tenant host binding and cache scoping must prevent name enumeration or leakage across communities.
  • Existing community ids, hosts, memberships, events, icons, and Desktop connections must remain valid.
  • If persistence changes, the migration must have a safe fallback for existing rows and a tested rollback/recovery story.
  • No additional network exposure, relay publication target, or credential scope is required.

References

  • NIP-11 — Relay Information Document: https://github.com/nostr-protocol/nips/blob/master/11.md
  • Current Desktop community local storage and name derivation: https://github.com/block/buzz/blob/9cc9652c7dec9145b0bf0ce2c4b46c8191d215f8/desktop/src/features/communities/communityStorage.ts
  • Current relay community record: https://github.com/block/buzz/blob/9cc9652c7dec9145b0bf0ce2c4b46c8191d215f8/crates/buzz-db/src/lib.rs
  • Current NIP-11 builder: https://github.com/block/buzz/blob/9cc9652c7dec9145b0bf0ce2c4b46c8191d215f8/crates/buzz-relay/src/nip11.rs
  • Current Desktop NIP-11 icon reader: https://github.com/block/buzz/blob/9cc9652c7dec9145b0bf0ce2c4b46c8191d215f8/desktop/src-tauri/src/commands/workspace.rs
  • PR #2549 — local community ordering and device-scoped storage: https://github.com/block/buzz/pull/2549
  • Issue #2667 — adjacent community ordering/color synchronization proposal: https://github.com/block/buzz/issues/2667

TheAngryPit avatar Jul 25 '26 01:07 TheAngryPit

Confirming this from a second deployment, and flagging that it also affects Buzz Mobile, which the current Scope doesn't cover (it's framed as relay + Desktop only). Two findings at c0d7b52af8d5f3572790be697dd2c4bf3c6a3b8f.

1. Mobile derives the name the same way, and it is also device-local

Community.nameFromUrl() (mobile/lib/shared/community/community.dart:74-84) splits the relay host and returns the first label whenever the host has more than two:

final parts = host.split('.');
if (parts.length > 2) return parts.first;
return host;

It is applied at both pairing paths (mobile/lib/features/pairing/pairing_provider.dart:471 and :647) and on legacy migration (mobile/lib/shared/community/community_storage.dart:48).

Observed: our self-hosted relay is wss://buzz.joinrack.app, so the phone names the community buzz, while the same community is named RACK on Desktop where it was typed by hand at add time. A third member's Desktop shows a third name. renameCommunity in the mobile community switcher writes only to local secure storage, so the acceptance criterion "two clean installations display the same canonical name" fails on iOS and Android for the same underlying reason it fails across Desktops.

This is the ordinary-case analogue of the reported 100 example: three-label hostnames are far more common than private IPv4 relays, and the derived label is then the relay's own subdomain rather than anything resembling the community's name.

2. Mobile has no NIP-11 read path at all, so the already-canonical icon doesn't reach it either

Flagging this because it changes how the fix should be scoped, not to reopen the icon contract.

The icon half works end to end. Our relay serves a custom per-community icon in its NIP-11 document (set via kind:9033), and Desktop renders it: useCommunityIcons.ts -> fetch_workspace_icon -> CommunityRail.tsx. Mobile renders the first letter of the local name instead:

// mobile/lib/features/channels/channels_page/community.dart:293-312
final initial = trimmedName != null && trimmedName.isNotEmpty
    ? trimmedName.substring(0, 1).toUpperCase()
    : '?';
return CircleAvatar(/* ... */ child: Text(initial));

There is no NIP-11 read anywhere under mobile/lib: grepping for nostr+json, relay_info, nip-11, and workspace_icon returns nothing. Desktop's read path is a Tauri command (desktop/src-tauri/src/commands/workspace.rs::fetch_workspace_icon), which Flutter cannot reuse.

The practical effect is that mobile shows an initial derived from a wrong name, so both halves of community identity are wrong there rather than one.

Suggested scope addition

If the canonical name lands as a NIP-11 field alongside icon, mobile gains nothing from it until it has its own plain-HTTPS Accept: application/nostr+json fetch. Extending Scope and the acceptance criteria to "and Buzz Mobile" (or spinning a follow-up mobile issue off this one) would keep the client gap from being closed on Desktop only. Happy to take the mobile side if that split is preferred.

skyerus avatar Jul 25 '26 19:07 skyerus

Adding the mobile side of this, observed today on a self-hosted relay at buzz.<domain> (checkout 0020907):

  • Mobile derives the community label from the hostname's first segment (Community.nameFromUrl in mobile/lib/shared/community/community.dart), so every user of our community sees "buzz" as the community name.
  • Unlike Desktop, mobile has no way to rename it: CommunityProvider.renameCommunity() exists (mobile/lib/shared/community/community_provider.dart) but nothing in the UI calls it. So the Desktop workaround described above is not available on mobile at all.
  • Same root cause: no canonical name on the relay. The community record has host and icon but no name, and NIP-11 serves the static "Buzz Relay" (crates/buzz-relay/src/nip11.rs).

Suggested shape, in increasing order of effort:

  1. Make the NIP-11 name/description configurable (env, e.g. BUZZ_RELAY_NAME), and have both clients seed the local label from it when adding a community. Cheapest path to a consistent name across devices and users.
  2. Store a canonical name on the community record next to icon, editable by owner/admin, and have clients prefer it over the derived label.
  3. Wire renameCommunity() to a mobile UI so users at least have parity with Desktop in the meantime.

rizqcon avatar Sep 11 '26 23:09 rizqcon

Adding a multi-member angle, observed on a self-hosted relay today (2026-10-11) and rechecked on current main (30873ba).

The existing report covers one owner across several devices. The same gap also hits every other member: an admin renames the community on their Desktop, but a newly invited member's Desktop and paired phone both show the hostname's first label (host in our case). The only fix is to ask each member to rename it locally, and on mobile there is no UI for that (renameCommunity exists in community_provider.dart but nothing calls it; pairing sets the name via Community.nameFromUrl).

Meanwhile the relay already serves per-community presentation state: the workspace icon set via kind:9033 reaches every member through NIP-11 icon. NIP-11 name however is hardcoded to "Buzz Relay" in nip11.rs.

A minimal path that would cover both reports:

  1. Store a per-community display name next to the icon (same admin command/permission), and serve it as NIP-11 name.
  2. Clients use the NIP-11 name as the default when adding, pairing, or joining via invite, and follow server updates unless the user has set a local override.

Happy to help with a PR if the approach sounds right.

Eight8Kane avatar Oct 11 '26 08:10 Eight8Kane