fix(gateway): restore Telegram DM topic isolation#40525
Open
konsisumer wants to merge 1 commit into
Open
Conversation
tonydwb
approved these changes
Jun 6, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Small targeted DM-fix; changed area matches the title.
✅ Looks Good
- Tight scope (1 changed file / +97 lines)
- No stale debug artifacts or broad new surface area
Reviewed by Hermes Agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Per the reporter's clarification on 2026-06-06, this restores the expected Telegram DM topic flow in two places.
_recover_telegram_topic_thread_id()opt-in viagateway.platforms.telegram.extra.pin_root_dm_repliesinstead of always rewriting lobby-shaped root-DM replies to the most recent topic. This keeps fresh root-DM messages from being silently redirected into an older topic lane._schedule_telegram_topic_title_rename()sees a real DM topic thread for the first time, so the existing rename pipeline can run even if/topicwas never explicitly invoked beforehand.tests/gateway/test_telegram_topic_mode.py.Fixes #30411
Addressing maintainer feedback
This issue was previously tied to the
#26609/#28513regression cluster, with#28605called out as the canonical follow-up and#29287/#29546noted as duplicate fix PRs. The new 2026-06-06 followup added fresh, specific behavior that was still missing onmain: opt-in root-DM pinning and lazy topic-mode seeding for auto-rename, so this PR implements that narrower follow-on instead of reopening any of those older branches.How to test
pytest tests/gateway/test_telegram_topic_mode.py -q.test_recover_returns_none_without_opt_in_pinningkeeps root-DM messages from being rebound whenpin_root_dm_repliesis unset.test_recover_rewrites_lobby_thread_id_to_most_recentstill passes whenpin_root_dm_repliesis explicitly enabled.test_schedule_topic_rename_auto_enables_topic_mode_for_new_dm_topicproves the rename scheduler now seeds topic mode for a newly created DM topic lane.What platforms tested on