Open MurzNN opened 5 years ago
UI/UX suggestion on how to do this: When user is editing a message, clicking on a reply (currently does nothing while editing) makes the current message a reply.
We also need to think about disengaging a reply (accidentally replied, when meant to send a non-reply). For this, while editing, an X button should appear on the reply (like on link previews).
Problem is, that X might be misinterpreted as 'cancel editing'. Instead of using the X icon, I'd use the symbol, but with something to indicate, that it's for unlinking (I have seen it before, there's something happening in the middle of the chain, a zap or something).
Related vector-im/element-web#2349 (If implementing this, consider that in the future, one should be able to move messages in and out of threads. Make it modular and make the next person's life easier.)
The best way to implement this is probably a 'hidden head tag', what says 'this message is attached to (reply of) message id x, in thread y'.
API-wise, is it even possible to add m.in_reply_to
relation after the fact? I am unable to get it working but perhaps it's more of an Element bug vs an API problem.
Related MSC discussion: https://github.com/matrix-org/matrix-doc/pull/2676#discussion_r696791776
Original events:
{
"type": "m.room.message",
"content": {
"msgtype": "m.text",
"body": "Reply to this message"
},
"sender": "@madlittlemods:matrix.org",
"event_id": "$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8",
"room_id": "!vaRuaHMtoPkUtcRtCV:matrix.org"
}
{
"type": "m.room.message",
"content": {
"msgtype": "m.text",
"body": "foo"
},
"sender": "@madlittlemods:matrix.org",
"event_id": "$Bl7NMSBwW-YSjfnpvd_f5ET2bUr_M4nk4315Q-89ZzQ",
"room_id": "!vaRuaHMtoPkUtcRtCV:matrix.org"
}
And here is what the timeline looks like before any edits:
For reference:
In reply to @madlittlemods:matrix.org
Reply to this message
In reply to @madlittlemods:matrix.org
Reply to this message
m.in_reply_to
relation{
"type": "m.room.message",
"content": {
"body": " * foo",
"msgtype": "m.text",
"m.new_content": {
"body": "foo",
"msgtype": "m.text"
},
"m.relates_to": {
"rel_type": "m.replace",
"event_id": "$Bl7NMSBwW-YSjfnpvd_f5ET2bUr_M4nk4315Q-89ZzQ",
"m.in_reply_to": {
"event_id": "$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8"
}
}
}
}
Results in:
A weird reply artifact is added to the bottom of the timeline and nothing is changed on the original message.
m.in_reply_to
and the fallback text{
"type": "m.room.message",
"content": {
"m.new_content": {
"msgtype": "m.text",
"body": "foo",
"format": "org.matrix.custom.html",
"formatted_body": "foo"
},
"m.relates_to": {
"rel_type": "m.replace",
"event_id": "$Bl7NMSBwW-YSjfnpvd_f5ET2bUr_M4nk4315Q-89ZzQ",
"m.in_reply_to": {
"event_id": "$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8"
}
},
"msgtype": "m.text",
"body": "> <@madlittlemods:matrix.org> Reply to this message\n\n * foo",
"format": "org.matrix.custom.html",
"formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!vaRuaHMtoPkUtcRtCV:matrix.org/$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8?via=matrix.org&via=gitter.im&via=vector.modular.im\">In reply to</a> <a href=\"https://matrix.to/#/@madlittlemods:matrix.org\">@madlittlemods:matrix.org</a><br>Reply to this message</blockquote></mx-reply> * foo"
}
}
Results in (same thing):
Same thing, a weird reply artifact is added to the bottom of the timeline and nothing is changed on the original message.
m.in_reply_to
, fallback text, and fallback in the m.new_content
This is a bit taboo, see https://github.com/vector-im/element-web/issues/13811
{
"type": "m.room.message",
"content": {
"m.new_content": {
"msgtype": "m.text",
"body": "> <@madlittlemods:matrix.org> Reply to this message\n\n foo",
"format": "org.matrix.custom.html",
"formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!vaRuaHMtoPkUtcRtCV:matrix.org/$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8?via=matrix.org&via=gitter.im&via=vector.modular.im\">In reply to</a> <a href=\"https://matrix.to/#/@madlittlemods:matrix.org\">@madlittlemods:matrix.org</a><br>Reply to this message</blockquote></mx-reply> foo"
},
"m.relates_to": {
"rel_type": "m.replace",
"event_id": "$Bl7NMSBwW-YSjfnpvd_f5ET2bUr_M4nk4315Q-89ZzQ",
"m.in_reply_to": {
"event_id": "$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8"
}
},
"msgtype": "m.text",
"body": "> <@madlittlemods:matrix.org> Reply to this message\n\n * foo",
"format": "org.matrix.custom.html",
"formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!vaRuaHMtoPkUtcRtCV:matrix.org/$ensh3G0vNNxYR6tTkR4D3K0RHzJteaGZerkd-GQIWd8?via=matrix.org&via=gitter.im&via=vector.modular.im\">In reply to</a> <a href=\"https://matrix.to/#/@madlittlemods:matrix.org\">@madlittlemods:matrix.org</a><br>Reply to this message</blockquote></mx-reply> * foo"
}
}
Results in:
Something better and closer; an off-styled reply blockquote is added to the original message but it still adds the extra artifact reply blockquote at the bottom of the timeline.
Related MSC's
As an update, the reply artifact was caused by having the "Show hidden events" lab turned on a bug where the tile still showed replies for hidden events. The bug was fixed by https://github.com/matrix-org/matrix-react-sdk/pull/6796
In terms of actually getting the edited relation reply to show up, I think I just had the event format wrong. Instead of adding m.in_reply_to
to the events' root m.relates_to
field, I created a new m.relates_to
inside of m.new_content
. This way when the m.new_content
replaces the content
of the original event, it has the new relation 🌈. This does require an additional change to element-web though, https://github.com/matrix-org/matrix-react-sdk/pull/6809 which hopefully passes the sniff test there in terms of something we want/can do with the Matrix API.
{
"type": "m.room.message",
"content": {
"body": " * foo bar",
"msgtype": "m.text",
"m.new_content": {
"body": "foo bar",
"msgtype": "m.text",
"m.relates_to": {
"m.in_reply_to": {
"event_id": "$qkjmFBTEc0VvfVyzq1CJuh1QZi_xDIgNEFjZ4Pq34og"
}
}
},
"m.relates_to": {
"rel_type": "m.replace",
"event_id": "$lX9MRe9ZTFOOvnU8PRVbvr1wqGtYvNQ1rSot-iUTN5k"
}
}
}
@MadLittleMods the MSC says
Any m.relates_to property within m.new_content is ignored.
Which implies you cannot attach a relation via an edit.
@t3chguy 👍 The spec is against this usage but it can technically work.
@t3chguy 👍 The spec is against this usage but it can technically work.
In in a faulty client, does synapse include the new relation in unsigned relations? Do other clients accept it too?
@t3chguy Yes, it works in Element after https://github.com/matrix-org/matrix-react-sdk/pull/6817
This is from before it became much more clear/crystalized in the MSC's (at least to me) that this was against current spec.
I suggest opening an MSC or clarification because that pr will need reverting based on spec compliance otherwise
@t3chguy I've created https://github.com/matrix-org/matrix-spec/issues/1452 to track this. I think we should also keep this issue open to track the feature itself and how that would look like vs whether the spec actually allows for it at the moment.
Agreed, this issue is about the feature regardless of underlying implementation
Very often users forgot to select "Reply" when answering to message, and sends new message as new "thread". For fix this they copy-paste message text, send as new "Reply" message, and delete original message.
For simplify this correction task, will be good to have ability for attach already sent message to other message as reply, via Edit form.