From 2f00559d9e7358fd5eb5605707db5aefdfbe86d9 Mon Sep 17 00:00:00 2001 From: Keyu Yuan Date: Sun, 10 May 2026 15:22:22 -0700 Subject: [PATCH] fix(telegram): pass source.thread_id explicitly on auto-reset notice (carve-out of #7404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- gateway/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/run.py b/gateway/run.py index 6522c4e9706..129827cbfb6 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -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)