From d1ae1d459431bd1cc74878c30a1c16449b47a931 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 5 Mar 2026 21:25:48 -0500 Subject: [PATCH 1/2] fix(notifications): show rich body in banner; fix encrypted msg dedup - Add early-return guard for m.room.encrypted in MessageNotifications so eventId is never added to notifiedEventsRef before decryption. Without this, the post-decryption re-emission was deduped and the banner showed "Encrypted Message" instead of actual content. - Build ReactNode bodyNode via getReactCustomHtmlParser + parse + sanitizeCustomHtml for org.matrix.custom.html messages, mirroring the timeline renderer pipeline (mxc images, mentions, etc.). - Add bodyNode?: ReactNode to InAppBannerNotification type. - Add BodyNode component in NotificationBanner; falls back to existing plain-text BodyText path when bodyNode is absent. --- .../NotificationBanner.css.ts | 9 +++++- .../NotificationBanner.tsx | 28 +++++++++++++++-- src/app/pages/client/ClientNonUIFeatures.tsx | 31 +++++++++++++++++++ src/app/state/sessions.ts | 6 ++++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/app/components/notification-banner/NotificationBanner.css.ts b/src/app/components/notification-banner/NotificationBanner.css.ts index 80c3617f..1ddfacda 100644 --- a/src/app/components/notification-banner/NotificationBanner.css.ts +++ b/src/app/components/notification-banner/NotificationBanner.css.ts @@ -110,11 +110,18 @@ export const BannerRoomName = style({ }); // Caps tall previews and fades the bottom edge when content overflows. +// Desktop: 25vh, mobile (≤768px): 35vh. export const BannerBody = style({ position: 'relative', - maxHeight: toRem(56), + maxHeight: '25vh', overflow: 'hidden', + '@media': { + '(max-width: 768px)': { + maxHeight: '35vh', + }, + }, + selectors: { '&[data-overflow=true]::after': { content: '""', diff --git a/src/app/components/notification-banner/NotificationBanner.tsx b/src/app/components/notification-banner/NotificationBanner.tsx index ad0ba026..666ec077 100644 --- a/src/app/components/notification-banner/NotificationBanner.tsx +++ b/src/app/components/notification-banner/NotificationBanner.tsx @@ -1,5 +1,5 @@ import { useAtom } from 'jotai'; -import { useCallback, useEffect, useRef, useState } from 'react'; +import { ReactNode, useCallback, useEffect, useRef, useState } from 'react'; import { Box, Icon, IconButton, Icons, Text } from 'folds'; import { inAppBannerAtom, InAppBannerNotification } from '$state/sessions'; import * as css from './NotificationBanner.css'; @@ -26,6 +26,26 @@ function BodyText({ text, hovered }: { text: string; hovered: boolean }) { ); } +// Same as BodyText but renders a pre-built ReactNode (rich HTML with mxc/mention transforms). +function BodyNode({ node, hovered }: { node: ReactNode; hovered: boolean }) { + const ref = useRef(null); + const [overflow, setOverflow] = useState(false); + + useEffect(() => { + const el = ref.current; + if (!el) return; + setOverflow(el.scrollHeight > el.clientHeight); + }, [node]); + + return ( +
+ + {node} + +
+ ); +} + type BannerItemProps = { notification: InAppBannerNotification; onDismiss: (id: string) => void; @@ -115,7 +135,11 @@ function BannerItem({ notification, onDismiss }: BannerItemProps) { )} - {notification.body && } + {notification.bodyNode ? ( + + ) : ( + notification.body && + )} { window.focus(); diff --git a/src/app/state/sessions.ts b/src/app/state/sessions.ts index 10a4ff3b..aadf20ce 100644 --- a/src/app/state/sessions.ts +++ b/src/app/state/sessions.ts @@ -1,3 +1,4 @@ +import { ReactNode } from 'react'; import { atom } from 'jotai'; import { createLogger } from '$utils/debug'; import { @@ -185,6 +186,11 @@ export type InAppBannerNotification = { /** Display name of the sender. */ senderName?: string; body?: string; + /** + * Pre-rendered rich body with mxc/mention transforms (built in ClientNonUIFeatures). + * When present, takes precedence over the plain-text `body` fallback. + */ + bodyNode?: ReactNode; /** URL of an avatar or room icon to display inside the banner. */ icon?: string; onClick: () => void; From b4de2a835a42d457785545046667d2867e45c20a Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Thu, 5 Mar 2026 21:50:54 -0500 Subject: [PATCH 2/2] chore: add changeset for notification banner rich body fix --- .changeset/notification_banner_rich_body.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/notification_banner_rich_body.md diff --git a/.changeset/notification_banner_rich_body.md b/.changeset/notification_banner_rich_body.md new file mode 100644 index 00000000..ec13cbee --- /dev/null +++ b/.changeset/notification_banner_rich_body.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Fixed in-app notification banners in encrypted rooms showing "Encrypted Message" instead of the actual content. Banners now also render rich text (mentions, inline images) using the same pipeline as the timeline renderer.