Skip to content

feat(edit): Add edit revisions list#6630

Open
bxdxnn wants to merge 5 commits into
matrix-org:mainfrom
bxdxnn:edit-revisions
Open

feat(edit): Add edit revisions list#6630
bxdxnn wants to merge 5 commits into
matrix-org:mainfrom
bxdxnn:edit-revisions

Conversation

@bxdxnn

@bxdxnn bxdxnn commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Add a new revisions field for timeline items that stores the history of the item.
Rust part of element-hq/element-meta#2573

  • I've documented the public API changes in the appropriate changelog files
    (see Writing changelog entries).
  • This PR was made with the help of AI.

Signed-off-by: bxdxnn 267911624+bxdxnn@users.noreply.github.com

@bxdxnn bxdxnn requested a review from a team as a code owner June 1, 2026 13:46
@bxdxnn bxdxnn requested review from Hywan and removed request for a team June 1, 2026 13:46
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@codspeed-hq

codspeed-hq Bot commented Jun 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing bxdxnn:edit-revisions (fb4abc1) with main (e8673e4)

Open in CodSpeed

@bxdxnn bxdxnn force-pushed the edit-revisions branch 4 times, most recently from e97032f to 1a1352c Compare June 1, 2026 15:14
@bxdxnn

This comment was marked as outdated.

@Hywan Hywan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Thanks for your contributions.

There is an annoying design issue with your proposal. Doing that on the Timeline means it only works on in-memory events: it misses all the events we have in the database and that are not loaded yet in the Timeline yet.

This feature should instead be implemented on the Event Cache, where we have methods like find_events_with_relations that can be used to retrieve all events related to a particular event, such as: all edits for event $e$. Maybe there is nothing to do on the Event Cache: maybe adding a method on an EventTimelineItem to retrieve all edits for a particular event would be the best way to approach this.

I think it's a better approach to the problem.

Also, please, add tests.

Thoughts?

Signed-off-by: bxdxnn <267911624+bxdxnn@users.noreply.github.com>
@bxdxnn

bxdxnn commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, still learning how the SDK works. Yes, I agree, makes more sense.

Rewrote the implementation

Comment on lines +313 to +314
if let Some(content) = TimelineItemContent::from_event(room, original_event).await {
revisions.push(EditRevision {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keeping TimelineItemContent directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we also need the timestamp of the event, TimelineItemContent doesn't provide it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we manipulate a TimelineItem directly then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimelineItem is pretty heavy and also has a lot of irrelevant info

Comment thread crates/matrix-sdk-ui/src/timeline/mod.rs Outdated
Comment thread crates/matrix-sdk-ui/src/timeline/mod.rs Outdated

@Hywan Hywan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are almost good!

Comment thread crates/matrix-sdk-ui/src/timeline/mod.rs Outdated

let timeline = room.timeline().await.unwrap();

let revisions = timeline.edit_revisions(event_id!("$nonexistent")).await.unwrap();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it wouldn't better to have edit_revisions on a TimelineItem instead of Timeline? cc @stefanceriu @jmartinesp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case, the timeline items are mapped to record types ASAP, so having to hold to the original item is difficult. It's simpler to have it on Timeline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked a summary from an LLM previously and it seems to be not worth it, but that's up to you as I don't really understand the logic between components ATM.

Co-authored-by: Ivan Enderlin <ivan@mnt.io>
Signed-off-by: bxdxnn <267911624+bxdxnn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants