element-hq / element-meta

Shared/meta documentation and project artefacts for Element clients
75 stars 12 forks source link

Expected UTDs: Hide device-relative historical UTDs #2313

Closed BillCarsonFr closed 6 months ago

BillCarsonFr commented 8 months ago

A freshly logged in session will have access to event in the joined rooms, but not to the keys for the messages as the device didn't exist when the event were sent. The new device has to go through the verification process in order to get access to the keys and properly display history.

We are talking here about Device-Relative history:

image

Currently EIX is hiding such history until the device has access to backup:

image

Technical Inputs

How to detect when an event is historical to the current device?

Currently EIX is using events origin_server_ts of events (isItemInEncryptionHistory). It's comparing the local creation date of the device ( since the unix epoch) to the event origin_server_ts (Timestamp in milliseconds since the unix epoch on originating homeserver when this event was sent.)

Some downside on this approach is that if the device local time or server local time is wrong it could messed up things.

Another approach could be to use the API end-point used to get the messages?

It's anyhow hard to see if something is really device relative history, as the process of sending is inherently racy. There might be some events that are shown were they shouldn't (sent around the same time the device is logged in but before propagated to anyone)

Proposal

If an UTD has not be displayed on screen, it should not be reported to analytics.

Tasks

### Tasks
- [x] EX Hide device relative historical messages until the device has access to backup.
- [x] WebR: Hide device relative historical messages until the backup has been downloaded.
- [x] WebR: make sure that UTDs due to this are reported separately in Posthog

Known possible issues

richvdh commented 8 months ago

Probably requires a fix to https://github.com/element-hq/element-web/issues/27009?

Edit: not really. The two are orthogonal.

richvdh commented 8 months ago

There might be some events that are shown were they shouldn't (sent around the same time the device is logged in but before propagated to anyone)

This is somewhat related to https://github.com/element-hq/element-meta/issues/2314, and dealing with the race condition might have a similar solution.

richvdh commented 8 months ago

As a first step, we will not hide the events altogether, but display a placeholder.

BillCarsonFr commented 8 months ago

Note: we should ensure that it's also hiding historical UTDs in thread view.

richvdh commented 8 months ago

Rough idea for approach here:

More detailed work:

BillCarsonFr commented 7 months ago

Some design exploration https://www.figma.com/file/a1NWmg6mOi2VZuSgaJx6nD/Displaying-UISI?type=design&node-id=1-12313&mode=design&t=6hb0XIH9Ftv5SI46-0

richvdh commented 7 months ago

Decision tree for the text to be displayed:

flowchart TD
A{Timestamp on the message\npostdates the creation of our device}
A -- Yes --> X
A -- No --> B
B{Is there a backup}
B -- No --> Y
B -- Yes --> C
C{Is the device verified}
C -- No --> Z
C -- Yes --> X

X([Normal UTD error])
Y([History is not available on this device])
Z([You need to verify this device])