From f867a5b5787d97cd394ab06910b71c7914287218 Mon Sep 17 00:00:00 2001 From: Lotus Bot Date: Thu, 21 May 2026 12:07:42 -0400 Subject: [PATCH] fix(perf): hoist lotusTerminal setting out of Message component (Perf-10) Previously every visible Message subscribed to settingsAtom via useSetting, creating O(80) active atom subscriptions. Now RoomTimeline reads it once and passes it down as a prop, reducing subscriptions to 1. Co-Authored-By: Claude Sonnet 4.6 --- src/app/features/room/RoomTimeline.tsx | 2 ++ src/app/features/room/message/Message.tsx | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 466f0caf4..bab2656fa 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -452,6 +452,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview; const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools'); + const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal'); const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock'); const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString'); @@ -1112,6 +1113,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli legacyUsernameColor={legacyUsernameColor || direct} hour24Clock={hour24Clock} dateFormatString={dateFormatString} + lotusTerminal={!!lotusTerminal} > {mEvent.isRedacted() ? ( diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 44fe99a28..b8e714225 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -726,6 +726,7 @@ export type MessageProps = { legacyUsernameColor?: boolean; hour24Clock: boolean; dateFormatString: string; + lotusTerminal?: boolean; }; export const Message = React.memo(as<'div', MessageProps>( ( @@ -757,6 +758,7 @@ export const Message = React.memo(as<'div', MessageProps>( legacyUsernameColor, hour24Clock, dateFormatString, + lotusTerminal: lotusTerminalProp, children, ...props }, @@ -770,7 +772,7 @@ export const Message = React.memo(as<'div', MessageProps>( ? [] : (readPositions.get(mEvent.getId() ?? '') ?? []); const isMine = mEvent.getSender() === mx.getUserId(); - const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal'); + const lotusTerminal = lotusTerminalProp; const [hover, setHover] = useState(false); const { hoverProps } = useHover({ onHoverChange: setHover });