Desktop: adding channel members blocks UI on full channel-list refetch
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
**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
Contributor guide
Research direction
Start in hooks.ts:238-256 at invalidateChannelState and useAddChannelMembersMutation.onSettled, then trace channels.rs:159-389 and add_channel_members at 901-913. Reproduce the Members-sidebar flow and compare the add operation with the relay timing. Done means adding members returns promptly while channel data refreshes without blocking the UI, with batched updates or a targeted refetch as appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, typescript
- Domain
- backend, desktop, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100