fix(telegram): keep /loop and synthetic sends in the active DM topic
Fixes #87051
This commit is contained in:
@@ -1564,9 +1564,13 @@ class TelegramAdapter(BasePlatformAdapter):
|
||||
Messages topics can opt in with explicit ``direct_messages_topic_id``
|
||||
metadata. Hermes-created private-chat topic lanes are marked with
|
||||
``telegram_dm_topic_reply_fallback``. Live replies send the private
|
||||
topic thread id together with a reply anchor; synthetic/resumed sends
|
||||
without an anchor use ``direct_messages_topic_id`` when metadata has it.
|
||||
``message_thread_id`` alone can render outside the visible lane.
|
||||
topic thread id together with a reply anchor. Synthetic/resumed sends
|
||||
without an anchor (loop wakeups, background-process notifications,
|
||||
queued follow-ups after a gateway restart) prefer the Hermes topic's
|
||||
``message_thread_id`` so they stay in the active topic lane (#87051);
|
||||
``direct_messages_topic_id`` is only used when no topic thread
|
||||
resolves, since the native DM-topic id does not match the Hermes
|
||||
topic lane and can render the message in a different chat lane.
|
||||
|
||||
When ``reply_to_mode`` is ``"off"``, the reply anchor is suppressed for
|
||||
DM topic fallback sends while preserving the ``message_thread_id`` so
|
||||
@@ -1578,6 +1582,15 @@ class TelegramAdapter(BasePlatformAdapter):
|
||||
if reply_to_message_id is None:
|
||||
reply_to_message_id = cls._metadata_reply_to_message_id(metadata)
|
||||
if reply_to_message_id is None:
|
||||
# Anchor-less synthetic sends (loop wakeups, watch
|
||||
# notifications, restart-resumed follow-ups) must stay in the
|
||||
# active topic lane: prefer the Hermes topic thread id when it
|
||||
# resolves (#87051). Routing via direct_messages_topic_id here
|
||||
# sent these to a different lane than the topic the session
|
||||
# runs in.
|
||||
thread_message_id = cls._message_thread_id_for_send(thread_id)
|
||||
if thread_message_id is not None:
|
||||
return {"message_thread_id": thread_message_id}
|
||||
direct_topic_id = cls._metadata_direct_messages_topic_id(metadata)
|
||||
if direct_topic_id is not None:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user