From fa5dbbfd4fff0fc5d516ad6ed12956553a6acc31 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:02:15 +0200 Subject: [PATCH] fix: DMs vanishing after WebSocket reconnection populateFromReady() built the federatedId dedup set from ALL existing DMs, including those belonging to the reconnecting origin. Incoming DMs then matched their own stale entries and were skipped as "duplicates." The subsequent origin-removal step deleted the old copies, leaving no DMs from that origin in state. Scope the dedup set to DMs from OTHER origins only, so reconnecting origins replace their DMs cleanly while cross-instance dedup still works. --- packages/web/src/stores/spaceStore.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web/src/stores/spaceStore.ts b/packages/web/src/stores/spaceStore.ts index ac83623b..cafec7a1 100644 --- a/packages/web/src/stores/spaceStore.ts +++ b/packages/web/src/stores/spaceStore.ts @@ -656,11 +656,15 @@ export const useSpaceStore = create((set, get) => ({ } } - // Build a set of existing federatedIds for dedup + // Build a set of existing federatedIds for dedup (only from OTHER origins — + // DMs from the reconnecting origin will be replaced, not deduplicated) const existingFederatedIds = new Map(); // federatedId → dmChannelId for (const dm of get().dmChannels) { if (dm.federatedId) { - existingFederatedIds.set(dm.federatedId, dm.id); + const dmOrigin = get().channelOriginMap.get(dm.id); + if (dmOrigin !== origin) { + existingFederatedIds.set(dm.federatedId, dm.id); + } } }