diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 030accab..668b33f7 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -858,10 +858,33 @@ export function RoomTimeline({ useLiveTimelineRefresh( room, useCallback(() => { - if (liveTimelineLinked || timeline.linkedTimelines.length === 0) { - setTimeline(getInitialTimeline(room)); - } - }, [room, liveTimelineLinked, timeline.linkedTimelines.length]) + // Always reinitialize on TimelineRefresh. With sliding sync, a limited + // response replaces the room's live EventTimeline with a brand-new object, + // firing TimelineRefresh. At that moment liveTimelineLinked is stale-false + // (the stored linkedTimelines still reference the old detached object), + // so the previous guard `if (liveTimelineLinked || ...)` would silently + // skip reinit. Back-pagination then calls paginateEventTimeline against + // the dead old timeline, which no-ops, and the IntersectionObserver never + // re-fires because intersection state didn't change — causing a permanent + // hang at the top of the timeline with no spinner and no history loaded. + // Unconditionally reinitializing is correct: TimelineRefresh signals that + // the SDK has replaced the timeline chain, so any stored range/indices + // against the old chain are invalid anyway. + // + // Also force atBottom=true and queue a scroll-to-bottom. The SDK fires + // TimelineRefresh before adding new events to the fresh live timeline, so + // getInitialTimeline captures range.end=0. Once events arrive the + // rangeAtEnd self-heal useEffect needs atBottom=true to run; the + // IntersectionObserver may have transiently fired isIntersecting=false + // during the render transition, leaving atBottom=false and causing the + // "Jump to Latest" button to stick permanently. Forcing atBottom here is + // correct: TimelineRefresh always reinits to the live end, so the user + // should be repositioned to the bottom regardless. + setTimeline(getInitialTimeline(room)); + setAtBottom(true); + scrollToBottomRef.current.count += 1; + scrollToBottomRef.current.smooth = false; + }, [room, setAtBottom]) ); // Re-render when non-live Replace relations arrive (bundled/historical edits @@ -882,6 +905,21 @@ export function RoomTimeline({ setTimeline(getInitialTimeline(room)); }, [eventId, room, timeline.linkedTimelines.length]); + // Fix stale rangeAtEnd after a sliding sync TimelineRefresh. The SDK fires + // TimelineRefresh before adding new events to the freshly-created live + // EventTimeline, so getInitialTimeline captures range.end=0. New events then + // arrive via useLiveEventArrive, but its atLiveEndRef guard is stale-false + // (hasn't re-rendered yet), bypassing the range-advance path. The next render + // ends up with liveTimelineLinked=true but rangeAtEnd=false, making the + // "Jump to Latest" button appear while the user is already at the bottom. + // Re-running getInitialTimeline post-render (after events were added to the + // live EventTimeline object) snaps range.end to the correct event count. + useEffect(() => { + if (liveTimelineLinked && !rangeAtEnd && atBottom) { + setTimeline(getInitialTimeline(room)); + } + }, [liveTimelineLinked, rangeAtEnd, atBottom, room]); + // Stay at bottom when room editor resize useResizeObserver( useMemo(() => { @@ -2127,6 +2165,19 @@ export function RoomTimeline({ ); } else if (timelineItems.length === 0) { + // When eventsLength===0 AND liveTimelineLinked the live EventTimeline was + // just reset by a sliding sync TimelineRefresh and new events haven't + // arrived yet. Attaching the IntersectionObserver anchor here would + // immediately fire a server-side /messages request before current events + // land — potentially causing a "/messages hangs → spinner stuck" scenario. + // Suppressing the anchor for this transient state is safe: the rangeAtEnd + // self-heal useEffect will call getInitialTimeline once events arrive, and + // at that point the correct anchor (below) will be re-observed. + // eventsLength>0 covers the range={K,K} case from recalibratePagination + // where items=0 but events exist — that needs the anchor for local range + // extension (no server call since start>0). + const placeholderBackAnchor = + eventsLength > 0 || !liveTimelineLinked ? observeBackAnchor : undefined; backPaginationJSX = messageLayout === MessageLayout.Compact ? ( <> @@ -2142,7 +2193,7 @@ export function RoomTimeline({ - + @@ -2154,7 +2205,7 @@ export function RoomTimeline({ - + diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index 32dc21d0..729ab9ff 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -370,7 +370,7 @@ function MessageNotifications() { if (document.visibilityState !== 'visible') return; // Page is visible — show the themed in-app notification banner. - if (showNotifications && (isHighlightByRule || loudByRule || isDM)) { + if (showNotifications && (isHighlightByRule || isLoud)) { const avatarMxc = room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl(); const roomAvatar = avatarMxc diff --git a/src/client/slidingSync.ts b/src/client/slidingSync.ts index 5135dcaa..219ffecd 100644 --- a/src/client/slidingSync.ts +++ b/src/client/slidingSync.ts @@ -149,14 +149,30 @@ const resolveAdaptiveRoomTimelineLimit = ( // state events (one per child, keyed by child room ID) to build the space hierarchy. // Without these events the SDK has no parent→child mapping, so all rooms appear as // orphans in the Home view and spaces appear empty. +// - im.ponies.room_emotes with wildcard is required: custom emoji/sticker packs are +// stored as im.ponies.room_emotes state events (one per pack, keyed by pack state key). +// getGlobalImagePacks reads these from pack rooms listed in im.ponies.emote_rooms +// account data; imagePackRooms also reads them from parent spaces. Without these +// events all list-entry rooms would show no emoji or sticker packs. +// - m.room.topic is required: topics are displayed for joined child rooms in space +// lobby (RoomItem → LocalRoomSummaryLoader → useLocalRoomSummary) and in the +// invite list. Without this event the topic always shows as blank for non-active +// rooms. +// - m.room.canonical_alias is required: getCanonicalAlias() is used in several places +// for non-active rooms — notification serverName extraction, mention autocomplete +// alias display, and getCanonicalAliasOrRoomId for navigation. Without it, aliases +// fall back silently to room IDs. const buildListRequiredState = (): MSC3575RoomSubscription['required_state'] => [ [EventType.RoomJoinRules, ''], [EventType.RoomAvatar, ''], [EventType.RoomTombstone, ''], [EventType.RoomEncryption, ''], [EventType.RoomCreate, ''], + [EventType.RoomTopic, ''], + [EventType.RoomCanonicalAlias, ''], [EventType.RoomMember, MSC3575_STATE_KEY_ME], ['m.space.child', MSC3575_WILDCARD], + ['im.ponies.room_emotes', MSC3575_WILDCARD], ]; // For an active encrypted room: fetch everything so the client can decrypt all events. @@ -435,8 +451,11 @@ export class SlidingSyncManager { [EventType.RoomTombstone, ''], [EventType.RoomEncryption, ''], [EventType.RoomCreate, ''], + [EventType.RoomTopic, ''], + [EventType.RoomCanonicalAlias, ''], [EventType.RoomMember, MSC3575_STATE_KEY_ME], ['m.space.child', MSC3575_WILDCARD], + ['im.ponies.room_emotes', MSC3575_WILDCARD], ]; while (hasMore) {