Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting threads by most recently responded to #152

Closed
clokep opened this issue Feb 17, 2022 · 3 comments
Closed

Sorting threads by most recently responded to #152

clokep opened this issue Feb 17, 2022 · 3 comments
Assignees

Comments

@clokep
Copy link
Contributor

clokep commented Feb 17, 2022

It is currently difficult for clients to sort threads by the most recently responded to. Clients use the /messages API with a filter of "relation_types": ["m.thread"] to fetch the list of threads in a room. This returns the root thread events in topological order of those events (either forwards or backwards depending on the dir parameter). Note that each event also includes bundled aggregation, which will include the latest event in each thread.

In order to sort threads by the latest event this requires clients to paginate all of the threads in the room, inspect the latest event from the bundled aggregation and attempt to sort by something. There's two issues with this approach:

  1. Using information available to clients (e.g. age or origin_server_ts) doesn't result in the proper ordering (?)
  2. It requires pulling all threads in a room, which can result in many round trips to the server as it requires paginating the entire results.

Ideally the /messages API could return the results in the expected order, by sorting by the latest thread relation message before returning the events.

Potential work breakdown

  1. Write an MSC describing this behavior.
  2. Implement the MSC in Synapse.
  3. Implement the MSC in clients.
@clokep
Copy link
Contributor Author

clokep commented Mar 21, 2022

From some discussion elsewhere -- there aren't any APIs in Matrix where a client can modify the sort order of the results (except reversing the result via backwards/forwards flags). This makes one wonder if it would be better to provide a separate API for this.

Technically this may be interesting as the server will need to track room ID -> thread roots -> latest event in thread. Hopefully that can be pulled out from the existing data, however!

@t3chguy
Copy link
Member

t3chguy commented Apr 22, 2022

I wonder how this will work given the order will be constantly changing, due to redactions and new threads responses coming in, so backpaginating this custom ordered mixed timeline may race with /sync bringing in new events causing order confusion

@clokep
Copy link
Contributor Author

clokep commented Sep 27, 2022

Another meta issue was filed for this, see #195. I'm closing this and opening a separate Synapse one: matrix-org/synapse#13921.

@clokep clokep closed this as completed Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants