Repository navigation
Conversation
… switch The relay client read its URL from the backend's process-global override and cached the first answer. A relay call landing after `disconnect()` but before `apply_workspace` installed the new override connected to the previous community's relay and survived as the current connection, so later publishes, relay admin events included, went to the old community. - `connect()` caches the looked-up URL only if the attempt is still current. - `useCommunityInit` pins the client to the applied community's relay; `bindRelayUrl` tears down any socket or attempt on another relay. - Relay admin events (add, remove, change role) take the selected community's relay and refuse to sign or publish when the connection is elsewhere. - The invite and add-member dialogs name the community they act on. Signed-off-by: ddfourtwo <35066307+ddfourtwo@users.noreply.github.com>
🔐 Codex Security Review
|
Review follow-up: pass the community check to publishEvent's isCurrent so a switch that lands while the event is being signed cancels the send, and cover the accepted path and test-state cleanup in relayMembers.test.mjs. Signed-off-by: ddfourtwo <35066307+ddfourtwo@users.noreply.github.com>
|
Our private fork carried this patch, and it has now synced past the part that landed upstream, so closing this as superseded. What is covered upstream: #9033 added What is still not upstream, and stays in our fork: Thanks for the review. |
Summary
Symptom. With a hosted community selected, Settings → Communities → Invites → "Invite to community" added the key to a different community, a self-hosted one the user had switched away from. The self-hosted relay recorded the kind:9030 add, and nothing reached the hosted relay. It happened three times in about ten minutes.
Cause. The relay invite chain never names a community.
publishRelayAdminEventsigns the admin event and publishes it on the app-widerelayClient. That client reads its URL from the backend's process-global relay override and caches the first answer. A switch runsrelayClient.disconnect()and then awaits more work beforeapply_workspaceinstalls the new override. If any relay call lands in that gap,connect()reads the old override, caches it, and keeps the socket. The attempt counter was bumped before the call, so nothing marks the socket stale. From then on, publishes go to the previous community, relay admin events included. The member list and role queries share that socket, so Settings can show the old community's roster under the new community's name.Fix.
connect()caches the URL it looked up only if the attempt is still current. A lookup that outlives a switch can no longer write back the old relay.applyCommunitysucceeds,useCommunityInitpins the client to that community's relay (relayClient.bindRelayUrl). The call tears down any socket or in-flight attempt on another relay. First mount and same-relay re-applies don't disconnect, so the existing no-disconnect guarantees inuseCommunityInit.test.mjsstill hold.relayClientSession.ts, the inline huddle-event and typing-indicator filters moved torelayChannelFilters.tsasbuildHuddleEventsFilterandbuildTypingIndicatorFilter. The filter values are unchanged.Not changed. Tauri commands that use the backend override directly (composer REST send, channel membership,
get_channels) are the separate scoping gap tracked in #7518. Upstream already skipsapplyCommunityfor a cancelled switch. A huddle window runs its ownuseCommunityInitand can re-apply the backend override, but it has its own relay client, so it can't move the main window's socket.Related issue
Related to #7518 and #7799, both the same class of community-switch race. This PR closes the relay-socket side for relay admin events. The unscoped
relayMembersQueryKeyroster cache from #7799 is not changed here.Testing
src/features/communities/communitySwitchRelaySocket.test.mjsdrives the realuseCommunityInitandrelayClientagainst a fake backend whose relay override changes only whenapply_workspacefinishes.main, the client ends the switch still targeting that relay with the socket live. Fails on main, passes here.connect()guard removed.relayMembers.test.mjs: add, remove and change-role all reject before anything is signed when the connection is to another relay or none. It fails with the guard removed.pnpm check,pnpm typecheck,pnpm check:file-sizes, andpnpm test(6832 + 160 pass).playwright --project=smokeforinvites-settings-screenshots.spec.tsandcommunity-rail.spec.ts: 32 passed. The invite-dialog text assertion was updated for the community name.