From 2cf5b8382cb3159657318036b2eebd4475a1cb43 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Wed, 4 Mar 2026 19:24:01 -0500 Subject: [PATCH] fix: improve message send UX - Remove 'Sending...' text from pending messages; text is now dimmed via opacity while in-flight to reduce timeline jump - Add 'Delete' button alongside 'Retry' on failed sends, using mx.cancelPendingEvent for client-side removal - Clear the input box immediately on send rather than waiting for the network round-trip to complete --- src/app/features/room/RoomInput.tsx | 8 +++----- src/app/features/room/RoomTimeline.tsx | 11 +++++++++++ src/app/features/room/message/Message.tsx | 24 ++++++++++++++++------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 3c2ca181..abd46d49 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -499,12 +499,10 @@ export const RoomInput = forwardRef( // Cancel failed — leave state intact for retry } } else { - try { - await mx.sendMessage(roomId, content as any); - } catch (error) { - log.error('failed to send message', { roomId }, error); - } resetInput(); + mx.sendMessage(roomId, content as any).catch((error: unknown) => { + log.error('failed to send message', { roomId }, error); + }); } }, [ mx, diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index c153ab52..f9a652c5 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -1197,6 +1197,14 @@ export function RoomTimeline({ [mx, room] ); + const handleDeleteFailedSend = useCallback( + (mEvent: MatrixEvent) => { + if (mEvent.getAssociatedStatus() !== EventStatus.NOT_SENT) return; + mx.cancelPendingEvent(mEvent); + }, + [mx] + ); + const handleEdit = useCallback( (editEvtId?: string) => { if (editEvtId) { @@ -1269,6 +1277,7 @@ export function RoomTimeline({ senderDisplayName={senderDisplayName} sendStatus={mEvent.getAssociatedStatus()} onResend={handleResend} + onDeleteFailedSend={handleDeleteFailedSend} onEditId={handleEdit} activeReplyId={activeReplyId} reply={ @@ -1356,6 +1365,7 @@ export function RoomTimeline({ senderDisplayName={senderDisplayName} sendStatus={mEvent.getAssociatedStatus()} onResend={handleResend} + onDeleteFailedSend={handleDeleteFailedSend} reply={ replyEventId && ( void; + onDeleteFailedSend?: (event: MatrixEvent) => void; }; function useMobileDoubleTap(callback: () => void, delay = 300) { @@ -308,6 +309,7 @@ function MessageInternal( activeReplyId, sendStatus, onResend, + onDeleteFailedSend, ...props }: MessageProps & { className?: string; children?: ReactNode }, ref: any @@ -445,6 +447,7 @@ function MessageInternal( sendStatus === EventStatus.SENDING; const isFailedSend = sendStatus === EventStatus.NOT_SENT; const canResend = isFailedSend && senderId === mx.getUserId() && !!onResend; + const canDeleteFailedSend = isFailedSend && senderId === mx.getUserId() && !!onDeleteFailedSend; const handleResendClick: MouseEventHandler = useCallback( (evt) => { @@ -455,6 +458,15 @@ function MessageInternal( [mEvent, onResend] ); + const handleDeleteFailedSendClick: MouseEventHandler = useCallback( + (evt) => { + evt.preventDefault(); + evt.stopPropagation(); + onDeleteFailedSend?.(mEvent); + }, + [mEvent, onDeleteFailedSend] + ); + const MSG_CONTENT_STYLE = { maxWidth: '100%' }; const msgContentJSX = ( @@ -484,13 +496,6 @@ function MessageInternal( {children} )} {reactions} - {isPendingSend && ( - - - Sending... - - - )} {isFailedSend && ( @@ -501,6 +506,11 @@ function MessageInternal( Retry )} + {canDeleteFailedSend && ( + + )} )}