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

Fix issues with getEventTimeline and thread roots #2444

Merged
merged 6 commits into from
Jun 8, 2022

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Jun 8, 2022

Fixes element-hq/element-web#21613


Here's what your changelog entry will look like:

🐛 Bug Fixes

@t3chguy t3chguy marked this pull request as ready for review June 8, 2022 18:00
@t3chguy t3chguy requested a review from a team as a code owner June 8, 2022 18:00
src/client.ts Outdated Show resolved Hide resolved
@t3chguy t3chguy enabled auto-merge (squash) June 8, 2022 22:04
@t3chguy t3chguy merged commit 8e896c4 into develop Jun 8, 2022
@t3chguy t3chguy deleted the t3chguy/fix/21613v branch June 8, 2022 22:11
@@ -119,13 +120,15 @@ export class EventTimelineSet extends TypedEventEmitter<EmittedEvents, EventTime
* Set to true to enable improved timeline support.
* @param {Object} [opts.filter = null]
* The filter object, if any, for this timelineSet.
* @param {MatrixClient} client the Matrix client which owns this EventTimelineSet,
* @param {MatrixClient=} client the Matrix client which owns this EventTimelineSet,
Copy link
Contributor

@MadLittleMods MadLittleMods Jun 9, 2022

Choose a reason for hiding this comment

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

Is this only necessary for threads? That's the only place we use this functionality. We should add a comment with the reasoning for when this is necessary and the thread use case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its used for the notification timeline (or any without a room) where a client is still necessary but cannot be accessed via room.client

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add that statement to the JSDoc here? It's great context for why we use it.

Comment on lines 130 to +131
client?: MatrixClient,
public readonly thread?: Thread,
Copy link
Contributor

@MadLittleMods MadLittleMods Jun 9, 2022

Choose a reason for hiding this comment

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

Seems like we should put this stuff in opts

We can still assign this.thread = opts.thread in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like we should put this stuff in opts

Why? https://github.com/vector-im/element-meta/pull/216/files doesn't favour it in any way shape or form

Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to defer in favor of the style-guide.

The function signature here is getting pretty complex and we already have opts where this seems like it would fit.

@@ -5245,14 +5245,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* <p>If the EventTimelineSet object already has the given event in its store, the
* corresponding timeline will be returned. Otherwise, a /context request is
* made, and used to construct an EventTimeline.
* If the event does not belong to this EventTimelineSet then undefined will be returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* If the event does not belong to this EventTimelineSet then undefined will be returned.
* If the event does not belong to this EventTimelineSet then undefined will be returned
* (like an `eventId` that doesn't belong in the thread represented by the given `EventTimelineSet`).

direction: Direction.Backward,
limit: 50,
};
if (timelineSet.thread?.id !== threadId) {
Copy link
Contributor

@MadLittleMods MadLittleMods Jun 9, 2022

Choose a reason for hiding this comment

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

A threadRoot returns:

{
    shouldLiveInRoom: true,
    shouldLiveInThread: true,
    threadId: event.getId(),
}

Won't this logic prevent a threadRoot from showing in the main room timeline? undefined !== $abc

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, I think this is the cause of element-hq/element-web#22539

The if check should be timelineSet.thread && timelineSet.thread.id !== threadId

@@ -1,5 +1,5 @@
import * as utils from "../test-utils/test-utils";
Copy link
Contributor

Choose a reason for hiding this comment

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

The title and changelog of this PR is not every descriptive: "Fix issues with getEventTimeline and thread roots". It just describes the code and not what's being fixed.

Potential option:

Fix events from main timeline getting mixed in threads

Copy link
Member Author

Choose a reason for hiding this comment

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

But this does more than that, that's just one symptom it fixes, changelog entries should be relatively short even if that's vague

Copy link
Contributor

@MadLittleMods MadLittleMods Jun 13, 2022

Choose a reason for hiding this comment

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

What other symptoms does it fix? The other problems are all variations of that AFAICT.

The problem is that following the link to this PR from the changelog also doesn't have any of the extra details either.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that following the link to this PR from the changelog also doesn't have any of the extra details either.

Except it does, in the canonical source, the issue it links to

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't "Fix events from main timeline getting mixed in threads" work to describe what this does then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it also stops other effects, like stops an unrelated timeline being returned if you call with a threaded-timelineset and an event id from a diff thread/main timeline

Copy link
Contributor

@MadLittleMods MadLittleMods Jun 13, 2022

Choose a reason for hiding this comment

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

The description and linked issue don't explain this. And my changelog example can be extended to something like:

Fix events from main timeline getting mixed in threads and generally events being mixed across timelines.

Which is way more useful than Fix issues with getEventTimeline and thread roots where thread roots are one of the edge cases that it actually doesn't fix anyway. And doesn't describe the main issue it fixes that everyone is running into in the first place.

I had to decode all of this information from the diff (which is painful) and when I did, I found bugs. The expectations and why were not spelled out in the code or description where we can easily compare how the code behaves to those expectations. One (maybe 2) symptoms are explain in the linked issue.

Copy link
Member Author

@t3chguy t3chguy Jun 13, 2022

Choose a reason for hiding this comment

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

The description and linked issue don't explain this.

Nor do they need to given threads in the js-sdk is marked @experimental

where thread roots are one of the edge cases that it actually doesn't fix anyway.

This isn't true, it fixed the issue for event timeline sets accessing thread roots which caused the issue you were hitting with main timeline events showing up in threads, and created a regression around accessing thread roots from main timeline event timeline sets

Copy link
Contributor

@MadLittleMods MadLittleMods Jun 13, 2022

Choose a reason for hiding this comment

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

Nor do they need to given threads in the js-sdk is marked @experimental

While compromises and known problems are probably part of an @experimental feature, seems like we shouldn't just drop the ball on all of it. I think this problem generally exists in most PR's though. And regardless, our current plan/goal for threads is to make this not experimental where this code is bound to live on.

We should so we can better maintain this. We're not going to remember this fresh context that I am driving for in 6 months when we find another regression. I understand that some of this code will change when we get backend changes to better support threads but that info will just make it easier to refactor this in the future as well to see that we're still maintaining all of the previous behavior plus the extra benefits.

This isn't true, it fixed the issue for event timeline sets accessing thread roots which caused the issue you were hitting with main timeline events showing up in threads, and created a regression around accessing thread roots from main timeline event timeline sets

I see what you mean. This is an example of what we should be explaining though.

su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Jul 7, 2022
* Remove unused sessionStore ([\matrix-org#2455](matrix-org#2455)).
* Implement MSC3827: Filtering of `/publicRooms` by room type ([\matrix-org#2469](matrix-org#2469)).
* expose latestLocationEvent on beacon model ([\matrix-org#2467](matrix-org#2467)). Contributed by @kerryarchibald.
* Live location share - add start time leniency ([\matrix-org#2465](matrix-org#2465)). Contributed by @kerryarchibald.
* Log real errors and not just their messages, traces are useful ([\matrix-org#2464](matrix-org#2464)).
* Various changes to `src/crypto` files for correctness ([\matrix-org#2137](matrix-org#2137)). Contributed by @ShadowJonathan.
* Update MSC3786 implementation: Check the `state_key` ([\matrix-org#2429](matrix-org#2429)).
* Timeline needs to refresh when we see a MSC2716 marker event  ([\matrix-org#2299](matrix-org#2299)). Contributed by @MadLittleMods.
* Try to load keys from key backup when a message fails to decrypt ([\matrix-org#2373](matrix-org#2373)). Fixes element-hq/element-web#21026. Contributed by @duxovni.
* Send call version `1` as a string ([\matrix-org#2471](matrix-org#2471)). Fixes element-hq/element-web#22629.
* Fix issue with `getEventTimeline` returning undefined for thread roots in main timeline ([\matrix-org#2454](matrix-org#2454)). Fixes element-hq/element-web#22539.
* Add missing `type` property on `IAuthData` ([\matrix-org#2463](matrix-org#2463)).
* Clearly indicate that `lastReply` on a Thread can return falsy ([\matrix-org#2462](matrix-org#2462)).
* Fix issues with getEventTimeline and thread roots ([\matrix-org#2444](matrix-org#2444)). Fixes element-hq/element-web#21613.
* Live location sharing - monitor liveness of beacons yet to start ([\matrix-org#2437](matrix-org#2437)). Contributed by @kerryarchibald.
* Refactor Relations to not be per-EventTimelineSet ([\matrix-org#2412](matrix-org#2412)). Fixes matrix-org#2399 and element-hq/element-web#22298.
* Add tests for sendEvent threadId handling ([\matrix-org#2435](matrix-org#2435)). Fixes element-hq/element-web#22433.
* Make sure `encryptAndSendKeysToDevices` assumes devices are unique per-user. ([\matrix-org#2136](matrix-org#2136)). Fixes matrix-org#2135. Contributed by @ShadowJonathan.
* Don't bug the user while re-checking key backups after decryption failures ([\matrix-org#2430](matrix-org#2430)). Fixes element-hq/element-web#22416. Contributed by @duxovni.
MadLittleMods added a commit that referenced this pull request Jul 13, 2022
…s a threaded message

See matrix-org/matrix-react-sdk#8354 (comment)

Also have to keep in mind that we don't want to mix messages in the wrong timelines (main vs threaded timeline)

 - #2444
 - #2454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thread includes messages from main timeline
3 participants