← Back to PRs

#6192: Telegram: fix DM Topics thread routing

by ViffyGwaanl open 2026-02-01 11:24 View on GitHub →
channel: telegram
### What Fix thread routing for Telegram *private chats with Topics enabled* by using the raw `message_thread_id` instead of applying forum-group thread resolution. ### Why `resolveTelegramForumThreadId(...)` is intended for forum groups; in private chats it can cause replies/typing to fall back to the main thread. ### Change - In groups/supergroups: keep using `resolveTelegramForumThreadId({ isForum, messageThreadId })` - In private chats: set `resolvedThreadId = messageThreadId` - Make `replyThreadId` follow `resolvedThreadId` ### Notes This matches observed behavior when DM Topics are enabled and `message_thread_id` is present. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates Telegram thread routing in `buildTelegramMessageContext` to treat DMs differently from groups: groups/supergroups still derive a `resolvedThreadId` via `resolveTelegramForumThreadId`, while private chats use the raw `message_thread_id`, and replies/typing now consistently use `replyThreadId = resolvedThreadId`. Overall this aligns the DM behavior with Telegram “Topics in private chats”, but the new `replyThreadId` assignment can change behavior for *non-forum* groups by routing replies/typing into the default forum topic id (often `1`) rather than the main thread when `message_thread_id` is absent. <h3>Confidence Score: 3/5</h3> - This PR is likely safe but may misroute replies/typing in non-forum groups due to default topic resolution. - The change is small and targeted, but it modifies group reply routing by always using `resolvedThreadId`, which can differ from the previous behavior when `isForum` is false and `message_thread_id` is missing. - src/telegram/bot-message-context.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs