From b3e434dbc21cfb09a48a6ddad228f06060baccba Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Mon, 6 Apr 2026 12:51:03 -0400 Subject: [PATCH 01/26] feat(threads): thread drawer, thread browser, live reply counts, and unread badges --- src/app/features/room/RoomTimeline.tsx | 8 +- src/app/features/room/ThreadBrowser.tsx | 291 +++++- src/app/features/room/ThreadDrawer.css.ts | 2 + src/app/features/room/ThreadDrawer.tsx | 836 +++++++++--------- .../hooks/timeline/useProcessedTimeline.ts | 10 +- src/app/hooks/timeline/useTimelineActions.ts | 28 +- .../timeline/useTimelineEventRenderer.tsx | 88 +- src/app/hooks/useMessageEdit.ts | 49 + src/app/styles/overrides/General.css.ts | 4 +- src/client/initMatrix.ts | 2 + 10 files changed, 827 insertions(+), 491 deletions(-) create mode 100644 src/app/hooks/useMessageEdit.ts diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index e703d0206..3e5d162f6 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -32,6 +32,7 @@ import { MessageBase, CompactPlaceholder, DefaultPlaceholder } from '$components import { RoomIntro } from '$components/room-intro'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { useAlive } from '$hooks/useAlive'; +import { useMessageEdit } from '$hooks/useMessageEdit'; import { useDocumentFocusChange } from '$hooks/useDocumentFocusChange'; import { markAsRead } from '$utils/notifications'; import { @@ -124,6 +125,8 @@ export function RoomTimeline({ }: Readonly) { const mx = useMatrixClient(); const alive = useAlive(); + + const { editId, handleEdit } = useMessageEdit(editor, { onReset: onEditorReset, alive }); const { navigateRoom } = useRoomNavigate(); const [hideReads] = useSetting(settingsAtom, 'hideReads'); @@ -166,7 +169,6 @@ export function RoomTimeline({ return myPowerLevel < sendLevel; }, [powerLevels, mx]); - const [editId, setEditId] = useState(); const [unreadInfo, setUnreadInfo] = useState(() => getRoomUnreadInfo(room, true)); const readUptoEventIdRef = useRef(undefined); @@ -460,7 +462,6 @@ export function RoomTimeline({ room, mx, editor, - alive, nicknames, globalProfiles, spaceId: optionalSpace?.roomId, @@ -469,8 +470,7 @@ export function RoomTimeline({ setReplyDraft, openThreadId, setOpenThread, - setEditId, - onEditorReset, + handleEdit, handleOpenEvent: (id) => { const evtTimeline = getEventTimeline(room, id); const absoluteIndex = evtTimeline diff --git a/src/app/features/room/ThreadBrowser.tsx b/src/app/features/room/ThreadBrowser.tsx index 0d9240c38..4cf718a8e 100644 --- a/src/app/features/room/ThreadBrowser.tsx +++ b/src/app/features/room/ThreadBrowser.tsx @@ -15,12 +15,21 @@ import { Icons, Input, Scroll, + Spinner, Text, Avatar, config, Chip, } from 'folds'; -import { MatrixEvent, Room, Thread, ThreadEvent } from '$types/matrix-sdk'; +import { + EventTimelineSet, + MatrixEvent, + NotificationCountType, + Room, + RoomEvent, + Thread, + ThreadEvent, +} from '$types/matrix-sdk'; import { useAtomValue } from 'jotai'; import { HTMLReactParserOptions } from 'html-react-parser'; import { Opts as LinkifyOpts } from 'linkifyjs'; @@ -54,6 +63,7 @@ import { makeMentionCustomProps, renderMatrixMention, } from '$plugins/react-custom-html-parser'; +import { UnreadBadge, UnreadBadgeCenter } from '$components/unread-badge'; import { EncryptedContent } from './message'; import * as css from './ThreadDrawer.css'; @@ -61,9 +71,10 @@ type ThreadPreviewProps = { room: Room; thread: Thread; onClick: (threadId: string) => void; + onJump?: () => void; }; -function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) { +function ThreadPreview({ room, thread, onClick, onJump }: ThreadPreviewProps) { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); const { navigateRoom } = useRoomNavigate(); @@ -121,8 +132,25 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) { (evt) => { evt.stopPropagation(); navigateRoom(room.roomId, thread.id); + onJump?.(); }, - [navigateRoom, room.roomId, thread.id] + [navigateRoom, room.roomId, thread.id, onJump] + ); + + const [, forceUnread] = useState(0); + useEffect(() => { + const onUnread = (_count: unknown, threadId?: string) => { + if (!threadId || threadId === thread.id) forceUnread((n) => n + 1); + }; + room.on(RoomEvent.UnreadNotifications as any, onUnread); + return () => { + room.off(RoomEvent.UnreadNotifications as any, onUnread); + }; + }, [room, thread.id]); + const unreadTotal = room.getThreadUnreadNotificationCount(thread.id, NotificationCountType.Total); + const unreadHighlight = room.getThreadUnreadNotificationCount( + thread.id, + NotificationCountType.Highlight ); const { rootEvent } = thread; @@ -134,9 +162,19 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) { const senderAvatarMxc = getMemberAvatarMxc(room, senderId); const getContent = (() => rootEvent.getContent()) as GetContentCallback; - const replyCount = thread.events.filter( + // Prefer a locally-counted reply count (based on events already in the thread + // timeline) but fall back to thread.length which is the server-reported count + // from bundled m.thread aggregations. This means that for threads discovered + // via fetchRoomThreads() whose timeline hasn't been paginated yet we still + // show the correct count rather than zero. + const localReplyCount = thread.events.filter( (ev: MatrixEvent) => ev.getId() !== thread.id && !reactionOrEditEvent(ev) ).length; + // Use Math.max so we never show fewer replies than the server reports. + // thread.length is the server-reported count from bundled m.thread aggregations; + // it may slightly overcount reactions but is far more accurate than a partial + // local cache (e.g. 5 loaded vs 22 on server). + const replyCount = Math.max(localReplyCount, thread.length ?? 0); const lastReply = thread.events .filter((ev: MatrixEvent) => ev.getId() !== thread.id && !reactionOrEditEvent(ev)) @@ -189,7 +227,12 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) { dateFormatString={dateFormatString} /> - + + {unreadTotal > 0 && ( + + 0} count={unreadTotal} /> + + )} Jump @@ -204,13 +247,7 @@ function ThreadPreview({ room, thread, onClick }: ThreadPreviewProps) { onClick={handleJumpClick} /> )} - + {() => { if (rootEvent.isRedacted()) { @@ -268,22 +305,165 @@ type ThreadBrowserProps = { }; export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBrowserProps) { + const mx = useMatrixClient(); const [, forceUpdate] = useState(0); const [query, setQuery] = useState(''); + const [loadingMore, setLoadingMore] = useState(false); + const [canLoadMore, setCanLoadMore] = useState(false); const searchRef = useRef(null); + const threadListTimelineSetRef = useRef(null); + const loadingMoreRef = useRef(false); + const canLoadMoreRef = useRef(false); + canLoadMoreRef.current = canLoadMore; - // Re-render when threads change. + // On mount, set up thread event listeners, create the server-side thread + // timeline sets, then fetch page 1 via paginate. The two operations are + // sequenced in a single effect so that createThreadsTimelineSets() always + // resolves before fetchRoomThreads() runs — the SDK's fetchRoomThreadList + // has an early-return guard (`if (this.threadsTimelineSets.length === 0)`) + // that silently no-ops when the sets haven't been created yet, so running + // both in parallel (the old two-effect approach) caused fetchRoomThreads to + // always be a no-op and left threadsReady=true prematurely. useEffect(() => { const onUpdate = () => forceUpdate((n) => n + 1); room.on(ThreadEvent.New as any, onUpdate); room.on(ThreadEvent.Update as any, onUpdate); room.on(ThreadEvent.NewReply as any, onUpdate); + + let cancelled = false; + const loadThreads = async () => { + setLoadingMore(true); + try { + // Create the timeline sets first — required before fetchRoomThreads(). + const sets = await room.createThreadsTimelineSets(); + if (!sets || cancelled) return; + const [allThreadsSet] = sets; + threadListTimelineSetRef.current = allThreadsSet; + + // Now fetch page 1 from the /threads endpoint. threadsTimelineSets is + // populated so fetchRoomThreadList will not early-return. + await room.fetchRoomThreads().catch((err: unknown) => { + // eslint-disable-next-line no-console + console.warn('ThreadBrowser: fetchRoomThreads failed', err); + }); + + // Paginate to load the first page into the timeline set. + const hasMore = await mx.paginateEventTimeline(allThreadsSet.getLiveTimeline(), { + backwards: true, + }); + // Ensure Thread objects exist for server-returned thread roots not yet + // known locally (threads outside the current sliding-sync window). + // fetchRoomThreads() creates Thread objects internally but uses + // room.findEventById() to set rootEvent — if the root event isn't in + // the sliding-sync cache, rootEvent ends up undefined, and + // ThreadPreview returns null for those threads. Backfill here using + // the event we already have from the threads timeline set. + allThreadsSet + .getLiveTimeline() + .getEvents() + .filter((event) => !!event.getId()) + .forEach((event) => { + const id = event.getId()!; + const existingThread = room.getThread(id); + + const bundled = (event.getUnsigned() as any)?.['m.relations']?.['m.thread']; + const bundledCount: number | undefined = + typeof bundled?.count === 'number' ? bundled.count : undefined; + if (!existingThread) { + room.createThread(id, event, [], false); + } else { + if (!existingThread.rootEvent) { + existingThread.rootEvent = event; + existingThread.setEventMetadata(event); + } + // Seed/update replyCount from bundled aggregations. This is needed + // for threads that were created by sliding-sync BEFORE fetchRoomThreads + // ran: SS delivers root events without bundled aggregations, so + // room.createThread() sets replyCount=0 and the SDK's fast-path + // ("replyCount===0 → initialEventsFetched=true, no server fetch") fires. + // Later, fetchRoomThreads() brings events WITH bundled counts, but + // createThread() is idempotent and returns the stale thread unchanged. + // Backfilling replyCount here lets ThreadPreview show the right count + // and lets Case C in ThreadDrawer know there are replies to fetch. + + if (bundledCount !== undefined && (existingThread as any).replyCount === 0) { + (existingThread as any).replyCount = bundledCount; + } + } + }); + if (!cancelled) { + setCanLoadMore(hasMore); + forceUpdate((n) => n + 1); + } + } catch { + // Server doesn't support thread list API; fall back to locally known threads. + } finally { + if (!cancelled) setLoadingMore(false); + } + }; + loadThreads(); + return () => { + cancelled = true; room.off(ThreadEvent.New as any, onUpdate); room.off(ThreadEvent.Update as any, onUpdate); room.off(ThreadEvent.NewReply as any, onUpdate); }; - }, [room]); + }, [room, mx]); + + const handleLoadMore = useCallback(async () => { + const tls = threadListTimelineSetRef.current; + if (!tls || loadingMore) return; + setLoadingMore(true); + try { + const hasMore = await mx.paginateEventTimeline(tls.getLiveTimeline(), { backwards: true }); + tls + .getLiveTimeline() + .getEvents() + .filter((event) => !!event.getId()) + .forEach((event) => { + const id = event.getId()!; + const existingThread = room.getThread(id); + + const bundled = (event.getUnsigned() as any)?.['m.relations']?.['m.thread']; + const bundledCount: number | undefined = + typeof bundled?.count === 'number' ? bundled.count : undefined; + if (!existingThread) { + room.createThread(id, event, [], false); + } else { + if (!existingThread.rootEvent) { + existingThread.rootEvent = event; + existingThread.setEventMetadata(event); + } + + if (bundledCount !== undefined && (existingThread as any).replyCount === 0) { + (existingThread as any).replyCount = bundledCount; + } + } + }); + setCanLoadMore(hasMore); + forceUpdate((n) => n + 1); + } catch { + // ignore + } finally { + setLoadingMore(false); + loadingMoreRef.current = false; + } + }, [mx, room, loadingMore]); + + const handleLoadMoreRef = useRef(handleLoadMore); + handleLoadMoreRef.current = handleLoadMore; + + const handleThreadsScroll = useCallback( + (e: React.UIEvent) => { + const el = e.currentTarget; + const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight; + if (distanceFromBottom < 200 && canLoadMoreRef.current && !loadingMoreRef.current) { + handleLoadMoreRef.current(); + } + }, + [] + ); const allThreads = room.getThreads().sort((a: Thread, b: Thread) => { const aTs = a.events.at(-1)?.getTs() ?? a.rootEvent?.getTs() ?? 0; @@ -309,7 +489,7 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr direction="Column" shrink="No" > -
+
@@ -317,9 +497,6 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr - - # {room.name} - - {threads.length === 0 ? ( - - - - {lowerQuery ? 'No threads match your search.' : 'No threads yet.'} - - - ) : ( - - {threads.map((thread: Thread) => ( - - ))} - - )} + {(() => { + if (threads.length === 0 && loadingMore) + return ( + + + + ); + if (threads.length === 0) + return ( + + + + {lowerQuery ? 'No threads match your search.' : 'No threads yet.'} + + + ); + return ( + <> + + {threads.map((thread: Thread) => ( + + ))} + + {loadingMore && ( + + + + )} + + ); + })()} diff --git a/src/app/features/room/ThreadDrawer.css.ts b/src/app/features/room/ThreadDrawer.css.ts index 5cb755075..4b2d9c1a1 100644 --- a/src/app/features/room/ThreadDrawer.css.ts +++ b/src/app/features/room/ThreadDrawer.css.ts @@ -60,7 +60,9 @@ export const ThreadBrowserItem = style({ background: 'none', border: 'none', color: 'inherit', + overflow: 'hidden', ':hover': { backgroundColor: color.SurfaceVariant.Container, + transform: 'none', }, }); diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 8d056addc..94e3ab1ed 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -1,6 +1,8 @@ import { MouseEventHandler, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { Box, Header, Icon, IconButton, Icons, Scroll, Text, config } from 'folds'; +import { Box, Header, Icon, IconButton, Icons, Scroll, Spinner, Text, config } from 'folds'; import { + Direction, + IEvent, MatrixEvent, PushProcessor, ReceiptType, @@ -13,11 +15,6 @@ import { useAtomValue, useSetAtom } from 'jotai'; import { ReactEditor } from 'slate-react'; import { HTMLReactParserOptions } from 'html-react-parser'; import { Opts as LinkifyOpts } from 'linkifyjs'; -import { ImageContent, MSticker, RedactedContent, Reply } from '$components/message'; -import { RenderMessageContent } from '$components/RenderMessageContent'; -import { Image } from '$components/media'; -import { ImageViewer } from '$components/image-viewer'; -import { ClientSideHoverFreeze } from '$components/ClientSideHoverFreeze'; import { factoryRenderLinkifyWithMention, getReactCustomHtmlParser, @@ -25,26 +22,20 @@ import { makeMentionCustomProps, renderMatrixMention, } from '$plugins/react-custom-html-parser'; -import { - getEditedEvent, - getEventReactions, - getMemberDisplayName, - reactionOrEditEvent, -} from '$utils/room'; +import { getEditedEvent, getMemberDisplayName, reactionOrEditEvent } from '$utils/room'; import { getMxIdLocalPart, toggleReaction } from '$utils/matrix'; -import { minuteDifference } from '$utils/time'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useSettingsLinkBaseUrl } from '$features/settings/useSettingsLinkBaseUrl'; import { nicknamesAtom } from '$state/nicknames'; -import { MessageLayout, MessageSpacing, settingsAtom } from '$state/settings'; +import { settingsAtom } from '$state/settings'; import { useSetting } from '$state/hooks/settings'; import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations'; import { buildAbbrReplaceTextNode } from '$components/message/RenderBody'; import { createMentionElement, moveCursor, useEditor } from '$components/editor'; import { useMentionClickHandler } from '$hooks/useMentionClickHandler'; import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler'; -import { GetContentCallback, MessageEvent, StateEvent } from '$types/matrix/room'; +import { MessageEvent, StateEvent } from '$types/matrix/room'; import { usePowerLevelsContext } from '$hooks/usePowerLevels'; import { useRoomPermissions } from '$hooks/useRoomPermissions'; import { useRoomCreators } from '$hooks/useRoomCreators'; @@ -52,7 +43,12 @@ import { useImagePackRooms } from '$hooks/useImagePackRooms'; import { useOpenUserRoomProfile } from '$state/hooks/userRoomProfile'; import { IReplyDraft, roomIdToReplyDraftAtomFamily } from '$state/room/roomInputDrafts'; import { roomToParentsAtom } from '$state/room/roomToParents'; -import { EncryptedContent, Message, Reactions } from './message'; +import { useIgnoredUsers } from '$hooks/useIgnoredUsers'; +import { useGetMemberPowerTag } from '$hooks/useMemberPowerTag'; +import { useMemberEventParser } from '$hooks/useMemberEventParser'; +import { useMessageEdit } from '$hooks/useMessageEdit'; +import { useProcessedTimeline, ProcessedEvent } from '$hooks/timeline/useProcessedTimeline'; +import { useTimelineEventRenderer } from '$hooks/timeline/useTimelineEventRenderer'; import { RoomInput } from './RoomInput'; import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing'; import * as css from './ThreadDrawer.css'; @@ -87,268 +83,6 @@ export function getThreadReplyEvents(room: Room, threadRootId: string): MatrixEv ); } -type ForwardedMessageProps = { - isForwarded: boolean; - originalTimestamp: number; - originalRoomId: string; - originalEventId: string; - originalEventPrivate: boolean; -}; - -type ThreadMessageProps = { - room: Room; - mEvent: MatrixEvent; - threadRootId: string; - editId: string | undefined; - onEditId: (id?: string) => void; - messageLayout: MessageLayout; - messageSpacing: MessageSpacing; - canDelete: boolean; - canSendReaction: boolean; - canPinEvent: boolean; - imagePackRooms: Room[]; - activeReplyId: string | undefined; - hour24Clock: boolean; - dateFormatString: string; - onUserClick: MouseEventHandler; - onUsernameClick: MouseEventHandler; - onReplyClick: MouseEventHandler; - onReactionToggle: (targetEventId: string, key: string, shortcode?: string) => void; - onResend?: (event: MatrixEvent) => void; - onDeleteFailedSend?: (event: MatrixEvent) => void; - pushProcessor: PushProcessor; - linkifyOpts: LinkifyOpts; - htmlReactParserOptions: HTMLReactParserOptions; - showHideReads: boolean; - showDeveloperTools: boolean; - onReferenceClick: MouseEventHandler; - jumpToEventId?: string; - collapse?: boolean; -}; - -function ThreadMessage({ - room, - threadRootId: threadRootIdProp, - mEvent, - editId, - onEditId, - messageLayout, - messageSpacing, - canDelete, - canSendReaction, - collapse = false, - canPinEvent, - imagePackRooms, - activeReplyId, - hour24Clock, - dateFormatString, - onUserClick, - onUsernameClick, - onReplyClick, - onReactionToggle, - onResend, - onDeleteFailedSend, - pushProcessor, - linkifyOpts, - htmlReactParserOptions, - showHideReads, - showDeveloperTools, - onReferenceClick, - jumpToEventId, -}: ThreadMessageProps) { - // Use the thread's own timeline set so reactions/edits on thread events are found correctly - const threadTimelineSet = room.getThread(threadRootIdProp)?.timelineSet; - const timelineSet = threadTimelineSet ?? room.getUnfilteredTimelineSet(); - const mEventId = mEvent.getId()!; - const senderId = mEvent.getSender() ?? ''; - const nicknames = useAtomValue(nicknamesAtom); - const senderDisplayName = - getMemberDisplayName(room, senderId, nicknames) ?? getMxIdLocalPart(senderId) ?? senderId; - - const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad'); - const [urlPreview] = useSetting(settingsAtom, 'urlPreview'); - const [encUrlPreview] = useSetting(settingsAtom, 'encUrlPreview'); - const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview; - const [autoplayStickers] = useSetting(settingsAtom, 'autoplayStickers'); - - const editedEvent = getEditedEvent(mEventId, mEvent, timelineSet); - const editedNewContent = editedEvent?.getContent()['m.new_content']; - const baseContent = mEvent.getContent(); - const safeContent = - Object.keys(baseContent).length > 0 ? baseContent : mEvent.getOriginalContent(); - const getContent = (() => editedNewContent ?? safeContent) as GetContentCallback; - - const reactionRelations = getEventReactions(timelineSet, mEventId); - const reactions = reactionRelations?.getSortedAnnotationsByKey(); - const hasReactions = reactions && reactions.length > 0; - - const pushActions = pushProcessor.actionsForEvent(mEvent); - let notifyHighlight: 'silent' | 'loud' | undefined; - if (pushActions?.notify && pushActions.tweaks?.highlight) { - notifyHighlight = pushActions.tweaks?.sound ? 'loud' : 'silent'; - } - - // Extract message forwarding info - const forwardContent = safeContent['moe.sable.message.forward'] as - | { - original_timestamp?: unknown; - original_room_id?: string; - original_event_id?: string; - original_event_private?: boolean; - } - | undefined; - - const messageForwardedProps: ForwardedMessageProps | undefined = forwardContent - ? { - isForwarded: true, - originalTimestamp: - typeof forwardContent.original_timestamp === 'number' - ? forwardContent.original_timestamp - : mEvent.getTs(), - originalRoomId: forwardContent.original_room_id ?? room.roomId, - originalEventId: forwardContent.original_event_id ?? '', - originalEventPrivate: forwardContent.original_event_private ?? false, - } - : undefined; - - const { replyEventId } = mEvent; - - const relation = mEvent.getRelation(); - const contentRelatesTo = mEvent.getContent()?.['m.relates_to']; - const isFallback = - relation?.is_falling_back === true || contentRelatesTo?.is_falling_back === true; - - return ( - - ) - } - reactions={ - hasReactions ? ( - - ) : undefined - } - > - {mEvent.isRedacted() ? ( - - ) : ( - - {() => { - if (mEvent.isRedacted()) - return ( - - ); - - if (mEvent.getType() === MessageEvent.Sticker) - return ( - ( - { - if (!autoplayStickers && p.src) { - return ( - - - - ); - } - return ; - }} - renderViewer={(p) => } - /> - )} - /> - ); - - if (mEvent.getType() === MessageEvent.RoomMessage) { - return ( - - ); - } - - return ( - - ); - }} - - )} - - ); -} - type ThreadDrawerProps = { room: Room; threadRootId: string; @@ -360,12 +94,25 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const mx = useMatrixClient(); const drawerRef = useRef(null); const editor = useEditor(); - const [, forceUpdate] = useState(0); - const [editId, setEditId] = useState(undefined); + const [forceUpdateCounter, forceUpdate] = useState(0); const [jumpToEventId, setJumpToEventId] = useState(undefined); + const [loadingOlderReplies, setLoadingOlderReplies] = useState(false); + const [canPageBack, setCanPageBack] = useState(true); + // Ref guard so the auto-paginate effect never starts a second concurrent request. + const paginatingOlderRef = useRef(false); const scrollRef = useRef(null); const prevReplyCountRef = useRef(0); - const replyEventsRef = useRef([]); + const processedEventsRef = useRef([]); + // Track whether we've already attempted a server fetch for a given threadRootId. + // Prevents infinite re-fetch loops on genuinely empty threads while still + // allowing the first fetch even when thread.length === 0 (sliding sync case + // where bundled aggregations are absent so replyCount defaults to 0). + const serverFetchAttemptedRef = useRef(null); + // True while the viewport auto-fill is actively paginating backwards. + // Used so the auto-scroll effect keeps the user anchored to the bottom + // (showing latest replies) while older content is prepended at the top. + const autoFillInProgressRef = useRef(false); + const { editId, handleEdit } = useMessageEdit(editor); const nicknames = useAtomValue(nicknamesAtom); const pushProcessor = useMemo(() => new PushProcessor(mx), [mx]); const useAuthentication = useMediaAuthentication(); @@ -380,6 +127,20 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString'); const [hideReads] = useSetting(settingsAtom, 'hideReads'); const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools'); + const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad'); + const [urlPreview] = useSetting(settingsAtom, 'urlPreview'); + const [encUrlPreview] = useSetting(settingsAtom, 'encUrlPreview'); + const [clientUrlPreview] = useSetting(settingsAtom, 'clientUrlPreview'); + const [encClientUrlPreview] = useSetting(settingsAtom, 'encClientUrlPreview'); + const [autoplayStickers] = useSetting(settingsAtom, 'autoplayStickers'); + const [autoplayEmojis] = useSetting(settingsAtom, 'autoplayEmojis'); + const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); + const [showTombstoneEvents] = useSetting(settingsAtom, 'showTombstoneEvents'); + const [hideMemberInReadOnly] = useSetting(settingsAtom, 'hideMembershipInReadOnly'); + const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview; + const showClientUrlPreview = room.hasEncryptionStateEvent() + ? clientUrlPreview && encClientUrlPreview + : clientUrlPreview; // Memoized parsing options const linkifyOpts = useMemo( @@ -412,6 +173,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra handleSpoilerClick: spoilerClickHandler, handleMentionClick: mentionClickHandler, nicknames, + autoplayEmojis, replaceTextNode: buildAbbrReplaceTextNode(abbrMap, linkifyOpts), }), [ @@ -423,6 +185,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra useAuthentication, nicknames, settingsLinkBaseUrl, + autoplayEmojis, abbrMap, ] ); @@ -435,6 +198,17 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const canDeleteOwn = permissions.event(MessageEvent.RoomRedaction, mx.getSafeUserId()); const canSendReaction = permissions.event(MessageEvent.Reaction, mx.getSafeUserId()); const canPinEvent = permissions.stateEvent(StateEvent.RoomPinnedEvents, mx.getSafeUserId()); + const isReadOnly = useMemo(() => { + const myPowerLevel = powerLevels?.users?.[mx.getUserId()!] ?? powerLevels?.users_default ?? 0; + const sendLevel = powerLevels?.events?.['m.room.message'] ?? powerLevels?.events_default ?? 0; + return myPowerLevel < sendLevel; + }, [powerLevels, mx]); + const getMemberPowerTag = useGetMemberPowerTag(room, creators, powerLevels); + const parseMemberEvent = useMemberEventParser(); + + // Ignored users + const ignoredUsersList = useIgnoredUsers(); + const ignoredUsersSet = useMemo(() => new Set(ignoredUsersList), [ignoredUsersList]); // Image packs const roomToParents = useAtomValue(roomToParentsAtom); @@ -448,31 +222,116 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra // User profile popup const openUserRoomProfile = useOpenUserRoomProfile(); - const rootEvent = room.findEventById(threadRootId); + // Thread timeline data for useProcessedTimeline + const thread = room.getThread(threadRootId); + const threadTimeline = thread?.timelineSet.getLiveTimeline(); - // 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. + // Prefer the event from the main timeline (already indexed), but fall back + // to thread.rootEvent — populated from bundled /threads server data even when + // the root is outside the currently-loaded timeline window. + const rootEvent = room.findEventById(threadRootId) ?? thread?.rootEvent; + const totalEvents = threadTimeline?.getEvents().length ?? 0; + const linkedTimelines = useMemo( + () => (threadTimeline ? [threadTimeline] : []), + // eslint-disable-next-line react-hooks/exhaustive-deps + [threadTimeline, totalEvents] + ); + const items = useMemo(() => Array.from({ length: totalEvents }, (_, i) => i), [totalEvents]); + + const processedEvents = useProcessedTimeline({ + items, + linkedTimelines, + skipThreadFilter: true, + ignoredUsersSet, + showHiddenEvents, + showTombstoneEvents, + mxUserId: mx.getUserId(), + readUptoEventId: undefined, + hideMembershipEvents: true, + hideNickAvatarEvents: true, + isReadOnly, + hideMemberInReadOnly, + }); + + // When the thread's own timeline is empty (server-side threads not yet fetched, + // or classic sync before backfill completes), fall back to scanning the main + // room timeline directly so replies are shown immediately. + const displayReplies = useMemo((): ProcessedEvent[] => { + const filtered = processedEvents.filter((e) => e.id !== threadRootId); + if (filtered.length > 0) return filtered; + const timelineSet = thread?.timelineSet ?? room.getUnfilteredTimelineSet(); + return getThreadReplyEvents(room, threadRootId).map((ev, idx) => ({ + id: ev.getId()!, + itemIndex: idx, + mEvent: ev, + timelineSet, + eventSender: ev.getSender() ?? null, + collapsed: false, + willRenderNewDivider: false, + willRenderDayDivider: false, + })); + // forceUpdateCounter makes this recompute whenever events arrive + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [room, threadRootId, thread, processedEvents, forceUpdateCounter]); + + processedEventsRef.current = displayReplies; + + const processedReplies = displayReplies; + + // Ensure the Thread object exists and has its reply events loaded. // - // 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. + // Case A — no Thread object yet (e.g. root event was loaded via jump/backward + // pagination but the SDK hasn't created a Thread shell for it): + // Call room.createThread() so the SDK constructor kicks off + // updateThreadMetadata() → resetLiveTimeline() + paginateEventTimeline() + // automatically. ThreadEvent.Update fires when done → forceUpdate → re-render. + // DO NOT call resetLiveTimeline() or paginateEventTimeline() ourselves — + // that would race with the SDK's own initialization and cause a flood of + // "Ignoring event … does not belong in timeline" warnings. + // + // If the root is also outside the local timeline (e.g. a thread discovered + // via ThreadBrowser but whose root predates the sliding-sync window), we + // fetch it bare with fetchRoomEvent — this does NOT add it to the main + // room timeline or cause any TimelineRefresh side-effects. + // + // Case B — Thread exists but initialEventsFetched is false (server-side thread + // support active; SDK's updateThreadMetadata() is running): + // Do nothing — the SDK will fire ThreadEvent.Update when done. + // + // Case C — Thread exists, initialEventsFetched is true (classic sync or SDK + // has already finished initialising): + // With classic sync the SDK never paginates thread timelines, so we backfill + // from the main live timeline. With server-side threads the SDK already + // populated thread.events; this block is a no-op in that case. 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( + // Case A: create thread shell; SDK handles the rest asynchronously. + if (!room.getThread(threadRootId)) { + const localRoot = room.findEventById(threadRootId); + if (localRoot) { + room.createThread(threadRootId, localRoot, [], false); + } else { + // Root not in local timeline — fetch it from the server without + // touching the main timeline (no TimelineRefresh side-effect). + mx.fetchRoomEvent(room.roomId, threadRootId) + .then((rawEvt) => { + if (room.getThread(threadRootId)) return; // created concurrently + room.createThread(threadRootId, new MatrixEvent(rawEvt as IEvent), [], false); + }) + .catch(() => {}); + } + } + + const currThread = room.getThread(threadRootId); + // Case B: SDK is actively initialising — don't interfere. + if (!currThread || !currThread.initialEventsFetched) return; + + // Case C: SDK is done (or classic sync). Backfill from live timeline if + // thread.events is still empty (classic sync path; server-side was already + // populated by paginateEventTimeline inside updateThreadMetadata). + const hasRepliesInThread = currThread.events.some( (ev) => ev.getId() !== threadRootId && !reactionOrEditEvent(ev) ); - if (hasRepliesInThread) return; // already populated, nothing to do + if (hasRepliesInThread) return; const liveEvents = room .getUnfilteredTimelineSet() @@ -485,9 +344,44 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra !reactionOrEditEvent(ev) ); if (liveEvents.length > 0) { - thread.addEvents(liveEvents, false); + // thread.addEvents() is typed as void but is internally async; schedule + // forceUpdate in a microtask so the timeline has been updated first. + currThread.addEvents(liveEvents, false); + Promise.resolve().then(() => forceUpdate((n) => n + 1)); + return; } - }, [room, threadRootId]); + + // No local events anywhere. We always attempt one server fetch here because + // with sliding sync the server omits bundled aggregations from subscription + // timeline events, leaving thread.replyCount at 0 even when the server has + // replies (the old `if (!currThread.length) return` guard incorrectly bailed + // out in that case). We use serverFetchAttemptedRef to ensure we only try + // once per threadRootId — if the paginate truly returns nothing, the ref + // prevents an infinite re-fetch loop. + if (serverFetchAttemptedRef.current === threadRootId) return; + serverFetchAttemptedRef.current = threadRootId; + + // Do NOT call resetLiveTimeline() here. Resetting a thread timeline emits + // RoomEvent.TimelineReset on the thread's EventTimelineSet; Thread's own + // onTimelineReset handler then awaits processRootEventPromise (a live + // fetchRootEvent network call). If that promise is still pending this + // creates a deadlock that hangs and eventually crashes the app — observed + // on both classic sync and sliding sync. + // + // Calling paginateEventTimeline directly is safe: the thread's back-token + // is null (set by the fast path when replyCount was 0 at construction), but + // the SDK maps null → undefined for the `from` parameter and calls + // fetchRelations without a cursor, which correctly fetches the latest + // replies from the server. + mx.paginateEventTimeline(currThread.timelineSet.getLiveTimeline(), { backwards: true }) + .then(() => forceUpdate((n) => n + 1)) + .catch(() => {}); + // forceUpdateCounter must be in deps so this effect re-runs after + // ThreadEvent.Update fires (which flips initialEventsFetched from false to + // true). Without it the effect runs once on mount, hits Case B + // (initialEventsFetched=false) and never runs again — leaving the drawer + // empty on sliding sync where replyCount starts at 0. + }, [mx, room, threadRootId, forceUpdate, forceUpdateCounter]); // Re-render when new thread events arrive (including reactions via ThreadEvent.Update). useEffect(() => { @@ -542,10 +436,10 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra // Mark thread as read when viewing it useEffect(() => { const markThreadAsRead = async () => { - const thread = room.getThread(threadRootId); - if (!thread) return; + const currentThread = room.getThread(threadRootId); + if (!currentThread) return; - const events = thread.events || []; + const events = currentThread.events || []; if (events.length === 0) return; const lastEvent = events[events.length - 1]; @@ -554,7 +448,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const userId = mx.getUserId(); if (!userId) return; - const readUpToId = thread.getEventReadUpTo(userId, false); + const readUpToId = currentThread.getEventReadUpTo(userId, false); const lastEventId = lastEvent.getId(); // Only send receipt if we haven't already read up to the last event @@ -570,22 +464,90 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra // Mark as read when opened and when new messages arrive markThreadAsRead(); - }, [mx, room, threadRootId, forceUpdate]); + }, [mx, room, threadRootId, forceUpdateCounter]); const replyEvents = getThreadReplyEvents(room, threadRootId); + const isThreadLoading = !!thread && !thread.initialEventsFetched && replyEvents.length === 0; - replyEventsRef.current = replyEvents; + const hasOlderReplies = + canPageBack && + !!thread?.initialEventsFetched && + thread?.timelineSet.getLiveTimeline().getPaginationToken(Direction.Backward) != null; - // Auto-scroll to bottom when event count grows (if the user is near the bottom). + // Keep a ref so the scroll handler always reads the latest value without deps. + const hasOlderRepliesRef = useRef(hasOlderReplies); + hasOlderRepliesRef.current = hasOlderReplies; + + const loadOlderReplies = useCallback(() => { + const t = room.getThread(threadRootId); + if (!t || !t.initialEventsFetched || paginatingOlderRef.current) return; + paginatingOlderRef.current = true; + setLoadingOlderReplies(true); + mx.paginateEventTimeline(t.timelineSet.getLiveTimeline(), { backwards: true }) + .then((hasMore) => { + paginatingOlderRef.current = false; + if (!hasMore) setCanPageBack(false); + setLoadingOlderReplies(false); + forceUpdate((n) => n + 1); + }) + .catch(() => { + paginatingOlderRef.current = false; + setLoadingOlderReplies(false); + }); + }, [mx, room, threadRootId, forceUpdate]); + + const loadOlderRepliesRef = useRef(loadOlderReplies); + loadOlderRepliesRef.current = loadOlderReplies; + + useEffect(() => { + setCanPageBack(true); + autoFillInProgressRef.current = false; + }, [threadRootId]); + + const handleRepliesScroll = useCallback(() => { + const el = scrollRef.current; + if (!el) return; + if (el.scrollTop < 200 && hasOlderRepliesRef.current && !paginatingOlderRef.current) { + loadOlderRepliesRef.current(); + } + }, []); + + // Auto-scroll to bottom when event count grows. + // During viewport auto-fill (autoFillInProgressRef) we ALWAYS scroll to the + // bottom: older messages are prepended at the top, so scrollTop stays at 0 + // (clamped), and when content first overflows the isAtBottom check would be + // false — leaving the user staring at the oldest messages instead of the + // latest ones. useEffect(() => { const el = scrollRef.current; if (!el) return; const isAtBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 150; - if (prevReplyCountRef.current === 0 || isAtBottom) { + if (prevReplyCountRef.current === 0 || isAtBottom || autoFillInProgressRef.current) { el.scrollTop = el.scrollHeight; } - prevReplyCountRef.current = replyEvents.length; - }, [replyEvents.length]); + prevReplyCountRef.current = processedReplies.length; + }, [processedReplies.length]); + + // Auto-fill viewport: paginate backwards until content overflows the scroll + // container, then stop. The scroll handler (handleRepliesScroll) loads more + // when the user scrolls back up past the top threshold. + useEffect(() => { + if (paginatingOlderRef.current) return; + const el = scrollRef.current; + if (!el) return; + if (!hasOlderReplies) { + autoFillInProgressRef.current = false; + return; + } + if (el.scrollHeight <= el.clientHeight) { + // Content doesn't yet fill the viewport — paginate one more page. + autoFillInProgressRef.current = true; + loadOlderRepliesRef.current(); + } else { + // Content now overflows — fill is complete. + autoFillInProgressRef.current = false; + } + }, [processedReplies.length, hasOlderReplies]); const handleUserClick: MouseEventHandler = useCallback( (evt) => { @@ -677,16 +639,29 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra [mx, room, threadRootId] ); - const handleEdit = useCallback( - (evtId?: string) => { - setEditId(evtId); - if (!evtId) { - ReactEditor.focus(editor); - moveCursor(editor); + const handleEditLastMessage = useCallback(() => { + const userId = mx.getUserId(); + const ownReply = [...processedEventsRef.current] + .reverse() + .find( + (e) => + e.id !== threadRootId && + e.mEvent.getSender() === userId && + !e.mEvent.isRedacted() && + !reactionOrEditEvent(e.mEvent) + ); + const ownId = ownReply?.id; + if (ownId) { + handleEdit(ownId); + const el = drawerRef.current; + if (el) { + el.querySelector(`[data-message-id="${ownId}"]`)?.scrollIntoView({ + block: 'nearest', + behavior: 'smooth', + }); } - }, - [editor] - ); + } + }, [mx, threadRootId, handleEdit]); const handleResend = useCallback( (event: MatrixEvent) => { @@ -707,7 +682,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const targetId = evt.currentTarget.getAttribute('data-event-id'); if (!targetId) return; const isRoot = targetId === threadRootId; - const isInReplies = replyEventsRef.current.some((e) => e.getId() === targetId); + const isInReplies = processedEventsRef.current.some((e) => e.id === targetId); if (!isRoot && !isInReplies) return; setJumpToEventId(targetId); setTimeout(() => setJumpToEventId(undefined), 2500); @@ -720,42 +695,63 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra [threadRootId] ); - const sharedMessageProps = { + // Map jumpToEventId to a focusItem index for useTimelineEventRenderer highlighting + const jumpIndex = jumpToEventId ? processedEvents.findIndex((e) => e.id === jumpToEventId) : -1; + const focusItem = + jumpIndex >= 0 + ? { index: processedEvents[jumpIndex].itemIndex, highlight: true, scrollTo: false as const } + : undefined; + + const renderMatrixEvent = useTimelineEventRenderer({ room, - threadRootId, - editId, - onEditId: handleEdit, - messageLayout, - messageSpacing, - canDelete: canRedact || canDeleteOwn, - canSendReaction, - canPinEvent, - imagePackRooms, - activeReplyId, - hour24Clock, - dateFormatString, - onUserClick: handleUserClick, - onUsernameClick: handleUsernameClick, - onReplyClick: handleReplyClick, - onReactionToggle: handleReactionToggle, - onResend: handleResend, - onDeleteFailedSend: handleDeleteFailedSend, + mx, pushProcessor, - linkifyOpts, - htmlReactParserOptions, - showHideReads: hideReads, - showDeveloperTools, - onReferenceClick: handleOpenReply, - jumpToEventId, - }; + nicknames, + imagePackRooms, + settings: { + messageLayout, + messageSpacing, + hideReads, + showDeveloperTools, + hour24Clock, + dateFormatString, + mediaAutoLoad, + showUrlPreview, + showClientUrlPreview, + autoplayStickers, + hideMemberInReadOnly, + isReadOnly, + hideMembershipEvents: true, + hideNickAvatarEvents: true, + showHiddenEvents, + hideThreadChip: true, + }, + state: { focusItem, editId, activeReplyId, openThreadId: threadRootId }, + permissions: { + canRedact, + canDeleteOwn, + canSendReaction, + canPinEvent, + }, + callbacks: { + onUserClick: handleUserClick, + onUsernameClick: handleUsernameClick, + onReplyClick: handleReplyClick, + onReactionToggle: handleReactionToggle, + onEditId: handleEdit, + onResend: handleResend, + onDeleteFailedSend: handleDeleteFailedSend, + setOpenThread: () => {}, + handleOpenReply, + }, + utils: { htmlReactParserOptions, linkifyOpts, getMemberPowerTag, parseMemberEvent }, + }); // Latest thread event for the following indicator (latest reply, or root if no replies) const threadParticipantIds = new Set( - [rootEvent, ...replyEvents].map((ev) => ev?.getSender()).filter(Boolean) as string[] + processedEvents.map((e) => e.mEvent.getSender()).filter(Boolean) as string[] ); - const latestThreadEventId = ( - replyEvents.length > 0 ? replyEvents[replyEvents.length - 1] : rootEvent - )?.getId(); + const latestThreadEventId = processedEvents.at(-1)?.id ?? rootEvent?.getId(); return ( - - # {room.name} - - + {renderMatrixEvent( + rootEvent.getType(), + typeof rootEvent.getStateKey() === 'string', + rootEvent.getId()!, + rootEvent, + processedEvents.find((e) => e.id === threadRootId)?.itemIndex ?? 0, + thread?.timelineSet ?? room.getUnfilteredTimelineSet(), + false + )} )} @@ -820,58 +822,77 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra variant="Background" visibility="Hover" direction="Vertical" - hideTrack + size="300" + onScroll={handleRepliesScroll} style={{ flexGrow: 1 }} > - {replyEvents.length === 0 ? ( - - - - No replies yet. Start the thread below! - - - ) : ( - <> - {/* Reply count label inside scroll area */} - - - {replyEvents.length} {replyEvents.length === 1 ? 'reply' : 'replies'} - - - - {replyEvents.map((mEvent, i) => { - const prevEvent = i > 0 ? replyEvents[i - 1] : undefined; - const collapse = - prevEvent !== undefined && - prevEvent.getSender() === mEvent.getSender() && - prevEvent.getType() === mEvent.getType() && - minuteDifference(prevEvent.getTs(), mEvent.getTs()) < 2; - return ( - - ); - })} - - - )} + {(() => { + if (isThreadLoading) + return ( + + + + ); + if (processedReplies.length === 0) + return ( + + + + No replies yet. Start the thread below! + + + ); + return ( + <> + {loadingOlderReplies && ( + + + + )} + {/* Reply count label inside scroll area */} + + + {processedReplies.length} {processedReplies.length === 1 ? 'reply' : 'replies'} + + + + {processedReplies.map((e) => + renderMatrixEvent( + e.mEvent.getType(), + typeof e.mEvent.getStateKey() === 'string', + e.id, + e.mEvent, + e.itemIndex, + e.timelineSet, + e.collapsed + ) + )} + + + ); + })()} @@ -885,6 +906,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra threadRootId={threadRootId} editor={editor} fileDropContainerRef={drawerRef} + onEditLastMessage={handleEditLastMessage} /> {hideReads ? ( diff --git a/src/app/hooks/timeline/useProcessedTimeline.ts b/src/app/hooks/timeline/useProcessedTimeline.ts index f1f799308..44e9500a2 100644 --- a/src/app/hooks/timeline/useProcessedTimeline.ts +++ b/src/app/hooks/timeline/useProcessedTimeline.ts @@ -20,6 +20,12 @@ export interface UseProcessedTimelineOptions { hideNickAvatarEvents: boolean; isReadOnly: boolean; hideMemberInReadOnly: boolean; + /** + * When true, skip the filter that removes events whose `threadRootId` points + * to a different event. Required when processing a thread's own timeline + * where every reply legitimately has `threadRootId` set to the root. + */ + skipThreadFilter?: boolean; } export interface ProcessedEvent { @@ -55,6 +61,7 @@ export function useProcessedTimeline({ hideNickAvatarEvents, isReadOnly, hideMemberInReadOnly, + skipThreadFilter, }: UseProcessedTimelineOptions): ProcessedEvent[] { return useMemo(() => { let prevEvent: MatrixEvent | undefined; @@ -116,7 +123,7 @@ export function useProcessedTimeline({ } } - if (threadRootId !== undefined && threadRootId !== mEventId) return acc; + if (!skipThreadFilter && threadRootId !== undefined && threadRootId !== mEventId) return acc; const isReactionOrEdit = reactionOrEditEvent(mEvent); if (isReactionOrEdit) return acc; @@ -193,5 +200,6 @@ export function useProcessedTimeline({ hideNickAvatarEvents, isReadOnly, hideMemberInReadOnly, + skipThreadFilter, ]); } diff --git a/src/app/hooks/timeline/useTimelineActions.ts b/src/app/hooks/timeline/useTimelineActions.ts index e7bb45f68..621e92aef 100644 --- a/src/app/hooks/timeline/useTimelineActions.ts +++ b/src/app/hooks/timeline/useTimelineActions.ts @@ -5,13 +5,12 @@ import { ReactEditor } from 'slate-react'; import { getMxIdLocalPart, toggleReaction } from '$utils/matrix'; import { getMemberDisplayName, getEditedEvent } from '$utils/room'; -import { createMentionElement, isEmptyEditor, moveCursor } from '$components/editor'; +import { createMentionElement, moveCursor } from '$components/editor'; export interface UseTimelineActionsOptions { room: Room; mx: MatrixClient; editor: Editor; - alive: () => boolean; nicknames: Record; globalProfiles: Record; spaceId?: string; @@ -27,8 +26,7 @@ export interface UseTimelineActionsOptions { setReplyDraft: (draft: any) => void; openThreadId?: string; setOpenThread: (threadId: string | undefined) => void; - setEditId: (editId: string | undefined) => void; - onEditorReset?: () => void; + handleEdit: (editId?: string) => void; handleOpenEvent: (eventId: string) => void; } @@ -36,7 +34,6 @@ export function useTimelineActions({ room, mx, editor, - alive, nicknames, globalProfiles, spaceId, @@ -45,8 +42,7 @@ export function useTimelineActions({ setReplyDraft, openThreadId, setOpenThread, - setEditId, - onEditorReset, + handleEdit, handleOpenEvent, }: UseTimelineActionsOptions) { const handleOpenReply: MouseEventHandler = useCallback( @@ -209,24 +205,6 @@ export function useTimelineActions({ [mx] ); - const handleEdit = useCallback( - (targetEditId?: string) => { - if (targetEditId) { - setEditId(targetEditId); - return; - } - setEditId(undefined); - - requestAnimationFrame(() => { - if (!alive()) return; - if (isEmptyEditor(editor)) onEditorReset?.(); - ReactEditor.focus(editor); - moveCursor(editor); - }); - }, - [editor, alive, onEditorReset, setEditId] - ); - return { handleOpenReply, handleUserClick, diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx index f7dca411a..9b56ea774 100644 --- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx +++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx @@ -1,10 +1,14 @@ -import { MouseEventHandler, useCallback, useMemo } from 'react'; +import { MouseEventHandler, useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useAtomValue } from 'jotai'; import { + IThreadBundledRelationship, MatrixClient, MatrixEvent, + NotificationCountType, Room, + RoomEvent, + ThreadEvent, PushProcessor, EventTimelineSet, IContent, @@ -47,6 +51,7 @@ import { } from '$utils/room'; import { getLinkedTimelines, getLiveTimeline } from '$utils/timeline'; import * as customHtmlCss from '$styles/CustomHtml.css'; +import { UnreadBadge, UnreadBadgeCenter } from '$components/unread-badge'; import { EncryptedContent, Event, @@ -105,20 +110,49 @@ function ThreadReplyChip({ const useAuthentication = useMediaAuthentication(); const nicknames = useAtomValue(nicknamesAtom); + const [counter, forceUpdate] = useState(0); + const thread = room.getThread(mEventId); + useEffect(() => { + if (!thread) return () => {}; + const onUpdate = () => forceUpdate((n) => n + 1); + thread.on(ThreadEvent.NewReply as any, onUpdate); + thread.on(ThreadEvent.Update as any, onUpdate); + room.on(RoomEvent.Redaction as any, onUpdate); + return () => { + thread.off(ThreadEvent.NewReply as any, onUpdate); + thread.off(ThreadEvent.Update as any, onUpdate); + room.off(RoomEvent.Redaction as any, onUpdate); + }; + }, [room, thread]); + const replyEvents = useMemo(() => { + // With threadSupport:true, reply events live in thread.timelineSet not the main room timeline. + // Prefer thread.events when available so avatars and preview text are populated. + if (thread) { + const fromThread = thread.events.filter( + (ev) => ev.getId() !== mEventId && !reactionOrEditEvent(ev) + ); + if (fromThread.length > 0) return fromThread; + } const linkedTimelines = getLinkedTimelines(getLiveTimeline(room)); return linkedTimelines .flatMap((tl) => tl.getEvents()) .filter( (ev) => ev.threadRootId === mEventId && ev.getId() !== mEventId && !reactionOrEditEvent(ev) ); - }, [room, mEventId]); + // eslint-disable-next-line react-hooks/exhaustive-deps -- counter is a cache-busting key, not used directly in body + }, [room, mEventId, thread, counter]); if (!thread) return null; - const replyCount = thread.length ?? 0; + // Prefer the server-authoritative bundled count. thread.length only reflects + // events fetched into the local timeline, which can be much lower than the + // true total before the thread drawer is first opened and paginated. + const bundledCount = + thread.rootEvent?.getServerAggregatedRelation('m.thread')?.count; + const replyCount = bundledCount ?? thread.length ?? 0; if (replyCount === 0) return null; const uniqueSenders: string[] = []; @@ -146,6 +180,12 @@ function ThreadReplyChip({ const isOpen = openThreadId === mEventId; + const unreadTotal = room.getThreadUnreadNotificationCount(mEventId, NotificationCountType.Total); + const unreadHighlight = room.getThreadUnreadNotificationCount( + mEventId, + NotificationCountType.Highlight + ); + return ( )} + {unreadTotal > 0 && ( + + 0} count={unreadTotal} /> + + )} ); } @@ -226,6 +271,7 @@ export interface TimelineEventRendererOptions { hideMembershipEvents: boolean; hideNickAvatarEvents: boolean; showHiddenEvents: boolean; + hideThreadChip?: boolean; }; state: { focusItem?: { index: number; highlight: boolean; scrollTo: boolean }; @@ -280,6 +326,7 @@ export function useTimelineEventRenderer({ hideMembershipEvents, hideNickAvatarEvents, showHiddenEvents, + hideThreadChip, }, state: { focusItem, editId, activeReplyId, openThreadId }, permissions: { canRedact, canDeleteOwn, canSendReaction, canPinEvent }, @@ -309,9 +356,16 @@ export function useTimelineEventRenderer({ isRedacted, getUnsigned, getTs, - replyEventId, + getWireContent, + replyEventId: rawReplyEventId, threadRootId, } = mEvent; + // In the thread drawer (hideThreadChip=true), suppress reply headers for events + // that only have m.in_reply_to as a non-thread-client fallback (is_falling_back: true). + const replyEventId = + hideThreadChip && getWireContent.call(mEvent)?.['m.relates_to']?.is_falling_back + ? undefined + : rawReplyEventId; const reactionRelations = getEventReactions(timelineSet, mEventId); const reactions = reactionRelations?.getSortedAnnotationsByKey(); @@ -400,7 +454,7 @@ export function useTimelineEventRenderer({ room={room} timelineSet={timelineSet} replyEventId={replyEventId} - threadRootId={threadRootId} + threadRootId={hideThreadChip ? undefined : threadRootId} mentions={baseContent['m.mentions']} onClick={handleOpenReply} /> @@ -408,7 +462,7 @@ export function useTimelineEventRenderer({ } reactions={(() => { const threadChip = - room.getThread(mEventId) || threadRootId ? ( + !hideThreadChip && (room.getThread(mEventId) || threadRootId) ? ( ) } reactions={(() => { const threadChip = - room.getThread(mEventId) || threadRootId ? ( + !hideThreadChip && (room.getThread(mEventId) || threadRootId) ? ( @@ -691,7 +755,7 @@ export function useTimelineEventRenderer({ } reactions={(() => { const threadChip = - room.getThread(mEventId) || threadRootId ? ( + !hideThreadChip && (room.getThread(mEventId) || threadRootId) ? ( void; + alive?: () => boolean; +} + +/** + * Manages the "edit mode" state for a message composer. + * + * Centralises the `editId` state and the `handleEdit` callback so both + * `RoomTimeline` and `ThreadDrawer` share identical behaviour: setting an + * edit target activates the editor for that event; clearing it resets the + * editor and returns focus. + */ +export function useMessageEdit( + editor: Editor, + options?: UseMessageEditOptions +): { editId: string | undefined; handleEdit: (editId?: string) => void } { + const [editId, setEditId] = useState(undefined); + + // Use refs so the callback never goes stale on options changes. + const aliveRef = useRef(options?.alive); + aliveRef.current = options?.alive; + const onResetRef = useRef(options?.onReset); + onResetRef.current = options?.onReset; + + const handleEdit = useCallback( + (targetEditId?: string) => { + if (targetEditId) { + setEditId(targetEditId); + return; + } + setEditId(undefined); + requestAnimationFrame(() => { + if (aliveRef.current && !aliveRef.current()) return; + if (onResetRef.current && isEmptyEditor(editor)) onResetRef.current(); + ReactEditor.focus(editor); + moveCursor(editor); + }); + }, + [editor] + ); + + return { editId, handleEdit }; +} diff --git a/src/app/styles/overrides/General.css.ts b/src/app/styles/overrides/General.css.ts index 34ef9ada8..4edb6ea98 100644 --- a/src/app/styles/overrides/General.css.ts +++ b/src/app/styles/overrides/General.css.ts @@ -40,7 +40,9 @@ globalStyle( button[class*="_1684mq51"]:has(img):hover, [data-index] [class*="_1r9nvaso"]:hover, [data-index] [class*="_1r9nvaso"] *:hover, - [data-index] button:has(p):hover + [data-index] button:has(p):hover, + [data-index] button:hover, + [data-index] [role="button"]:hover `, { transform: 'none !important', diff --git a/src/client/initMatrix.ts b/src/client/initMatrix.ts index 093093ba2..f6f428a10 100644 --- a/src/client/initMatrix.ts +++ b/src/client/initMatrix.ts @@ -429,6 +429,7 @@ export const startClient = async (mx: MatrixClient, config?: StartClientConfig): await mx.startClient({ lazyLoadMembers: true, pollTimeout: FAST_SYNC_POLL_TIMEOUT_MS, + threadSupport: true, }); // Attach an ongoing classic-sync observer — equivalent to SlidingSyncManager's // onLifecycle listener. Tracks state transitions, initial-sync timing, and errors. @@ -581,6 +582,7 @@ export const startClient = async (mx: MatrixClient, config?: StartClientConfig): await mx.startClient({ lazyLoadMembers: true, slidingSync: manager.slidingSync, + threadSupport: true, }); } catch (err) { debugLog.error('network', 'Failed to start client with sliding sync', { From 76333bdb6ddb8565cad237768749cf08918cec09 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Mon, 6 Apr 2026 12:51:04 -0400 Subject: [PATCH 02/26] chore: add changeset for feat-thread-enhancements --- .changeset/feat-thread-enhancements.md | 5 +++++ src/app/features/room/ThreadBrowser.tsx | 17 +++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 .changeset/feat-thread-enhancements.md diff --git a/.changeset/feat-thread-enhancements.md b/.changeset/feat-thread-enhancements.md new file mode 100644 index 000000000..b2532c19c --- /dev/null +++ b/.changeset/feat-thread-enhancements.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Update threads: various fixes, browse all room threads, and see live reply counts on messages. diff --git a/src/app/features/room/ThreadBrowser.tsx b/src/app/features/room/ThreadBrowser.tsx index 4cf718a8e..51a01780b 100644 --- a/src/app/features/room/ThreadBrowser.tsx +++ b/src/app/features/room/ThreadBrowser.tsx @@ -454,16 +454,13 @@ export function ThreadBrowser({ room, onOpenThread, onClose, overlay }: ThreadBr const handleLoadMoreRef = useRef(handleLoadMore); handleLoadMoreRef.current = handleLoadMore; - const handleThreadsScroll = useCallback( - (e: React.UIEvent) => { - const el = e.currentTarget; - const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight; - if (distanceFromBottom < 200 && canLoadMoreRef.current && !loadingMoreRef.current) { - handleLoadMoreRef.current(); - } - }, - [] - ); + const handleThreadsScroll = useCallback((e: React.UIEvent) => { + const el = e.currentTarget; + const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight; + if (distanceFromBottom < 200 && canLoadMoreRef.current && !loadingMoreRef.current) { + handleLoadMoreRef.current(); + } + }, []); const allThreads = room.getThreads().sort((a: Thread, b: Thread) => { const aTs = a.events.at(-1)?.getTs() ?? a.rootEvent?.getTs() ?? 0; From ccfd9afc3bc08a418ebda686873c359ec9f9d3c6 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 02:26:50 -0700 Subject: [PATCH 03/26] fix: prevent iOS overscroll on root element Add overscroll-behavior: none to the html element to prevent the elastic bounce-back scroll effect on iOS that competes with the timeline scroll. Fixes #500 --- src/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.css b/src/index.css index ceab92d93..cde45ce4c 100755 --- a/src/index.css +++ b/src/index.css @@ -78,6 +78,7 @@ html { height: 100%; overflow: hidden; + overscroll-behavior: none; } body { From 3525c32a6f50f005e3945254fac55c1059cf0c1d Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 02:48:32 -0700 Subject: [PATCH 04/26] fix: use file name instead of "a voice message" for non-voice audio Only use "a voice message" as the fallback body text when the audio actually has waveform data (i.e., it was recorded as a voice message). Regular audio files (music, etc.) now fall back to the file name instead. Fixes #543 --- src/app/features/room/msgContent.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/features/room/msgContent.ts b/src/app/features/room/msgContent.ts index 0cec05a57..c4547deca 100644 --- a/src/app/features/room/msgContent.ts +++ b/src/app/features/room/msgContent.ts @@ -147,10 +147,12 @@ export type AudioMsgContent = IContent & { export const getAudioMsgContent = (item: TUploadItem, mxc: string): AudioMsgContent => { const { file, encInfo, metadata } = item; const { waveform, audioDuration, markedAsSpoiler } = metadata; + const isVoice = waveform !== undefined && waveform.length > 0; + const fallbackBody = isVoice ? 'a voice message' : file.name; let content: IContent = { msgtype: MsgType.Audio, filename: file.name, - body: item.body && item.body.length > 0 ? item.body : 'a voice message', + body: item.body && item.body.length > 0 ? item.body : fallbackBody, info: { mimetype: file.type, size: file.size, @@ -162,7 +164,7 @@ export const getAudioMsgContent = (item: TUploadItem, mxc: string): AudioMsgCont waveform: waveform?.map((v) => Math.round(v * 1024)), duration: markedAsSpoiler || !audioDuration ? 0 : audioDuration * 1000, }, - 'org.matrix.msc1767.text': item.body && item.body.length > 0 ? item.body : 'a voice message', + 'org.matrix.msc1767.text': item.body && item.body.length > 0 ? item.body : fallbackBody, 'org.matrix.msc3245.voice.v2': { duration: markedAsSpoiler || !audioDuration ? 0 : audioDuration, waveform: waveform?.map((v) => Math.round(v * 1024)), From 41ac5c69710e5ffd0f51f2823ad3d64a04319580 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 02:56:50 -0700 Subject: [PATCH 05/26] fix: constrain bug report modal to viewport height Add maxHeight: 90vh to the Modal and its inner Box container so the bug report screen doesn't overflow beyond the viewport, which was causing the close button and header text to be cropped off. Fixes #629 --- src/app/features/bug-report/BugReportModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/features/bug-report/BugReportModal.tsx b/src/app/features/bug-report/BugReportModal.tsx index 1babed978..168d7b972 100644 --- a/src/app/features/bug-report/BugReportModal.tsx +++ b/src/app/features/bug-report/BugReportModal.tsx @@ -233,8 +233,8 @@ function BugReportModal() { escapeDeactivates: stopPropagation, }} > - - + +
Date: Tue, 7 Apr 2026 10:30:24 -0500 Subject: [PATCH 06/26] fix dms nav --- .changeset/fix-dms-nav-not-naving.dm | 5 +++++ src/app/pages/client/sidebar/DirectTab.tsx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-dms-nav-not-naving.dm diff --git a/.changeset/fix-dms-nav-not-naving.dm b/.changeset/fix-dms-nav-not-naving.dm new file mode 100644 index 000000000..53751aa01 --- /dev/null +++ b/.changeset/fix-dms-nav-not-naving.dm @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix dms navigation not navigating to dms when local storage is messed up. \ No newline at end of file diff --git a/src/app/pages/client/sidebar/DirectTab.tsx b/src/app/pages/client/sidebar/DirectTab.tsx index 17c88a042..ffdf9c5ac 100644 --- a/src/app/pages/client/sidebar/DirectTab.tsx +++ b/src/app/pages/client/sidebar/DirectTab.tsx @@ -82,7 +82,9 @@ export function DirectTab() { const handleDirectClick = () => { const activePath = navToActivePath.get('direct'); - if (activePath && screenSize !== ScreenSize.Mobile) { + const activePathname = activePath?.pathname; + const isValidDirectPath = typeof activePathname === 'string' && activePathname.startsWith('/direct/'); + if (activePath && isValidDirectPath && screenSize !== ScreenSize.Mobile) { navigate(joinPathComponent(activePath)); return; } From dbd1b36f258ea52b00bdc436b69255301e37a1a0 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 7 Apr 2026 10:34:16 -0500 Subject: [PATCH 07/26] formatting --- src/app/pages/client/sidebar/DirectTab.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/pages/client/sidebar/DirectTab.tsx b/src/app/pages/client/sidebar/DirectTab.tsx index ffdf9c5ac..72c2b7d5b 100644 --- a/src/app/pages/client/sidebar/DirectTab.tsx +++ b/src/app/pages/client/sidebar/DirectTab.tsx @@ -83,7 +83,8 @@ export function DirectTab() { const handleDirectClick = () => { const activePath = navToActivePath.get('direct'); const activePathname = activePath?.pathname; - const isValidDirectPath = typeof activePathname === 'string' && activePathname.startsWith('/direct/'); + const isValidDirectPath = + typeof activePathname === 'string' && activePathname.startsWith('/direct/'); if (activePath && isValidDirectPath && screenSize !== ScreenSize.Mobile) { navigate(joinPathComponent(activePath)); return; From 09fe8d9298b878547c1ba3a0dd47c99f0743d46d Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 7 Apr 2026 10:36:24 -0500 Subject: [PATCH 08/26] markdown file not dm file... --- .../{fix-dms-nav-not-naving.dm => fix-dms-nav-not-naving.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .changeset/{fix-dms-nav-not-naving.dm => fix-dms-nav-not-naving.md} (89%) diff --git a/.changeset/fix-dms-nav-not-naving.dm b/.changeset/fix-dms-nav-not-naving.md similarity index 89% rename from .changeset/fix-dms-nav-not-naving.dm rename to .changeset/fix-dms-nav-not-naving.md index 53751aa01..2e214e4a8 100644 --- a/.changeset/fix-dms-nav-not-naving.dm +++ b/.changeset/fix-dms-nav-not-naving.md @@ -2,4 +2,4 @@ default: patch --- -Fix dms navigation not navigating to dms when local storage is messed up. \ No newline at end of file +Fix dms navigation not navigating to dms when local storage is messed up. From fb8450ec8b698ecb6ead09938898da68764e58cf Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:25:37 -0700 Subject: [PATCH 09/26] docs: add changeset for iOS overscroll fix --- .changeset/fix-ios-overscroll.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-ios-overscroll.md diff --git a/.changeset/fix-ios-overscroll.md b/.changeset/fix-ios-overscroll.md new file mode 100644 index 000000000..02b02f246 --- /dev/null +++ b/.changeset/fix-ios-overscroll.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix iOS elastic bounce-back overscroll on the root element. From ea59ca2395ecf8a38c709b58261da4a10556b553 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:26:06 -0700 Subject: [PATCH 10/26] docs: add changeset for audio description fix --- .changeset/fix-audio-file-description.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-audio-file-description.md diff --git a/.changeset/fix-audio-file-description.md b/.changeset/fix-audio-file-description.md new file mode 100644 index 000000000..89710332a --- /dev/null +++ b/.changeset/fix-audio-file-description.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Use file name instead of "a voice message" for non-voice audio files. From 027f6ae1c00eebef59769ceadd2979d0c6556311 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:26:20 -0700 Subject: [PATCH 11/26] docs: add changeset for bug report modal fix --- .changeset/fix-bug-report-modal-overflow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-bug-report-modal-overflow.md diff --git a/.changeset/fix-bug-report-modal-overflow.md b/.changeset/fix-bug-report-modal-overflow.md new file mode 100644 index 000000000..c37f218a7 --- /dev/null +++ b/.changeset/fix-bug-report-modal-overflow.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Constrain bug report modal to viewport height to prevent overflow. From 235431da00d91ed5142e725f71748cc0b94d9b47 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Wed, 8 Apr 2026 17:13:38 -0400 Subject: [PATCH 12/26] fix(threads): pass showBundledPreview setting to useTimelineEventRenderer --- src/app/features/room/ThreadDrawer.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 94e3ab1ed..7e0e3960f 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -137,6 +137,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); const [showTombstoneEvents] = useSetting(settingsAtom, 'showTombstoneEvents'); const [hideMemberInReadOnly] = useSetting(settingsAtom, 'hideMembershipInReadOnly'); + const [showBundledPreview] = useSetting(settingsAtom, 'bundledPreview'); const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview; const showClientUrlPreview = room.hasEncryptionStateEvent() ? clientUrlPreview && encClientUrlPreview @@ -718,6 +719,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra mediaAutoLoad, showUrlPreview, showClientUrlPreview, + showBundledPreview, autoplayStickers, hideMemberInReadOnly, isReadOnly, From c47b842c74ca929d2f4e0548fdc07d5c9860a8af Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Thu, 9 Apr 2026 07:18:14 +0300 Subject: [PATCH 13/26] basic working version --- .../settings/account/NameColorEditor.tsx | 158 +++++++++--------- src/app/features/settings/account/Profile.tsx | 22 ++- src/app/hooks/useUserProfile.ts | 37 +++- 3 files changed, 133 insertions(+), 84 deletions(-) diff --git a/src/app/features/settings/account/NameColorEditor.tsx b/src/app/features/settings/account/NameColorEditor.tsx index 8185dc2c0..9428a8e02 100644 --- a/src/app/features/settings/account/NameColorEditor.tsx +++ b/src/app/features/settings/account/NameColorEditor.tsx @@ -7,6 +7,7 @@ import { HexColorPickerPopOut } from '$components/HexColorPickerPopOut'; type NameColorEditorProps = { title: string; description?: string; + focusId?: string; current?: string; onSave: (color: string | null) => void; disabled?: boolean; @@ -15,6 +16,7 @@ type NameColorEditorProps = { export function NameColorEditor({ title, description, + focusId, current, onSave, disabled, @@ -57,89 +59,95 @@ export function NameColorEditor({ return ( - - - - } + - {(onOpen, opened) => ( - + )} + + + + handleUpdate(e.currentTarget.value)} + placeholder="#FFFFFF" + variant="Background" + size="300" + radii="300" + disabled={disabled ?? false} style={{ - width: '32px', - height: '32px', - borderRadius: '50%', - backgroundColor: tempColor, - boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.1)', + textTransform: 'uppercase', + fontFamily: 'monospace', + width: '100px', }} /> + {current && ( + + + + )} + + + + {hasChanged && ( + )} - - - - handleUpdate(e.currentTarget.value)} - placeholder="#FFFFFF" - variant="Background" - size="300" - radii="300" - disabled={disabled ?? false} - style={{ - textTransform: 'uppercase', - fontFamily: 'monospace', - width: '100px', - }} - /> - {current && ( - - - - )} - - - {hasChanged && ( - - )} - + } + /> ); } diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 834bd511d..16e022a94 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -539,11 +539,30 @@ function ProfileExtended({ profile, userId }: Readonly) { gap="400" > handleSaveField('moe.sable.app.name_color', color)} /> + handleSaveField('moe.sable.app.name_color_dark_theme', color)} + /> + handleSaveField('moe.sable.app.name_color_light_theme', color)} + /> diff --git a/src/app/hooks/useUserProfile.ts b/src/app/hooks/useUserProfile.ts index 3308e6813..4d78035ea 100644 --- a/src/app/hooks/useUserProfile.ts +++ b/src/app/hooks/useUserProfile.ts @@ -9,6 +9,7 @@ import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; import { MSC1767Text } from '$types/matrix/common'; import { useMatrixClient } from './useMatrixClient'; +import { ThemeKind, useActiveTheme } from './useTheme'; const inFlightProfiles = new Map>(); @@ -25,6 +26,8 @@ export type UserProfile = { status?: string; bannerUrl?: string; nameColor?: string; + nameColorDark?: string; + nameColorLight?: string; isCat?: boolean; hasCats?: boolean; extended?: Record; @@ -45,6 +48,8 @@ const normalizeInfo = (info: any): UserProfile => { 'chat.commet.profile_banner', 'chat.commet.profile_status', 'moe.sable.app.name_color', + 'moe.sable.app.name_color_dark_theme', + 'moe.sable.app.name_color_light_theme', 'kitty.meow.has_cats', 'kitty.meow.is_cat', ]); @@ -68,6 +73,8 @@ const normalizeInfo = (info: any): UserProfile => { status: info['chat.commet.profile_status'], bannerUrl: info['chat.commet.profile_banner'], nameColor: info['moe.sable.app.name_color'], + nameColorDark: info['moe.sable.app.name_color_dark_theme'], + nameColorLight: info['moe.sable.app.name_color_light_theme'], isCat: info['kitty.meow.is_cat'] === true, hasCats: info['kitty.meow.has_cats'] === true, extended, @@ -98,6 +105,7 @@ export const useUserProfile = ( const [renderGlobalColors] = useSetting(settingsAtom, 'renderGlobalNameColors'); const [renderRoomColors] = useSetting(settingsAtom, 'renderRoomColors'); const [renderRoomFonts] = useSetting(settingsAtom, 'renderRoomFonts'); + const themeKind = useActiveTheme().kind; const userSelector = useMemo(() => selectAtom(profilesCacheAtom, (db) => db[userId]), [userId]); @@ -202,12 +210,26 @@ export const useUserProfile = ( } } const validGlobalVal = isValidHex(data?.nameColor); + const validGlobalValDark = isValidHex(data?.nameColorDark); + const validGlobalValLight = isValidHex(data?.nameColorLight); - const hasGlobalColor = !!validGlobalVal; - const validGlobal = - (renderGlobalColors || userId === mx.getUserId()) && hasGlobalColor + const validGlobalGeneral = + (renderGlobalColors || userId === mx.getUserId()) && !!validGlobalVal ? validGlobalVal : undefined; + const validGlobalDark = + (renderGlobalColors || userId === mx.getUserId()) && + themeKind === ThemeKind.Dark && + !!validGlobalValDark + ? validGlobalValDark + : undefined; + const validGlobalLight = + (renderGlobalColors || userId === mx.getUserId()) && + themeKind === ThemeKind.Light && + !!validGlobalValLight + ? validGlobalValLight + : undefined; + const validGlobal = validGlobalDark ?? validGlobalLight ?? validGlobalGeneral; const validLocal = localColor && isValidHex(localColor) ? localColor : undefined; const validSpace = spaceColor && isValidHex(spaceColor) ? spaceColor : undefined; @@ -237,13 +259,14 @@ export const useUserProfile = ( }; }, [ cached, + initialProfile, + mx, userId, room, - mx, - legacyUsernameColor, - renderGlobalColors, - initialProfile, renderRoomColors, renderRoomFonts, + renderGlobalColors, + themeKind, + legacyUsernameColor, ]); }; From 8143a17d6d44be0d6a2fe65a034b008bb319ddc3 Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Thu, 9 Apr 2026 07:26:24 +0300 Subject: [PATCH 14/26] added changeset --- .changeset/feat-add-theme-specific-colors.md | 5 +++++ src/app/features/settings/account/Profile.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/feat-add-theme-specific-colors.md diff --git a/.changeset/feat-add-theme-specific-colors.md b/.changeset/feat-add-theme-specific-colors.md new file mode 100644 index 000000000..1ad50e322 --- /dev/null +++ b/.changeset/feat-add-theme-specific-colors.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Add the ability to set Global Name Colors dependent on the theme (dark/light) diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 16e022a94..da2d140f6 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -547,7 +547,7 @@ function ProfileExtended({ profile, userId }: Readonly) { /> ) { /> Date: Thu, 9 Apr 2026 07:32:25 +0300 Subject: [PATCH 15/26] make the text and bubble not move around --- .../settings/account/NameColorEditor.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/app/features/settings/account/NameColorEditor.tsx b/src/app/features/settings/account/NameColorEditor.tsx index 9428a8e02..3215b0970 100644 --- a/src/app/features/settings/account/NameColorEditor.tsx +++ b/src/app/features/settings/account/NameColorEditor.tsx @@ -75,6 +75,17 @@ export function NameColorEditor({ }} > + {hasChanged && ( + + )} } > @@ -133,18 +144,6 @@ export function NameColorEditor({ )} - - {hasChanged && ( - - )} } /> From 42b758258ac0661834b7c7c9261e10895684b954 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 9 Apr 2026 13:31:06 -0400 Subject: [PATCH 16/26] fix(timeline): re-arm initial-scroll when TimelineReset blanks the view When the app returns from background, retryImmediately() triggers a fresh sliding sync response. If the server includes initial:true for the open room, the SDK emits RoomEvent.TimelineReset, replacing the live timeline with a new empty one. eventsLength drops to 0 but isReady stays true, leaving the message list visible but empty for ~500 ms until events re-arrive. Add a useLayoutEffect that detects eventsLength dropping to 0 while the timeline is already visible (isReady === true). It hides the content (opacity 0) and resets hasInitialScrolledRef so the initial-scroll effect re-arms. When events refill the timeline the existing 80 ms scroll timer fires again and sets isReady back to true, revealing the content. --- src/app/features/room/RoomTimeline.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 5c61d9dd4..5f3dba47e 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -328,6 +328,17 @@ export function RoomTimeline({ [] ); + // If the timeline was blanked while content was already visible — e.g. a + // TimelineReset fired by mx.retryImmediately() when the app comes back from + // background — hide the timeline (opacity 0) and re-arm the initial-scroll so + // it runs again once events refill the live timeline. + useLayoutEffect(() => { + if (!isReady) return; + if (timelineSync.eventsLength > 0) return; + setIsReady(false); + hasInitialScrolledRef.current = false; + }, [isReady, timelineSync.eventsLength]); + const recalcTopSpacer = useCallback(() => { const v = vListRef.current; if (!v) return; From dc5dbfdf4ffb7cadb9414a7aac0cc25ef186ada7 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 9 Apr 2026 14:04:59 -0400 Subject: [PATCH 17/26] fix(timeline): show skeleton placeholders while timeline reloads on foreground --- src/app/features/room/RoomTimeline.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 5f3dba47e..9076d4502 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -651,7 +651,7 @@ export function RoomTimeline({ const showLoadingPlaceholders = timelineSync.eventsLength === 0 && - (timelineSync.canPaginateBack || timelineSync.backwardStatus === 'loading'); + (!isReady || timelineSync.canPaginateBack || timelineSync.backwardStatus === 'loading'); let backPaginationJSX: ReactNode | undefined; if (timelineSync.canPaginateBack || timelineSync.backwardStatus !== 'idle') { @@ -719,7 +719,7 @@ export function RoomTimeline({ const vListItemCount = timelineSync.eventsLength === 0 && - (timelineSync.canPaginateBack || timelineSync.backwardStatus === 'loading') + (!isReady || timelineSync.canPaginateBack || timelineSync.backwardStatus === 'loading') ? 3 : timelineSync.eventsLength; const vListIndices = useMemo( @@ -851,7 +851,7 @@ export function RoomTimeline({ minHeight: 0, overflow: 'hidden', position: 'relative', - opacity: isReady ? 1 : 0, + opacity: isReady || showLoadingPlaceholders ? 1 : 0, }} > From 3aacd916db36238036c2ffca5149f1360200286f Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 9 Apr 2026 15:13:11 -0400 Subject: [PATCH 18/26] chore: add changeset for timeline-blank-on-foreground fix --- .changeset/fix-timeline-blank-on-foreground.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-timeline-blank-on-foreground.md diff --git a/.changeset/fix-timeline-blank-on-foreground.md b/.changeset/fix-timeline-blank-on-foreground.md new file mode 100644 index 000000000..a214a478f --- /dev/null +++ b/.changeset/fix-timeline-blank-on-foreground.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix blank room timeline when app returns from background. When sliding sync delivers an `initial: true` response for the open room, a `TimelineReset` event now correctly shows skeleton placeholders while events reload instead of leaving an empty view. From 595d990ced5d4fdb33aa20e9384ca4aa872533e4 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 21:46:20 -0500 Subject: [PATCH 19/26] remove some unnecessary comments --- src/app/features/room/ThreadDrawer.tsx | 60 +------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 7e0e3960f..92288e61c 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -98,19 +98,11 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const [jumpToEventId, setJumpToEventId] = useState(undefined); const [loadingOlderReplies, setLoadingOlderReplies] = useState(false); const [canPageBack, setCanPageBack] = useState(true); - // Ref guard so the auto-paginate effect never starts a second concurrent request. const paginatingOlderRef = useRef(false); const scrollRef = useRef(null); const prevReplyCountRef = useRef(0); const processedEventsRef = useRef([]); - // Track whether we've already attempted a server fetch for a given threadRootId. - // Prevents infinite re-fetch loops on genuinely empty threads while still - // allowing the first fetch even when thread.length === 0 (sliding sync case - // where bundled aggregations are absent so replyCount defaults to 0). const serverFetchAttemptedRef = useRef(null); - // True while the viewport auto-fill is actively paginating backwards. - // Used so the auto-scroll effect keeps the user anchored to the bottom - // (showing latest replies) while older content is prepended at the top. const autoFillInProgressRef = useRef(false); const { editId, handleEdit } = useMessageEdit(editor); const nicknames = useAtomValue(nicknamesAtom); @@ -280,30 +272,6 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra const processedReplies = displayReplies; // Ensure the Thread object exists and has its reply events loaded. - // - // Case A — no Thread object yet (e.g. root event was loaded via jump/backward - // pagination but the SDK hasn't created a Thread shell for it): - // Call room.createThread() so the SDK constructor kicks off - // updateThreadMetadata() → resetLiveTimeline() + paginateEventTimeline() - // automatically. ThreadEvent.Update fires when done → forceUpdate → re-render. - // DO NOT call resetLiveTimeline() or paginateEventTimeline() ourselves — - // that would race with the SDK's own initialization and cause a flood of - // "Ignoring event … does not belong in timeline" warnings. - // - // If the root is also outside the local timeline (e.g. a thread discovered - // via ThreadBrowser but whose root predates the sliding-sync window), we - // fetch it bare with fetchRoomEvent — this does NOT add it to the main - // room timeline or cause any TimelineRefresh side-effects. - // - // Case B — Thread exists but initialEventsFetched is false (server-side thread - // support active; SDK's updateThreadMetadata() is running): - // Do nothing — the SDK will fire ThreadEvent.Update when done. - // - // Case C — Thread exists, initialEventsFetched is true (classic sync or SDK - // has already finished initialising): - // With classic sync the SDK never paginates thread timelines, so we backfill - // from the main live timeline. With server-side threads the SDK already - // populated thread.events; this block is a no-op in that case. useEffect(() => { // Case A: create thread shell; SDK handles the rest asynchronously. if (!room.getThread(threadRootId)) { @@ -352,36 +320,15 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra return; } - // No local events anywhere. We always attempt one server fetch here because - // with sliding sync the server omits bundled aggregations from subscription - // timeline events, leaving thread.replyCount at 0 even when the server has - // replies (the old `if (!currThread.length) return` guard incorrectly bailed - // out in that case). We use serverFetchAttemptedRef to ensure we only try - // once per threadRootId — if the paginate truly returns nothing, the ref - // prevents an infinite re-fetch loop. if (serverFetchAttemptedRef.current === threadRootId) return; serverFetchAttemptedRef.current = threadRootId; - // Do NOT call resetLiveTimeline() here. Resetting a thread timeline emits - // RoomEvent.TimelineReset on the thread's EventTimelineSet; Thread's own - // onTimelineReset handler then awaits processRootEventPromise (a live - // fetchRootEvent network call). If that promise is still pending this - // creates a deadlock that hangs and eventually crashes the app — observed - // on both classic sync and sliding sync. - // - // Calling paginateEventTimeline directly is safe: the thread's back-token - // is null (set by the fast path when replyCount was 0 at construction), but - // the SDK maps null → undefined for the `from` parameter and calls - // fetchRelations without a cursor, which correctly fetches the latest - // replies from the server. mx.paginateEventTimeline(currThread.timelineSet.getLiveTimeline(), { backwards: true }) .then(() => forceUpdate((n) => n + 1)) .catch(() => {}); // forceUpdateCounter must be in deps so this effect re-runs after // ThreadEvent.Update fires (which flips initialEventsFetched from false to - // true). Without it the effect runs once on mount, hits Case B - // (initialEventsFetched=false) and never runs again — leaving the drawer - // empty on sliding sync where replyCount starts at 0. + // true). }, [mx, room, threadRootId, forceUpdate, forceUpdateCounter]); // Re-render when new thread events arrive (including reactions via ThreadEvent.Update). @@ -514,11 +461,6 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra }, []); // Auto-scroll to bottom when event count grows. - // During viewport auto-fill (autoFillInProgressRef) we ALWAYS scroll to the - // bottom: older messages are prepended at the top, so scrollTop stays at 0 - // (clamped), and when content first overflows the isAtBottom check would be - // false — leaving the user staring at the oldest messages instead of the - // latest ones. useEffect(() => { const el = scrollRef.current; if (!el) return; From 02876e032f802704b379f5dafd62cba51ca8f780 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 21:47:30 -0500 Subject: [PATCH 20/26] Clean up comments in ThreadBrowser component Removed comments explaining reply count logic. --- src/app/features/room/ThreadBrowser.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/features/room/ThreadBrowser.tsx b/src/app/features/room/ThreadBrowser.tsx index 51a01780b..f5c58cf0d 100644 --- a/src/app/features/room/ThreadBrowser.tsx +++ b/src/app/features/room/ThreadBrowser.tsx @@ -162,18 +162,10 @@ function ThreadPreview({ room, thread, onClick, onJump }: ThreadPreviewProps) { const senderAvatarMxc = getMemberAvatarMxc(room, senderId); const getContent = (() => rootEvent.getContent()) as GetContentCallback; - // Prefer a locally-counted reply count (based on events already in the thread - // timeline) but fall back to thread.length which is the server-reported count - // from bundled m.thread aggregations. This means that for threads discovered - // via fetchRoomThreads() whose timeline hasn't been paginated yet we still - // show the correct count rather than zero. const localReplyCount = thread.events.filter( (ev: MatrixEvent) => ev.getId() !== thread.id && !reactionOrEditEvent(ev) ).length; // Use Math.max so we never show fewer replies than the server reports. - // thread.length is the server-reported count from bundled m.thread aggregations; - // it may slightly overcount reactions but is far more accurate than a partial - // local cache (e.g. 5 loaded vs 22 on server). const replyCount = Math.max(localReplyCount, thread.length ?? 0); const lastReply = thread.events From 29d90e6285e256ef9cbd9caca86ffd5056d82afa Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 21:58:44 -0500 Subject: [PATCH 21/26] formatting --- src/app/features/room/ThreadDrawer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx index 92288e61c..135c958a9 100644 --- a/src/app/features/room/ThreadDrawer.tsx +++ b/src/app/features/room/ThreadDrawer.tsx @@ -328,7 +328,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra .catch(() => {}); // forceUpdateCounter must be in deps so this effect re-runs after // ThreadEvent.Update fires (which flips initialEventsFetched from false to - // true). + // true). }, [mx, room, threadRootId, forceUpdate, forceUpdateCounter]); // Re-render when new thread events arrive (including reactions via ThreadEvent.Update). From 0fdbc9081fcbadf1e2466665c62a064d24ea9ab7 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 22:08:53 -0500 Subject: [PATCH 22/26] Update link in About component to Open Collective --- src/app/features/settings/about/About.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/settings/about/About.tsx b/src/app/features/settings/about/About.tsx index fdd3d3834..88c3d9259 100644 --- a/src/app/features/settings/about/About.tsx +++ b/src/app/features/settings/about/About.tsx @@ -209,7 +209,7 @@ export function About({ requestBack, requestClose }: Readonly) { - {/* - */} From 1e43d2db4adf092951169c7f1a65aeada0b08302 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 22:10:33 -0500 Subject: [PATCH 24/26] Add donation link to contributing guidelines --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 29f53db0b..c037e31df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,7 @@ All types of contributions are encouraged and valued. Please make sure to read t > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: > > - Star the project +> - [Donate](https://opencollective.com/sable)! ❤️ > - Talk about it! > - Refer this project in your project's readme > - Mention the project at local meetups and tell your friends/colleagues From ff8d1c73b2ea42c650647e18008c18c86c6f62cb Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 9 Apr 2026 22:12:00 -0500 Subject: [PATCH 25/26] Update donation links to Open Collective Updated support links for donations. --- .changeset/update-donation-links.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/update-donation-links.md diff --git a/.changeset/update-donation-links.md b/.changeset/update-donation-links.md new file mode 100644 index 000000000..3d68d3e97 --- /dev/null +++ b/.changeset/update-donation-links.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Updated Support links to point to https://opencollective.com/sable From d6def47b4d82473acbbdda895f5d55f6e3285d19 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 03:15:48 +0000 Subject: [PATCH 26/26] chore: prepare release 1.14.0 --- .changeset/add_msc4095_displaying.md | 5 --- ...nge-code-block-highlighting-to-arborium.md | 5 --- .changeset/feat-add-DM-statuses.md | 5 --- .changeset/feat-add-custom-DM-looks.md | 5 --- .changeset/feat-add-statuses-in-Members.md | 5 --- .changeset/feat-add-theme-specific-colors.md | 5 --- .changeset/feat-collpase-folder-setting.md | 5 --- .changeset/feat-dismiss-local-echo.md | 5 --- .changeset/feat-thread-enhancements.md | 5 --- .changeset/fix-audio-file-description.md | 5 --- .changeset/fix-bug-report-modal-overflow.md | 5 --- .changeset/fix-dms-nav-not-naving.md | 5 --- .changeset/fix-focus-capture-reply.md | 5 --- .changeset/fix-formatted-body-linkify.md | 5 --- .changeset/fix-hidden-names.md | 5 --- .../fix-html-formatting-on-long-messages.md | 5 --- .changeset/fix-ios-overscroll.md | 5 --- .../fix-pmp-encrypted-sticky-scrolling.md | 5 --- .../fix-timeline-blank-on-foreground.md | 5 --- .changeset/pr-602-centered-zoom.md | 5 --- .changeset/pr-602-multiplicative-zoom.md | 5 --- .changeset/pr-602-zoom-buttons.md | 5 --- .changeset/remove-right-click-drag.md | 5 --- .changeset/settings-links.md | 5 --- .changeset/settings-route-based-navigation.md | 5 --- .changeset/update-donation-links.md | 5 --- CHANGELOG.md | 34 +++++++++++++++++++ package.json | 2 +- 28 files changed, 35 insertions(+), 131 deletions(-) delete mode 100644 .changeset/add_msc4095_displaying.md delete mode 100644 .changeset/change-code-block-highlighting-to-arborium.md delete mode 100644 .changeset/feat-add-DM-statuses.md delete mode 100644 .changeset/feat-add-custom-DM-looks.md delete mode 100644 .changeset/feat-add-statuses-in-Members.md delete mode 100644 .changeset/feat-add-theme-specific-colors.md delete mode 100644 .changeset/feat-collpase-folder-setting.md delete mode 100644 .changeset/feat-dismiss-local-echo.md delete mode 100644 .changeset/feat-thread-enhancements.md delete mode 100644 .changeset/fix-audio-file-description.md delete mode 100644 .changeset/fix-bug-report-modal-overflow.md delete mode 100644 .changeset/fix-dms-nav-not-naving.md delete mode 100644 .changeset/fix-focus-capture-reply.md delete mode 100644 .changeset/fix-formatted-body-linkify.md delete mode 100644 .changeset/fix-hidden-names.md delete mode 100644 .changeset/fix-html-formatting-on-long-messages.md delete mode 100644 .changeset/fix-ios-overscroll.md delete mode 100644 .changeset/fix-pmp-encrypted-sticky-scrolling.md delete mode 100644 .changeset/fix-timeline-blank-on-foreground.md delete mode 100644 .changeset/pr-602-centered-zoom.md delete mode 100644 .changeset/pr-602-multiplicative-zoom.md delete mode 100644 .changeset/pr-602-zoom-buttons.md delete mode 100644 .changeset/remove-right-click-drag.md delete mode 100644 .changeset/settings-links.md delete mode 100644 .changeset/settings-route-based-navigation.md delete mode 100644 .changeset/update-donation-links.md diff --git a/.changeset/add_msc4095_displaying.md b/.changeset/add_msc4095_displaying.md deleted file mode 100644 index a8b83ed00..000000000 --- a/.changeset/add_msc4095_displaying.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add support for rendering bundled urls per MSC4095 diff --git a/.changeset/change-code-block-highlighting-to-arborium.md b/.changeset/change-code-block-highlighting-to-arborium.md deleted file mode 100644 index 1071ef3dc..000000000 --- a/.changeset/change-code-block-highlighting-to-arborium.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Improve code blocks with faster, more accurate syntax highlighting, broader language support, and separate light and dark theme options. diff --git a/.changeset/feat-add-DM-statuses.md b/.changeset/feat-add-DM-statuses.md deleted file mode 100644 index 55e0aa3be..000000000 --- a/.changeset/feat-add-DM-statuses.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add statuses to DMs diff --git a/.changeset/feat-add-custom-DM-looks.md b/.changeset/feat-add-custom-DM-looks.md deleted file mode 100644 index a2df236d5..000000000 --- a/.changeset/feat-add-custom-DM-looks.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add custom DM images and descriptions diff --git a/.changeset/feat-add-statuses-in-Members.md b/.changeset/feat-add-statuses-in-Members.md deleted file mode 100644 index 9ea6f93ce..000000000 --- a/.changeset/feat-add-statuses-in-Members.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add statuses to Member Tile diff --git a/.changeset/feat-add-theme-specific-colors.md b/.changeset/feat-add-theme-specific-colors.md deleted file mode 100644 index 1ad50e322..000000000 --- a/.changeset/feat-add-theme-specific-colors.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add the ability to set Global Name Colors dependent on the theme (dark/light) diff --git a/.changeset/feat-collpase-folder-setting.md b/.changeset/feat-collpase-folder-setting.md deleted file mode 100644 index b49339c45..000000000 --- a/.changeset/feat-collpase-folder-setting.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add a setting to collapse sidebar folders by default. diff --git a/.changeset/feat-dismiss-local-echo.md b/.changeset/feat-dismiss-local-echo.md deleted file mode 100644 index 4fa2adbb4..000000000 --- a/.changeset/feat-dismiss-local-echo.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Add a "Dismiss" button to command response messages. diff --git a/.changeset/feat-thread-enhancements.md b/.changeset/feat-thread-enhancements.md deleted file mode 100644 index b2532c19c..000000000 --- a/.changeset/feat-thread-enhancements.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Update threads: various fixes, browse all room threads, and see live reply counts on messages. diff --git a/.changeset/fix-audio-file-description.md b/.changeset/fix-audio-file-description.md deleted file mode 100644 index 89710332a..000000000 --- a/.changeset/fix-audio-file-description.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Use file name instead of "a voice message" for non-voice audio files. diff --git a/.changeset/fix-bug-report-modal-overflow.md b/.changeset/fix-bug-report-modal-overflow.md deleted file mode 100644 index c37f218a7..000000000 --- a/.changeset/fix-bug-report-modal-overflow.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Constrain bug report modal to viewport height to prevent overflow. diff --git a/.changeset/fix-dms-nav-not-naving.md b/.changeset/fix-dms-nav-not-naving.md deleted file mode 100644 index 2e214e4a8..000000000 --- a/.changeset/fix-dms-nav-not-naving.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix dms navigation not navigating to dms when local storage is messed up. diff --git a/.changeset/fix-focus-capture-reply.md b/.changeset/fix-focus-capture-reply.md deleted file mode 100644 index 30b559f9c..000000000 --- a/.changeset/fix-focus-capture-reply.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix reply button not capturing editor focus. diff --git a/.changeset/fix-formatted-body-linkify.md b/.changeset/fix-formatted-body-linkify.md deleted file mode 100644 index cbd310aba..000000000 --- a/.changeset/fix-formatted-body-linkify.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fixes links not being clickable in formatted messages, including messages that use abbreviations. diff --git a/.changeset/fix-hidden-names.md b/.changeset/fix-hidden-names.md deleted file mode 100644 index b3aa8fb1a..000000000 --- a/.changeset/fix-hidden-names.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix some zero-width (invisible) names diff --git a/.changeset/fix-html-formatting-on-long-messages.md b/.changeset/fix-html-formatting-on-long-messages.md deleted file mode 100644 index 2a34189b0..000000000 --- a/.changeset/fix-html-formatting-on-long-messages.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Re-introduced custom HTML formatting for long messages diff --git a/.changeset/fix-ios-overscroll.md b/.changeset/fix-ios-overscroll.md deleted file mode 100644 index 02b02f246..000000000 --- a/.changeset/fix-ios-overscroll.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix iOS elastic bounce-back overscroll on the root element. diff --git a/.changeset/fix-pmp-encrypted-sticky-scrolling.md b/.changeset/fix-pmp-encrypted-sticky-scrolling.md deleted file mode 100644 index df6d3b941..000000000 --- a/.changeset/fix-pmp-encrypted-sticky-scrolling.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fixed the "sticky scrolling" issue in encrypted rooms with many PMP messages. diff --git a/.changeset/fix-timeline-blank-on-foreground.md b/.changeset/fix-timeline-blank-on-foreground.md deleted file mode 100644 index a214a478f..000000000 --- a/.changeset/fix-timeline-blank-on-foreground.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix blank room timeline when app returns from background. When sliding sync delivers an `initial: true` response for the open room, a `TimelineReset` event now correctly shows skeleton placeholders while events reload instead of leaving an empty view. diff --git a/.changeset/pr-602-centered-zoom.md b/.changeset/pr-602-centered-zoom.md deleted file mode 100644 index 35c1a550e..000000000 --- a/.changeset/pr-602-centered-zoom.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Image zooming is now centered on the cursor position diff --git a/.changeset/pr-602-multiplicative-zoom.md b/.changeset/pr-602-multiplicative-zoom.md deleted file mode 100644 index 7a4def730..000000000 --- a/.changeset/pr-602-multiplicative-zoom.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Image zooming is now multiplicative instead of additive, resulting in a consistent "zooming speed". diff --git a/.changeset/pr-602-zoom-buttons.md b/.changeset/pr-602-zoom-buttons.md deleted file mode 100644 index 3c5ab5df6..000000000 --- a/.changeset/pr-602-zoom-buttons.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Image zoom buttons now zoom towards the center of the screen diff --git a/.changeset/remove-right-click-drag.md b/.changeset/remove-right-click-drag.md deleted file mode 100644 index 1627565d1..000000000 --- a/.changeset/remove-right-click-drag.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Right clicks no longer drag images in the viewer. diff --git a/.changeset/settings-links.md b/.changeset/settings-links.md deleted file mode 100644 index 7e36f2cc7..000000000 --- a/.changeset/settings-links.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -You can now share direct links to specific settings, and opening one takes you to the right section and highlights the target option. diff --git a/.changeset/settings-route-based-navigation.md b/.changeset/settings-route-based-navigation.md deleted file mode 100644 index ff0abe0cb..000000000 --- a/.changeset/settings-route-based-navigation.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -Settings now use route-based navigation with improved desktop and mobile behavior, including better back and close handling. diff --git a/.changeset/update-donation-links.md b/.changeset/update-donation-links.md deleted file mode 100644 index 3d68d3e97..000000000 --- a/.changeset/update-donation-links.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Updated Support links to point to https://opencollective.com/sable diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d0dbcb8e..5695f023c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ # Sable Client Changelog +## 1.14.0 (2026-04-10) + +### Features + +* Add support for rendering bundled urls per MSC4095 ([#590](https://github.com/SableClient/Sable/pull/590) by @nushea) +* Improve code blocks with faster, more accurate syntax highlighting, broader language support, and separate light and dark theme options. ([#576](https://github.com/SableClient/Sable/pull/576) by @hazre) +* Add statuses to DMs ([#644](https://github.com/SableClient/Sable/pull/644) by @nushea) +* Add custom DM images and descriptions ([#644](https://github.com/SableClient/Sable/pull/644) by @nushea) +* Add statuses to Member Tile ([#644](https://github.com/SableClient/Sable/pull/644) by @nushea) +* Add the ability to set Global Name Colors dependent on the theme (dark/light) ([#656](https://github.com/SableClient/Sable/pull/656) by @nushea) +* Add a setting to collapse sidebar folders by default. ([#624](https://github.com/SableClient/Sable/pull/624) by @7w1) +* Add a "Dismiss" button to command response messages. ([#625](https://github.com/SableClient/Sable/pull/625) by @7w1) +* Update threads: various fixes, browse all room threads, and see live reply counts on messages. ([#564](https://github.com/SableClient/Sable/pull/564) by @Just-Insane) +* Re-introduced custom HTML formatting for long messages ([#641](https://github.com/SableClient/Sable/pull/641) by @Septicity) +* You can now share direct links to specific settings, and opening one takes you to the right section and highlights the target option. ([#577](https://github.com/SableClient/Sable/pull/577) by @hazre) +* Settings now use route-based navigation with improved desktop and mobile behavior, including better back and close handling. ([#577](https://github.com/SableClient/Sable/pull/577) by @hazre) + +### Fixes + +* Use file name instead of "a voice message" for non-voice audio files. ([#651](https://github.com/SableClient/Sable/pull/651) by @mvanhorn) +* Constrain bug report modal to viewport height to prevent overflow. ([#652](https://github.com/SableClient/Sable/pull/652) by @mvanhorn) +* Fix dms navigation not navigating to dms when local storage is messed up. ([#653](https://github.com/SableClient/Sable/pull/653) by @7w1) +* Fix reply button not capturing editor focus. ([#623](https://github.com/SableClient/Sable/pull/623) by @7w1) +* Fixes links not being clickable in formatted messages, including messages that use abbreviations. ([#632](https://github.com/SableClient/Sable/pull/632) by @hazre) +* Fix some zero-width (invisible) names ([#640](https://github.com/SableClient/Sable/pull/640) by @nushea) +* Fix iOS elastic bounce-back overscroll on the root element. ([#650](https://github.com/SableClient/Sable/pull/650) by @mvanhorn) +* Fixed the "sticky scrolling" issue in encrypted rooms with many PMP messages. ([#626](https://github.com/SableClient/Sable/pull/626) by @Septicity) +* Fix blank room timeline when app returns from background. When sliding sync delivers an `initial: true` response for the open room, a `TimelineReset` event now correctly shows skeleton placeholders while events reload instead of leaving an empty view. ([#657](https://github.com/SableClient/Sable/pull/657) by @Just-Insane) +* Image zooming is now centered on the cursor position ([#602](https://github.com/SableClient/Sable/pull/602) by @mini-bomba) +* Image zooming is now multiplicative instead of additive, resulting in a consistent "zooming speed". ([#602](https://github.com/SableClient/Sable/pull/602) by @mini-bomba) +* Image zoom buttons now zoom towards the center of the screen ([#602](https://github.com/SableClient/Sable/pull/602) by @mini-bomba) +* Right clicks no longer drag images in the viewer. ([#620](https://github.com/SableClient/Sable/pull/620) by @Septicity) +* Updated Support links to point to https://opencollective.com/sable ([#661](https://github.com/SableClient/Sable/pull/661) by @7w1) + ## 1.13.1 (2026-03-30) ### Fixes diff --git a/package.json b/package.json index cab220bb1..980aa4b64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sable", - "version": "1.13.1", + "version": "1.14.0", "description": "An almost stable Matrix client", "type": "module", "packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",