Skip to content

fix(desktop): push new members and profile edits to pickers live - #65

Merged
QuicksilverSlick merged 1 commit into
mainfrom
fix/live-member-directory
Oct 22, 2026
Merged

QuicksilverSlick merged 1 commit into
mainfrom
fix/live-member-directory

Conversation

@QuicksilverSlick

Copy link
Copy Markdown
Owner

What happened

On 21 Oct a new identity claimed an invite on the hosted relay and published its kind:0 profile. The owner's running desktop did not show them in the DM recipient picker until the app was fully restarted.

Root cause

  • Nothing on desktop subscribed to kind:0.
  • The only live kind:13534 subscription (useCommunityJoinAlerts) runs for owners/admins only, and it writes only the members-panel cache.
  • So the caches every people picker reads never learned that fresh data had landed. These are user-search (DM picker, @mention, member pickers, top-bar people search), users-batch / user-profile (author labels) and the viewer's own membership.
  • user-search is fresh for 30 s and app-focus refetch is off. An open picker, or one reopened within 30 s, kept serving the old directory.
  • Upstream block/buzz has no fix for this.

Change

New desktop/src/features/profile/useLiveDirectoryUpdates.ts, mounted once in AppShell (per community). It opens one live {kinds:[0,13534], limit:0} subscription on the existing relay socket.

  • kind:0:
    • evicts that member's users-batch-entry;
    • refreshes user-search, plus that member's user-profile and users-batch;
    • trims infinite directory queries to page one first, so a scrolled picker refetches one page, not all of them;
    • batches into a 2 s window timed from the first event, which a burst cannot postpone. These refetches use HTTP POST /query (about 5/s, shared with every other read).
  • kind:13534:
    • writes the roster straight into relayMembers, using the same parser as listRelayMembers, so it costs no request;
    • fences on created_at;
    • refetches myRelayMembership / myRelayMembershipLookup only when the viewer's own role changed, so promotion or demotion applies without a reload.
  • Failed subscribe: a subscribe that fails at launch (offline, relay down) retries with backoff (1 s, doubling, capped at 30 s).
  • Reconnect gaps: existing useRelayAutoHeal handles these. It now also refreshes myRelayMembershipLookup, which was missing from RELAY_QUERY_ROOTS.

Testing

  • useLiveDirectoryUpdates.test.mjs (8 cases) drives the production function with a fake socket and a real QueryClient. I removed each guard in turn and a test failed every time: case normalisation, eviction, page trim, the fixed window, the roster fence, the own-role check, retry, and dispose.
  • New e2e tests/e2e/live-directory.spec.ts (added to smoke). The DM picker is open on "Quill" with no match, the mock relay live-publishes a kind:0, and the person must appear with no reload. It fails when the hook is not mounted. A new mock-bridge seam, __BUZZ_E2E_EMIT_MOCK_PROFILE__, drives it.
  • Local results:
    • pnpm test: 7,123 + 177 passing.
    • tsc --noEmit, biome and check:file-sizes are clean.
    • Smoke e2e: live-directory and mention-recipients (26 tests) pass. A wider batch also passed: channels, messaging, community-rail, agent-control-regressions, dm-history-live-regression and mock-subscription-readiness (216 passed).
  • Two smoke tests fail on this machine with and without this change (checked 3 times each on a build without the hook):
    • community-rail.spec.ts:815;
    • messaging.spec.ts:1771 (clipboard read permission).
  • Agent review ran. Its two blockers were fixed here: the swallowed subscribe failure, and the cost of each refresh.

Not exercised: the native app against the hosted relay with a second real identity joining. The Playwright run covers the web build against the mock relay socket.

Follow-ups (not in this PR)

  • A member renamed mid-session keeps the old name in cached channel-member rows until those lists reload. updateCachedChannelMemberDisplayName could take the name from the kind:0.
  • Auto-heal does not evict users-batch-entry, so a label edited during a socket gap can stay stale for up to 10 minutes. This is marked with a ponytail: comment.
  • A kind:0 the viewer publishes from another device does not refresh the desktop's own profile query.

🤖 Generated with Claude Code

A member who joined mid-session never appeared in the DM recipient picker
until the app restarted. Nothing on desktop subscribed to kind:0, and the
only kind:13534 live subscription ran for owners/admins and fed only the
members panel, so the user-search, users-batch, user-profile and
membership caches never learned that fresh data had landed.

useLiveDirectoryUpdates keeps one live {kinds:[0,13534]} subscription on
the app's relay socket:
- kind:0 evicts that member's users-batch entry and refreshes user-search
  (infinite queries trimmed to page one), user-profile and users-batch,
  once per 2s window that a burst cannot postpone;
- kind:13534 writes the roster straight into relayMembers (created_at
  fenced) and refetches the viewer's own membership only when their role
  changed;
- a failed subscribe retries with backoff instead of freezing the
  directory until restart.

Reconnect auto-heal now also refreshes myRelayMembershipLookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: QuicksilverSlick <russelledeming@gmail.com>
@QuicksilverSlick QuicksilverSlick added the lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train. label Oct 22, 2026
@QuicksilverSlick
QuicksilverSlick merged commit d213b4f into main Oct 22, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lane:ready Builder is done: green, agent-reviewed, exercised. The steward puts it in the next train.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant