cinnyapp/cinny

Threaded replies not working every time

Opened this issue · 8 comments

Describe the bug

According to #1349, replying to a threaded reply should, as far as I can tell, reply within that same thread. This is happening sometimes, but not always. In some cases, it even does something weird where other clients don't see the reply at all. The screenshot below might help.

Screenshot 2024-11-06 at 13 04 52

The "E assim?" message is inside a thread; the "Olá?" message replies to that, but doesn't get put inside the thread.

The video below even shows the messages, in Element, appearing inside the thread and then disappearing (they don't show up outside the thread also).

Screen.Recording.2024-11-06.at.13.35.35.mov

I will also post the sources for these three messages (the original, the first threaded reply, and the "failed" threaded reply).

The sources Initial message
{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "Olá "
    },
    "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
    "origin_server_ts": 1730861185499,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.message",
    "unsigned": {
      "age": 33748570,
      "m.relations": {
        "m.thread": {
          "count": 2,
          "current_user_participated": true,
          "latest_event": {
            "content": {
              "algorithm": "m.megolm.v1.aes-sha2",
              "ciphertext": "AwgDEoABnceNA+S1LxDfZ0AhjZgHebPrUErclyloL7pxhpeFzQkgR8Kq5hTp++dFIuqPmsJTyfTaRu52Gv6LuH66CNjEM1wJnLUAR+cFHfPeQ/dGe0Nz6IX2ytKR0HKoFFXav3or1lka1XuWnCh3lZDc27tg6omi76aGnYUA8wSLpEzqj4+3l8Q3KFnsyZtzVPEu8nRc25sh2YZexHcZcjgi/5wawrjSec0jz4zCLcloEwEjsE65TP01S3RQI9yu8QBvUuKRmuia/ivWBwE",
              "device_id": "PELfujDz1L",
              "m.relates_to": {
                "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
                "is_falling_back": true,
                "m.in_reply_to": {
                  "event_id": "$CMTH-tUKKa3ZJDY_qf5ka1EeCT2Ca5lmfXhZYOGo_8Y"
                },
                "rel_type": "m.thread"
              },
              "sender_key": "wRzGQwu4M4Gm5UE1vuTnqFyqNEjhgyU85QOkdTk1YnU",
              "session_id": "QlQEi3IRf6utYPVecqTO6Oad7N+ySGGAcDr8Ebew5JM"
            },
            "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A",
            "origin_server_ts": 1730861410860,
            "room_id": "!wzIvctSysYGDinFtVb:matrix.org",
            "sender": "@filipe:chat.filipesm.eu",
            "type": "m.room.encrypted",
            "unsigned": {
              "transaction_id": "$local.e4e5596e-a9a0-48fd-97b3-5e0c6ec67e63"
            }
          }
        }
      },
      "transaction_id": "$local.f537da89-7792-4e0a-abfd-70fcbded67f3"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgBEoABz4N0h9fXxDZjt3q2hpS3H5CDcC7NGsJonDVyCKR4vCSJUNugO/pEO9nxKi2xpNBzZ7frXxY7G+UknYip5n/Jje9X5DACq1kgMIiHdi+5DkPzOXUXWa8OtJkQDu/SrS+CId99nM2/1MypTNfs69S0vieptEVO1H9287Ijxfz3SGD3y5CKeZZtrm0lFjhTwnNZmD3A4kN0SryoIeqiB1v7T6tB9bY+e+dLeaq4cAYPQcz7y0QMrQ17HV1pRPrQ4My02tXZql1d/Q0",
      "device_id": "PELfujDz1L",
      "sender_key": "wRzGQwu4M4Gm5UE1vuTnqFyqNEjhgyU85QOkdTk1YnU",
      "session_id": "QlQEi3IRf6utYPVecqTO6Oad7N+ySGGAcDr8Ebew5JM"
    },
    "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
    "origin_server_ts": 1730861185499,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 33748570,
      "m.relations": {
        "m.thread": {
          "count": 2,
          "current_user_participated": true,
          "latest_event": {
            "content": {
              "algorithm": "m.megolm.v1.aes-sha2",
              "ciphertext": "AwgDEoABnceNA+S1LxDfZ0AhjZgHebPrUErclyloL7pxhpeFzQkgR8Kq5hTp++dFIuqPmsJTyfTaRu52Gv6LuH66CNjEM1wJnLUAR+cFHfPeQ/dGe0Nz6IX2ytKR0HKoFFXav3or1lka1XuWnCh3lZDc27tg6omi76aGnYUA8wSLpEzqj4+3l8Q3KFnsyZtzVPEu8nRc25sh2YZexHcZcjgi/5wawrjSec0jz4zCLcloEwEjsE65TP01S3RQI9yu8QBvUuKRmuia/ivWBwE",
              "device_id": "PELfujDz1L",
              "m.relates_to": {
                "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
                "is_falling_back": true,
                "m.in_reply_to": {
                  "event_id": "$CMTH-tUKKa3ZJDY_qf5ka1EeCT2Ca5lmfXhZYOGo_8Y"
                },
                "rel_type": "m.thread"
              },
              "sender_key": "wRzGQwu4M4Gm5UE1vuTnqFyqNEjhgyU85QOkdTk1YnU",
              "session_id": "QlQEi3IRf6utYPVecqTO6Oad7N+ySGGAcDr8Ebew5JM"
            },
            "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A",
            "origin_server_ts": 1730861410860,
            "room_id": "!wzIvctSysYGDinFtVb:matrix.org",
            "sender": "@filipe:chat.filipesm.eu",
            "type": "m.room.encrypted",
            "unsigned": {
              "transaction_id": "$local.e4e5596e-a9a0-48fd-97b3-5e0c6ec67e63"
            }
          }
        }
      },
      "transaction_id": "$local.f537da89-7792-4e0a-abfd-70fcbded67f3"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  }
}

Successful threaded reply

{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "E assim?",
      "m.relates_to": {
        "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$CMTH-tUKKa3ZJDY_qf5ka1EeCT2Ca5lmfXhZYOGo_8Y"
        },
        "rel_type": "m.thread"
      }
    },
    "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A",
    "origin_server_ts": 1730861410860,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.message",
    "unsigned": {
      "age": 33523209,
      "transaction_id": "$local.e4e5596e-a9a0-48fd-97b3-5e0c6ec67e63"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgDEoABnceNA+S1LxDfZ0AhjZgHebPrUErclyloL7pxhpeFzQkgR8Kq5hTp++dFIuqPmsJTyfTaRu52Gv6LuH66CNjEM1wJnLUAR+cFHfPeQ/dGe0Nz6IX2ytKR0HKoFFXav3or1lka1XuWnCh3lZDc27tg6omi76aGnYUA8wSLpEzqj4+3l8Q3KFnsyZtzVPEu8nRc25sh2YZexHcZcjgi/5wawrjSec0jz4zCLcloEwEjsE65TP01S3RQI9yu8QBvUuKRmuia/ivWBwE",
      "device_id": "PELfujDz1L",
      "m.relates_to": {
        "event_id": "$G3f6k1-xYD5D0L7I9heDezTS6IEKMLypYPv4Lm9h4Kc",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$CMTH-tUKKa3ZJDY_qf5ka1EeCT2Ca5lmfXhZYOGo_8Y"
        },
        "rel_type": "m.thread"
      },
      "sender_key": "wRzGQwu4M4Gm5UE1vuTnqFyqNEjhgyU85QOkdTk1YnU",
      "session_id": "QlQEi3IRf6utYPVecqTO6Oad7N+ySGGAcDr8Ebew5JM"
    },
    "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A",
    "origin_server_ts": 1730861410860,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 33523209,
      "transaction_id": "$local.e4e5596e-a9a0-48fd-97b3-5e0c6ec67e63"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  }
}

"Failed" threaded reply

{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "> <@filipe:chat.filipesm.eu> E assim?\n\nOlá?",
      "format": "org.matrix.custom.html",
      "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!wzIvctSysYGDinFtVb%3Amatrix.org/%24gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A\">In reply to</a><a href=\"https://matrix.to/#/%40filipe%3Achat.filipesm.eu\">@filipe:chat.filipesm.eu</a><br />E assim?</blockquote></mx-reply>Olá?",
      "m.relates_to": {
        "m.in_reply_to": {
          "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A"
        }
      }
    },
    "event_id": "$feD1waMDYXUuqCXqEc8imAOOAiXpWEiK0EUfoA3O-8k",
    "origin_server_ts": 1730890780070,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.message",
    "unsigned": {
      "age": 4154222,
      "transaction_id": "m1730890779820.14"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgAEvAD1cqcR+hmp7sTIVm3fVDeZ9JKR6wldOpHVES8u8BWnnuQfSrzYNk1zQd5DgtuiPKWRzVnEUGiv/pc/KfKD32Oi/1aDM3JSq3DEvbPFzRaCiu0nmPPkIpP3Wj615NrLhDktnNcOTK97Qm7m3owCPEptc5DUB3JzeIJBmbWp3DFkbk7wVP9yM4OkkqKnhAMlJdo/UliPk/1lX6uUzEExPtPVAykC+S/P/JkJBN+lXOyr9YGzh1aBVa2+7fyvKqyC5MshWfBq6eHTYr94+J+eitwFsBZUqRDJIx3f4lwQYrTOg6lqL0o3ZdlWTl0CIJpeaf138Bgvi9hHGLJY7wxpootVmWAgOTtCZb+oLA92Day3u1/h4yhz9RqxmW7GuAO0eO7youtOWzg8XFNxMv8m4n4/lRreY4HKkMYR9uM0U+GJE41ktpdp35m9LrnUnBSYiXq7D/OJI9Uh4k7HjNXvwCY4QiEVblVwXq7ImK7tf6gXCn614odReOapCZxuxKPXLah3v/qZZmRYnRTdqTeenTdsephJDrmGj29DzJXk96BYWSZwqmd+Rih7jto6C5kJuO+qWDvtKpJcpEDp0p8zWQIwvnBZHdqbMzFEr/kIulHPu9vLCJM1XjU0pUwwgWdqqw1+QRikKRJt/IknqPBZGFEPseDlc23Yar+VllU7HCIB7Gyvnd0ZxBB9BLO6BWnJunLnmu6FsVsT4+ERvnOTAUE3Y8UnK676R5PY0zIR6Km4ykUZHzIxw13DA",
      "device_id": "DJQFoJUAEV",
      "m.relates_to": {
        "m.in_reply_to": {
          "event_id": "$gurWt1gh2_Oaut8p56XLmB2CZIFFFi8KxzvAdfjQO8A"
        }
      },
      "sender_key": "TIfqtIk7PAcAY1YRcal2NVh4VjlgxXVrzLY9U7RKI1A",
      "session_id": "614miFrM6tlmvg8ylayZhkWrMwgt28u2c4PfjwMfOYo"
    },
    "event_id": "$feD1waMDYXUuqCXqEc8imAOOAiXpWEiK0EUfoA3O-8k",
    "origin_server_ts": 1730890780070,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 4154222,
      "transaction_id": "m1730890779820.14"
    },
    "room_id": "!wzIvctSysYGDinFtVb:matrix.org"
  }
}

Reproduction

  1. Use Cinny (latest) to reply to a threaded reply, and see it sometimes work, sometimes not?

Expected behavior

The reply would be threaded (and visible in other clients like Element, inside the thread)

Platform and versions

1. MacOS and Android
2. Vivali browser
3. Matrix homeserver: Conduwuit
4. Cinny version: 4.2.2

Additional context

No response

This seems to be related to the is_falling_back property. From my experience, if it is true, than a the threaded reply always works (and doesn't work if is_falling_back === false). Does this make any sense to anyone? I don't know much about the codebase :(

Does this only happens in encrypted room?

Does this only happens in encrypted room?

I can double check!

I just opened a non-encrypted room (same accounts as the original example) and everything worked every time, so I couldn't reproduce.


I just discovered the "root" of the problem I think: when I open a thread on Element from my account, and then reply to that, it fails. If another account opens the thread initially, everything seems to work.

The above rule does not apply for non-e2ee rooms. Threads seems to work every time in non-e2ee rooms, like you suspected @ajbura


EDIT with more info:

Thread started from other account (on Element) that works

{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "Thread",
      "m.mentions": {},
      "m.relates_to": {
        "rel_type": "m.thread",
        "event_id": "$vdm35VGHVsH1YiRPNRinyeVaMmpEVaeQUf4t-SuGhAQ",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$vdm35VGHVsH1YiRPNRinyeVaMmpEVaeQUf4t-SuGhAQ"
        }
      }
    },
    "event_id": "$-vvPR5ZXWG9CxixgPLcaPUJE4Qwk9Hcg_fWAybnqaXo",
    "origin_server_ts": 1734075300664,
    "sender": "@filipesm.eu:matrix.org",
    "type": "m.room.message",
    "unsigned": {
      "age": 266
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgBEtAC9Cevl8qGR6LYlFmvr1ZeoyFXcKaVLTRd6rP9WMllOsbRHYjvafcpjG5MTnuHlCNqol3r/no8idCRJknuQDTNtZKBid7d6xcPMw7mrwQkfKeKcIShNMmKJedzXgwxQUD1DIkaLEByjmrBb1LIFf1lKfEq/6Oi7Ix3jxvkEyY69lfK7mZWbYvofJl9FlJC11oscvF7KPmC5x9yzPAO5uiqr/dMu+j/A6qFtRVs6BskQ63IYhx491KYUvBsbcznqWejz2HP20EjxF3NY4znn/aID1NA06+8EhnOqiSA0lsn/UVAHdZkFF1USrWciMjySs8D1LQS4WcT3NI5CyY8DH/9ObTSqcPmhEVTJLGo0plJMVq+wgbit0dlQqFe6wtM5piTDmlivRqPPgA9BpPeTzl5Q/0GsV1RaYcaiYHa1iVo2nGwDk3h4B2g/ewSEU9Cr2OmMQEnTAxbwNgWuht7Scz9MHmU1K6vJE/d8ubcsr/Q7+fuKnC9qqS/LhYeGOi56/srPurjTmeHqJT443qo38Nj8vHl4bXfAYEK",
      "device_id": "IBQOUKQBMI",
      "m.relates_to": {
        "event_id": "$vdm35VGHVsH1YiRPNRinyeVaMmpEVaeQUf4t-SuGhAQ",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$vdm35VGHVsH1YiRPNRinyeVaMmpEVaeQUf4t-SuGhAQ"
        },
        "rel_type": "m.thread"
      },
      "sender_key": "nMUOOZwc+lvvais/rEEThh7c1/PSmK5cuXnD8YrZUyI",
      "session_id": "n4zEJ4g577ogeSmgdcdSOk2Uv3HTGxjovMprq4hau5o"
    },
    "event_id": "$-vvPR5ZXWG9CxixgPLcaPUJE4Qwk9Hcg_fWAybnqaXo",
    "origin_server_ts": 1734075300664,
    "sender": "@filipesm.eu:matrix.org",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 266
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  }
}

Thread started on Element from my account, that doesn't work

{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "Hey",
      "m.relates_to": {
        "event_id": "$0fu41UBlrYFNTfVDjsuLq1S0bTYAch14e-Vgy_rhmqM",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$0fu41UBlrYFNTfVDjsuLq1S0bTYAch14e-Vgy_rhmqM"
        },
        "rel_type": "m.thread"
      }
    },
    "event_id": "$Hc37EQlH4y-DTLJ9ljY2ijQVMFO0Yn2qco69F1ciFDw",
    "origin_server_ts": 1734075397265,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.message",
    "unsigned": {
      "age": 186,
      "transaction_id": "$local.f4acd129-cee8-456f-8a59-9aa9dead5c16"
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgBEoAB/v5/qKw3QCKdDBunkusJUq+4/YhfvKjy7cy4ZOvHv8E1ecimFY8pL/MokTJs1AiumDxrCYQ+UznhRsU4DMgxES+obJDud5DR6BA3s8qpME3pRaimBn8cUVHThJ61b6UBUTWjGFEA1cj/WvBcxa275yFwsR7EySKF5DX+3Y4LFZy44BA+I6bCNJLkdNZt5p5VUuwDETA3A04vDQS4CaVUlvWwTf7Dp0TybjvN9F7+Camnyh6ulnij7q/CHh21Ud/My/cBd1fb/QQ",
      "device_id": "YcNk27rQX9",
      "m.relates_to": {
        "event_id": "$0fu41UBlrYFNTfVDjsuLq1S0bTYAch14e-Vgy_rhmqM",
        "is_falling_back": true,
        "m.in_reply_to": {
          "event_id": "$0fu41UBlrYFNTfVDjsuLq1S0bTYAch14e-Vgy_rhmqM"
        },
        "rel_type": "m.thread"
      },
      "sender_key": "GMFxPV+C23ezUBi2osSub13xlm29z6ls5c4nOJbsgBQ",
      "session_id": "pnPgCrJw+yscoY3gMALSoJD12Hct5JPNE1yxSbDv5Gs"
    },
    "event_id": "$Hc37EQlH4y-DTLJ9ljY2ijQVMFO0Yn2qco69F1ciFDw",
    "origin_server_ts": 1734075397265,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 186,
      "transaction_id": "$local.f4acd129-cee8-456f-8a59-9aa9dead5c16"
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  }
}

The only different between the two seems to be the unsigned field, and the transaction_id inside.

looks like for some unknown reason

const { 'm.relates_to': relation } = replyEvt.getOriginalContent();
doesn't not return data from encrypted message.

we could try using getWireContent() as we don't need to decrypt messages to read it's relations field

Indeed we could, but it's still weird that for some reason it's not getting it right now, right? Like you very nicely pointed out, the reply draft (when typing the message after clicking the reply button) is not threaded at any point. It never recognises it's inside a thread, but it should.

I don't know if using getWireContent() (which I assume gets the original unencrypted message) helps. Would that mean that the message we have in replyEvt does not have the unencrypted content? Why would that happen only for threads started by the same account on another client? Hmmm

Another thing to point out is that the failed threaded reply (below) still responds to the threaded message, just doesn't "stay threaded".

Failed threaded reply

{
  "<== DECRYPTED_EVENT ==>": {
    "content": {
      "msgtype": "m.text",
      "body": "> <@filipe:chat.filipesm.eu> Hey\n\nHey?",
      "format": "org.matrix.custom.html",
      "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!B34AEQHk5nDImeth78%3Achat.filipesm.eu/%24Hc37EQlH4y-DTLJ9ljY2ijQVMFO0Yn2qco69F1ciFDw\">In reply to</a><a href=\"https://matrix.to/#/%40filipe%3Achat.filipesm.eu\">@filipe:chat.filipesm.eu</a><br />Hey</blockquote></mx-reply>Hey?",
      "m.relates_to": {
        "m.in_reply_to": {
          "event_id": "$Hc37EQlH4y-DTLJ9ljY2ijQVMFO0Yn2qco69F1ciFDw"
        }
      }
    },
    "event_id": "$dRlckBOydutixc2bFMj5W91Rx2fd88OSs9NvpaDhjp0",
    "origin_server_ts": 1734075402255,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.message",
    "unsigned": {
      "age": 123,
      "transaction_id": "m1734075402034.14"
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  },
  "<== ORIGINAL_EVENT ==>": {
    "content": {
      "algorithm": "m.megolm.v1.aes-sha2",
      "ciphertext": "AwgGEvADOpH41w1zHfgISY8RgRppHjPseqx19XrYqdmLBJGUpxkTu+ByqaDWnNfw6ncsdkCMZMyyRoFgbfiXtyKpV+WYlqjRevbcsACoepvTKraCcKxMaU/off5hFzi0pRoWgH0BvbP8LzbsoPnQ23sslyQoZYrxcrdje0zsP0FE4UwV+9wHk1wMSitPWfN7UulWRIvfDzMRU7iA43r6fox8XgJH159QGqoiy6eweKQD0ZvFiQFd6TL9ZJD2yRQRXERi9RpinW3gUZ5G6B1BDwxtjAujFiP3Xg5gNjLsFyDxs5UI2JGto58OzoVQk1iq+efJ2fLBktYBnUuSG7qvun+QxOvHq01YhI8hl1JBq3jfDBPR1KJ4JOJZyut3cn/V+pi8v1ES7SPvdLkVsLxKhBBGWHLHySKRq9H+eAvpsQiSqVE5CHBteO3wane4g55F8TrGn8MGtIWdLSTYDUZqxCgRgFMAbReJLr8YGN4dsd/e61bJy9MraFRlVxSJb0TMpy7YwT5ExDCwc1LA8y43jnMY04m7qpO+OrtjHuWkmnPfnfa4hHUtijYDTdZtXQJJSDneIz7TjZiJ7mQwXk+kkvC8k+TfhO2A13+Qq7ieX6fOScZ56hlYXnE4ULt/AapIGPViGfyKHnXqJflsuz9BJK0DDDTF5z9XyIdS0n5ZRFXRA7oRDHaWqM5n/HopMN0HzAdEnDwMfvbZ5AwKiPNPtJFjEoRqpGSPwJt0OUrFt7o22OVlJzrIedkUuFkCBQ",
      "device_id": "DJQFoJUAEV",
      "m.relates_to": {
        "m.in_reply_to": {
          "event_id": "$Hc37EQlH4y-DTLJ9ljY2ijQVMFO0Yn2qco69F1ciFDw"
        }
      },
      "sender_key": "TIfqtIk7PAcAY1YRcal2NVh4VjlgxXVrzLY9U7RKI1A",
      "session_id": "wMiYidJTohxUwhUC/yvDEicCZIU7XHPCNuaMM6ODgmo"
    },
    "event_id": "$dRlckBOydutixc2bFMj5W91Rx2fd88OSs9NvpaDhjp0",
    "origin_server_ts": 1734075402255,
    "sender": "@filipe:chat.filipesm.eu",
    "type": "m.room.encrypted",
    "unsigned": {
      "age": 123,
      "transaction_id": "m1734075402034.14"
    },
    "room_id": "!B34AEQHk5nDImeth78:chat.filipesm.eu"
  }
}

https://github.com/matrix-org/matrix-js-sdk/blob/315e81b7decd67154eaedfbaf4cf3fbecbb99e7f/src/models/event.ts#L562 this.clearEvent returns the IClearEvent (which omits m.relates_to) but getOriginalContent returns it as T which is IContent. So, basically sdk is lying about types here leading to bug. using getWireContent should fix it.

Do you want help testing? Or want me to submit a bug upstream? :)