From 8eef74ef04968bf89d61d86eae7f4fa89524e465 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 9 Mar 2026 01:28:14 +0100 Subject: [PATCH 1/2] enhance UnsupportedContent and BrokenContent to display message body for better context --- src/app/components/RenderMessageContent.tsx | 2 +- .../components/message/MsgTypeRenderers.tsx | 36 ++++++++++++------- .../message/content/FallbackContent.tsx | 33 ++++++++++------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index 3c2ded07..93a697c6 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -366,7 +366,7 @@ function RenderMessageContentInternal({ mentionedUserIds={content?.['m.mentions']?.user_ids} /> ); - return ; + return ; } export const RenderMessageContent = memo(RenderMessageContentInternal); diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 66656f94..97daa9cb 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -52,18 +52,22 @@ export function RedactedContent({ reason }: RedactedContentProps) { ); } -export function UnsupportedContent() { +type BrokenContentProps = { + body?: string; +}; + +export function UnsupportedContent({ body }: BrokenContentProps) { return ( - + ); } -export function BrokenContent() { +export function BrokenContent({ body }: BrokenContentProps) { return ( - + ); } @@ -117,7 +121,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }: return true; }, [trimmedBody, safeCustomBody]); - if (!body) return ; + if (!body) return ; const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG); const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined; @@ -170,7 +174,9 @@ export function MEmote({ const { body, formatted_body: customBody } = content; const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize'); - if (typeof body !== 'string') return ; + if (typeof body !== 'string') { + return ; + } const trimmedBody = trimReplyFromBody(body); const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG); const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined; @@ -205,7 +211,9 @@ export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNot const { body, formatted_body: customBody } = content; const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize'); - if (typeof body !== 'string') return ; + if (typeof body !== 'string') { + return ; + } const trimmedBody = trimReplyFromBody(body); const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG); const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined; @@ -248,7 +256,7 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) { const imgInfo = content?.info; const mxcUrl = content.file?.url ?? content.url; if (typeof mxcUrl !== 'string') { - return ; + return ; } const MAX_SIZE = 400; const imgW = imgInfo?.w ?? MAX_SIZE; @@ -310,7 +318,7 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }: if (mxcUrl) { return renderAsFile(); } - return ; + return ; } const height = Math.min(scaleYDimension(videoInfo.w || 400, 400, videoInfo.h || 400), 400); @@ -379,7 +387,7 @@ export function MAudio({ content, renderAsFile, renderAudioContent, outlined }: if (mxcUrl) { return renderAsFile(); } - return ; + return ; } const filename = content.filename ?? content.body ?? 'Audio'; @@ -430,7 +438,7 @@ export function MFile({ content, renderFileContent, outlined }: MFileProps) { const mxcUrl = content.file?.url ?? content.url; if (typeof mxcUrl !== 'string') { - return ; + return ; } return ( @@ -461,7 +469,9 @@ type MLocationProps = { }; export function MLocation({ content }: MLocationProps) { const geoUri = content.geo_uri; - if (typeof geoUri !== 'string') return ; + if (typeof geoUri !== 'string') { + return ; + } const location = parseGeoUri(geoUri); return ( @@ -490,7 +500,7 @@ export function MSticker({ content, renderImageContent }: MStickerProps) { const imgInfo = content?.info; const mxcUrl = content.file?.url ?? content.url; if (typeof mxcUrl !== 'string') { - return ; + return ; } const height = scaleYDimension(imgInfo?.w || 152, 152, imgInfo?.h || 152); diff --git a/src/app/components/message/content/FallbackContent.tsx b/src/app/components/message/content/FallbackContent.tsx index 8156a5d0..9bd012a1 100644 --- a/src/app/components/message/content/FallbackContent.tsx +++ b/src/app/components/message/content/FallbackContent.tsx @@ -16,12 +16,16 @@ export const MessageDeletedContent = as<'div', { children?: never; reason?: stri ) ); -export const MessageUnsupportedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - - - Unsupported message - -)); +export const MessageUnsupportedContent = as<'div', { children?: never; body?: string }>( + ({ body, ...props }, ref) => ( + + + Unsupported message + {body && `: ${body}`} + {!body && ' (no body)'} + + ) +); export const MessageFailedContent = as<'div', { children?: never }>(({ ...props }, ref) => ( @@ -44,12 +48,17 @@ export const MessageNotDecryptedContent = as<'div', { children?: never }>(({ ... )); -export const MessageBrokenContent = as<'div', { children?: never }>(({ ...props }, ref) => ( - - - Broken message - -)); +// display body of the message if it is available, as it may give some clue about why the message is broken +export const MessageBrokenContent = as<'div', { children?: never; body?: string }>( + ({ body, ...props }, ref) => ( + + + Broken message + {body && `: ${body}`} + {!body && ' (no body)'} + + ) +); export const MessageEmptyContent = as<'div', { children?: never }>(({ ...props }, ref) => ( From 1874524f5bfeba4d18ce2c6fe361940d3d68c017 Mon Sep 17 00:00:00 2001 From: Rose Date: Mon, 9 Mar 2026 01:39:21 +0100 Subject: [PATCH 2/2] added changeset for https://github.com/7w1/sable/pull/267 Enhance the UnsupportedContent and BrokenContent components to include a message body for better user feedback. --- ...ortedcontent_and_brokencontent_to_display_message_body.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/enhance_unsupportedcontent_and_brokencontent_to_display_message_body.md diff --git a/.changeset/enhance_unsupportedcontent_and_brokencontent_to_display_message_body.md b/.changeset/enhance_unsupportedcontent_and_brokencontent_to_display_message_body.md new file mode 100644 index 00000000..983247a2 --- /dev/null +++ b/.changeset/enhance_unsupportedcontent_and_brokencontent_to_display_message_body.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Enhance UnsupportedContent and BrokenContent to display message body