Desktop: adding channel members blocks UI on full channel-list refetch
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
- Open a channel's Members sidebar
- Search for a user to add
- Click "Add" on a search result
- 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:
- Optimistic update: patch the local cache immediately, then refetch in the background
- Batch the PUT_USER events into a single replaceable kind:39002 update
- Use a targeted refetch (just the affected channel's members) instead of the full list