buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Desktop: adding channel members blocks UI on full channel-list refetch

Open astromara opened this issue 3 months ago • 0 comments

Describe the bug Adding members to a channel is slow because the desktop blocks on a full channel-list refetch after each PUT_USER event.

Steps to reproduce

  1. Open a channel's Members sidebar
  2. Search for a user to add
  3. Click "Add" on a search result
  4. Observe the button stays disabled for several seconds before returning

Expected behavior The add-member operation should return quickly (the relay processes it in ~50ms). The channel list refetch should happen in the background without blocking the UI.

Version and platform

  • Buzz version: 0.5.14
  • OS: macOS 26.5.2 (Apple Silicon)

Logs / additional context The relay logs show the PUT_USER event completes in 50-91ms:

{"timestamp":"2026-08-16T18:48:06.711287Z","level":"INFO","message":"NIP-29 PUT_USER processed","channel":"3ed09850-0516-4125-b425-ee19502fd5d6",...}

Root cause: invalidateChannelState (hooks.ts:238-256) is called from useAddChannelMembersMutation.onSettled and awaited. This invalidates the entire channels query, triggering fetch_channels (channels.rs:159-389) which does:

  • Phase 1: fetch member-chain + open directory + hidden-DM snapshot
  • Phase 2: fetch member counts + last-message timestamps for all channels

The stall is proportional to channel count. Additionally, add_channel_members (channels.rs:901-913) loops over pubkeys sequentially rather than batching, so adding N members = N × (relay round-trip + full channel refetch).

Suggested fix:

  1. Optimistic update: patch the local cache immediately, then refetch in the background
  2. Batch the PUT_USER events into a single replaceable kind:39002 update
  3. Use a targeted refetch (just the affected channel's members) instead of the full list

astromara avatar Aug 16 '26 18:08 astromara