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

Message editing: attach message as reply to other message via Edit form #1047

Open
MurzNN opened this issue Jul 22, 2019 · 11 comments
Open

Message editing: attach message as reply to other message via Edit form #1047

MurzNN opened this issue Jul 22, 2019 · 11 comments

Comments

@MurzNN
Copy link

MurzNN commented Jul 22, 2019

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.

@jtagcat
Copy link

jtagcat commented Jul 8, 2020

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.

image

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 link 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).

@jtagcat
Copy link

jtagcat commented Jul 8, 2020

Related element-hq/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'.

@MadLittleMods
Copy link

MadLittleMods commented Aug 26, 2021

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: matrix-org/matrix-spec-proposals#2676 (comment)

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:

What does a normal message look like with a `m.in_reply_to`
{
  "type": "m.room.message",
  "content": {
    "msgtype": "m.text",
    "body": "> <@madlittlemods:matrix.org> Reply to this message\n\nfoo",
    "format": "org.matrix.custom.html",
    "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!vaRuaHMtoPkUtcRtCV:matrix.org/$BNJlsM_mfjrvzDMbJ7TUp_YZHeGGRYkIFulQXGp_aJs?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": {
      "m.in_reply_to": {
        "event_id": "$BNJlsM_mfjrvzDMbJ7TUp_YZHeGGRYkIFulQXGp_aJs"
      }
    }
  },
  "sender": "@madlittlemods:matrix.org",
  "event_id": "$xz3ODvwgG7pKolVelsLI33zgFK0tXTa904-cwwTb6Ck",
  "room_id": "!vaRuaHMtoPkUtcRtCV:matrix.org"
}
What does a edited message look like with a `m.in_reply_to`
{
  "type": "m.room.message",
  "content": {
    "m.new_content": {
      "msgtype": "m.text",
      "body": "foo bar",
      "format": "org.matrix.custom.html",
      "formatted_body": "foo bar"
    },
    "m.relates_to": {
      "rel_type": "m.replace",
      "event_id": "$xz3ODvwgG7pKolVelsLI33zgFK0tXTa904-cwwTb6Ck"
    },
    "msgtype": "m.text",
    "body": "> <@madlittlemods:matrix.org> Reply to this message\n\n * foo bar",
    "format": "org.matrix.custom.html",
    "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!vaRuaHMtoPkUtcRtCV:matrix.org/$BNJlsM_mfjrvzDMbJ7TUp_YZHeGGRYkIFulQXGp_aJs?via=matrix.org&amp;via=gitter.im&amp;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 bar"
  },
  "sender": "@madlittlemods:matrix.org",
  "event_id": "$l246fF0IBQNLqkVWoGcXhF8tLops024pWMUJDAI_2_Y",
  "room_id": "!vaRuaHMtoPkUtcRtCV:matrix.org"
}

Edit message to just add the 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.

Edit message with 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&amp;via=gitter.im&amp;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.

Edit message with m.in_reply_to, fallback text, and fallback in the m.new_content

This is a bit taboo, see element-hq/element-web#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&amp;via=gitter.im&amp;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&amp;via=gitter.im&amp;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

MadLittleMods referenced this issue in matrix-org/matrix-react-sdk Sep 14, 2021
…Event

As discovered in https://github.com/vector-im/element-web/issues/10391#is

Previously, if you turned on the `showHiddenEventsInTimeline` labs flag, edit (`m.replace`) events
that also have a `m.in_reply_to` field, will show the reply in the timeline.

ex.
```
{
  "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": "$yvuev9bF2nLRf8fscG55njpVjY3FHJzWgZ4BKI9_0eg",
      "m.in_reply_to": {
        "event_id": "$qkjmFBTEc0VvfVyzq1CJuh1QZi_xDIgNEFjZ4Pq34og"
      }
    }
  }
}
```
MadLittleMods referenced this issue in matrix-org/matrix-react-sdk Sep 14, 2021
…eEvent` (#6796)

As discovered in https://github.com/vector-im/element-web/issues/10391#is

Previously, if you turned on the `showHiddenEventsInTimeline` labs flag, edit (`m.replace`) events
that also have a `m.in_reply_to` field, will show the reply in the timeline.

ex.
```
{
  "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": "$yvuev9bF2nLRf8fscG55njpVjY3FHJzWgZ4BKI9_0eg",
      "m.in_reply_to": {
        "event_id": "$qkjmFBTEc0VvfVyzq1CJuh1QZi_xDIgNEFjZ4Pq34og"
      }
    }
  }
}
```
MadLittleMods referenced this issue in matrix-org/matrix-react-sdk Sep 14, 2021
Part of https://github.com/vector-im/element-web/issues/10391#issuecomment-906131724

When `m.relates_to` -> `m.in_reply_to` is provided in `m.new_content`
for an edited message, use the updated reply.

ex.

```json
{
  "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
Copy link

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 matrix-org/matrix-react-sdk#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, matrix-org/matrix-react-sdk#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 referenced this issue in matrix-org/matrix-react-sdk Sep 15, 2021
Part of https://github.com/vector-im/element-web/issues/10391#issuecomment-906131724

When `m.relates_to` -> `m.in_reply_to` is provided in `m.new_content`
for an edited message, use the updated reply.

ex.

```json
{
  "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 referenced this issue in matrix-org/matrix-react-sdk Sep 16, 2021
Part of https://github.com/vector-im/element-web/issues/10391

When `m.relates_to` -> `m.in_reply_to` is provided in `m.new_content`
for an edited message, use the updated reply.

ex.

```json
{
  "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 referenced this issue in matrix-org/matrix-react-sdk Sep 17, 2021
Part of https://github.com/vector-im/element-web/issues/10391

When `m.relates_to` -> `m.in_reply_to` is provided in `m.new_content`
for an edited message, use the updated reply.

ex.

```json
{
  "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"
    }
  }
}
```
@t3chguy
Copy link
Member

t3chguy commented Feb 23, 2023

@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.

https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2676-message-editing.md#applying-mnew_content

@t3chguy t3chguy transferred this issue from element-hq/element-web Feb 23, 2023
@MadLittleMods
Copy link

@t3chguy 👍 The spec is against this usage but it can technically work.

@t3chguy
Copy link
Member

t3chguy commented Feb 23, 2023

@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?

@MadLittleMods
Copy link

MadLittleMods commented Feb 23, 2023

@t3chguy Yes, it works in Element after matrix-org/matrix-react-sdk#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.

@t3chguy
Copy link
Member

t3chguy commented Feb 23, 2023

I suggest opening an MSC or clarification because that pr will need reverting based on spec compliance otherwise

@MadLittleMods
Copy link

@t3chguy I've created matrix-org/matrix-spec#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.

@t3chguy
Copy link
Member

t3chguy commented Feb 23, 2023

Agreed, this issue is about the feature regardless of underlying implementation

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

5 participants