From 85682ac37f4b8b56b99fc23980ec2175af6636b9 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 10 Oct 2024 14:43:48 +0200 Subject: [PATCH] chore(timeline): add extra logs to investigate edit issues --- crates/matrix-sdk-ui/src/timeline/controller/mod.rs | 2 +- crates/matrix-sdk-ui/src/timeline/event_handler.rs | 3 +++ .../src/timeline/event_item/content/message.rs | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/controller/mod.rs b/crates/matrix-sdk-ui/src/timeline/controller/mod.rs index 9095a9493..ba23ab6e5 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/mod.rs @@ -812,7 +812,7 @@ impl TimelineController

{ } } - warn!("Timeline item not found, can't add event ID"); + warn!("Timeline item not found, can't update send state"); return; }; diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index 0550ea941..116103052 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -523,6 +523,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { let Some(message) = event_item.content.as_message() else { return }; let Some(in_reply_to) = message.in_reply_to() else { return }; if replacement.event_id == in_reply_to.event_id { + trace!(reply_event_id = ?event_item.identifier(), "Updating response to edited event"); let in_reply_to = InReplyToDetails { event_id: in_reply_to.event_id.clone(), event: TimelineDetails::Ready(Box::new( @@ -554,6 +555,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { } /// Try to stash a pending edit, if it makes sense to do so. + #[instrument(skip(self, replacement))] fn stash_pending_edit( &mut self, position: TimelineItemPosition, @@ -604,6 +606,7 @@ impl<'a, 'o> TimelineEventHandler<'a, 'o> { event_id: &EventId, ) -> Option { let pos = edits.iter().position(|edit| edit.edited_event() == event_id)?; + trace!(edited_event = %event_id, "unstashed pending edit"); Some(edits.remove(pos).unwrap()) } diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/content/message.rs b/crates/matrix-sdk-ui/src/timeline/event_item/content/message.rs index 1c232e9a5..4e361e386 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/content/message.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/content/message.rs @@ -37,7 +37,7 @@ use ruma::{ serde::Raw, OwnedEventId, OwnedUserId, RoomVersionId, UserId, }; -use tracing::error; +use tracing::{error, trace}; use super::TimelineItemContent; use crate::{ @@ -99,6 +99,7 @@ impl Message { /// Apply an edit to the current message. pub(crate) fn apply_edit(&mut self, mut new_content: RoomMessageEventContentWithoutRelation) { + trace!("applying edit to a Message"); // Edit's content is never supposed to contain the reply fallback. new_content.msgtype.sanitize(DEFAULT_SANITIZER_MODE, RemoveReplyFallback::No); self.msgtype = new_content.msgtype; @@ -191,7 +192,10 @@ pub(crate) fn extract_room_msg_edit_content( .content .relates_to { - Some(Relation::Replacement(re)) => Some(re.new_content), + Some(Relation::Replacement(re)) => { + trace!("found a bundled edit event in a room message"); + Some(re.new_content) + } _ => { error!("got m.room.message event with an edit without a valid m.replace relation"); None @@ -215,7 +219,10 @@ pub(crate) fn extract_poll_edit_content( match *relations.replace? { AnySyncMessageLikeEvent::UnstablePollStart(SyncUnstablePollStartEvent::Original(ev)) => { match ev.content { - UnstablePollStartEventContent::Replacement(re) => Some(re.relates_to.new_content), + UnstablePollStartEventContent::Replacement(re) => { + trace!("found a bundled edit event in a poll"); + Some(re.relates_to.new_content) + } _ => { error!("got new poll start event in a bundled edit"); None