fix(telegram): pass source.thread_id explicitly on auto-reset notice (carve-out of #7404)

The auto-reset notice ("◐ Session automatically reset…") was being sent
with metadata=getattr(event, 'metadata', None), which can drop or
mis-route in Telegram forum topics: the event's metadata isn't
guaranteed to carry the originating thread_id, so the notice could leak
into General or another topic.

Use the existing self._thread_metadata_for_source(source) helper, which
already handles thread_id construction plus the Telegram DM topic
reply-fallback shape used everywhere else in the gateway.

Carve-out of #7404. The PR's other hunk (line 7578, queued first
response) is already redundant on main — gateway/run.py:15782 has used
_status_thread_metadata since the _thread_metadata_for_source plumbing
landed.

Closes #7355 (path B; paths A and C closed via prior salvage merges).
This commit is contained in:
Keyu Yuan 2026-05-10 15:22:22 -07:00 committed by Teknium
parent a2920b1762
commit 2f00559d9e

View file

@ -7025,7 +7025,7 @@ class GatewayRunner:
pass
await adapter.send(
source.chat_id, notice,
metadata=getattr(event, 'metadata', None),
metadata=self._thread_metadata_for_source(source),
)
except Exception as e:
logger.debug("Auto-reset notification failed (non-fatal): %s", e)