Wire onMembershipLeave to RoomMemberEvent.Membership in attach()/dispose().
When the local user leaves or is banned from a subscribed room, calls
unsubscribeFromRoom() which prunes timelines exceeding PRUNE_TIMELINE_THRESHOLD.
Previously, unsubscribeFromRoom() was dead code — nothing in the app called it.
Also add 5 unit tests covering: leave, ban, other-user leave, join (no-op),
and non-subscribed room (no-op).
Replace the adaptive 50/100/150 timeline limit system with a flat
ACTIVE_ROOM_TIMELINE_LIMIT=50, matching Element Web approach.
Stop calling unsubscribeFromRoom() on room navigation so subscriptions
accumulate across the session for instant room switching.
Element Web SlidingSyncManager.setRoomVisible() never removes subscriptions
at all -- no pruning whatsoever. Our PRUNE_TIMELINE_THRESHOLD=100 guard
is more conservative than their approach.
- Remove AdaptiveSignals type, readAdaptiveSignals(),
resolveAdaptiveRoomTimelineLimit(), applyRoomTimelineLimit()
- Remove adaptiveTimeline and configuredTimelineLimit class fields
- Remove adaptiveTimeline from SlidingSyncDiagnostics type and UI
- Stop unsubscribing on nav in useSlidingSyncActiveRoom
- Lower PRUNE_TIMELINE_THRESHOLD from 150 to 100
Two memory management issues fixed:
1. SlidingSyncManager.dispose() now calls this.slidingSync.stop() before
removing listeners. Without this the SDK's internal Promise loop keeps
polling the sliding sync proxy even after the client is disposed, leaking
network connections and preventing garbage collection.
2. pruneRoomTimeline() is called from unsubscribeFromRoom(). When a room
leaves the active subscription its EventTimeline chain can hold hundreds of
events in memory. Once the event count exceeds PRUNE_TIMELINE_THRESHOLD
(= ACTIVE_ROOM_TIMELINE_LIMIT_HIGH = 150) the live timeline is reset via
EventTimelineSet.resetLiveTimeline(). The full history remains on disk in
IndexedDBStore and is re-fetched via the active-room subscription on next
open, so there is no user-visible change.
Adds 5 unit tests: 1 for dispose, 4 for the pruning threshold boundary.
Inside the ThreadDrawer the user is already in thread context, so showing
the "Thread" badge in the reply chip is redundant and visually noisy.
The compose box always sets replyDraft.relation.rel_type = RelationType.Thread
when threadRootId is set (so the message goes to the right thread), but that
should not make the ThreadIndicator visible there.
Add !threadRootId guard to the ThreadIndicator render condition.
Adds 4 unit tests covering the four branches of the condition.
Covers the two bugs fixed in the previous commit:
- Verifies the first button gets data-selected="true" on initial render so the
CSS highlight rule fires immediately (regression for the dep-array fix).
- Verifies the first button is also stamped when async search results load new
buttons after the initial render (the original regression).
- Verifies keyboard navigation via the AUTOCOMPLETE_NAVIGATE_EVENT moves the
selected index and that it clamps at the list boundaries.
Also adds an eslint-disable comment in AutocompleteMenu.tsx explaining why
the no-dep-array useLayoutEffect is intentional (setSelectedIndex is a stable
React setter; the conditional call cannot cause an infinite loop).
The root message section had two sources of excess whitespace:
1. hideTrack={false} forced a visible scrollbar gutter on the Scroll
component even when the message fit within the 200px max-height and no
scrolling was needed. Changed to hideTrack (default true = hidden) so
the gutter only appears when actually scrollable.
2. padding: S400 0 S200 0 (16px top / 8px bottom) on the root message box
was adding significant dead space above the message content that
compounds with the Message component's own internal padding.
Reduced to S200 0 S100 0 (8px top / 4px bottom).
Extract the replyEvents IIFE into a module-level function so the fix-first-
then-check-length logic can be exercised in isolated unit tests without
mounting the full component.
Tests cover:
- Returns thread.events (minus root) when the Thread object has replies.
- Excludes reactions (RelationType.Annotation) from the results.
- Classic-sync regression: thread.events = [rootEvent] => falls back to the
live room timeline (the bug was that length-1 thread blocked the fallback).
- Falls back to live timeline when getThread() returns null.
- Filters out events belonging to a different thread.
- Returns [] when neither source has relevant events.
With classic sync, RoomViewHeader creates Thread objects via
room.createThread(id, rootEvent, [], false) — passing no initialEvents.
This means thread.events starts as just [rootEvent] (or empty).
Two bugs resulted:
1. The gate `if (fromThread.length > 0)` blocked the live-timeline fallback.
Since thread.events = [rootEvent], length was 1 (truthy), but after
filtering the root out the array was empty — yielding zero replies even
though the events were present in the main room timeline.
Fix: compute the filtered array first, then gate on its length so the
fallback is reached when the thread object has no actual replies yet.
2. Even after #1, subsequent renders and read-receipt logic used thread.events
(empty) rather than the live timeline.
Fix: add a mount-time useEffect that backfills matching events from the
unfiltered live timeline into the Thread object via thread.addEvents() so
the authoritative source is populated for future interactions.