diff --git a/.changeset/fix-thread-drawer-server-side-backfill.md b/.changeset/fix-thread-drawer-server-side-backfill.md new file mode 100644 index 00000000..7de45baf --- /dev/null +++ b/.changeset/fix-thread-drawer-server-side-backfill.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix thread drawer flooding console with "Ignoring event" warnings when server-side thread support is enabled. diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 53ab2f37..d7a1fe63 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -428,13 +428,25 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const rootEvent = room.findEventById(threadRootId); - // When the drawer is opened with classic sync, room.createThread() may have - // been called with empty initialEvents so thread.events only has the root. - // Backfill events from the main room timeline into the Thread object so the - // authoritative source is populated for subsequent renders and receipts. + // When the drawer is opened with classic sync (no server-side thread support), + // room.createThread() may have been called with empty initialEvents so + // thread.events only has the root. Backfill events from the main room + // timeline so the authoritative source is populated for subsequent renders. + // + // IMPORTANT: skip this backfill when server-side thread support is active + // (initialEventsFetched starts false). In that case the SDK will call + // updateThreadMetadata() → resetLiveTimeline() + paginateEventTimeline() + // automatically. Calling thread.addEvents() ourselves first would trigger + // that same cascade prematurely and cause a flood of + // "EventTimelineSet.addEventToTimeline: Ignoring event=…" warnings because + // canContain() fails while the timeline is in the middle of being reset and + // repopulated. useEffect(() => { const thread = room.getThread(threadRootId); if (!thread) return; + // initialEventsFetched === false ↔ Thread.hasServerSideSupport is set. + // The SDK handles initialization itself; our manual backfill must not run. + if (!thread.initialEventsFetched) return; const hasRepliesInThread = thread.events.some( (ev) => ev.getId() !== threadRootId && !reactionOrEditEvent(ev) );