fix(telegram): support message_thread_id for DM topics#17952
fix(telegram): support message_thread_id for DM topics#17952timbrinded wants to merge 3 commits into
Conversation
Telegram added 'Topics in DMs' which assigns thread IDs to DM conversations. The existing code unconditionally stripped message_thread_id for all DM-scoped threads, assuming DMs never have threads. This caused replies to land outside their topic in DMs that have topics enabled. Now pass through message_thread_id when present (> 0) for DM scope, only omitting it for regular DMs without topics.
|
Anecdotally these were the fixes i had to do on my installation to fix threading this morning after updating to latest version. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for Telegram's "Topics in DMs" feature by allowing message_thread_id to be passed through for direct message conversations that have topics enabled. Previously, the code unconditionally filtered out all thread IDs for DM scope, assuming DMs never had threads.
Changes:
- Modified
buildTelegramThreadParamsto pass through positive thread IDs for DM scope instead of always returningundefined - Updated tests in
helpers.test.tsto validate that DM topics with valid IDs now includemessage_thread_id - Updated
draft-stream.test.tsto expectmessage_thread_idfor DM topics
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/telegram/bot/helpers.ts | Changed DM thread ID handling to conditionally pass through positive values |
| src/telegram/bot/helpers.test.ts | Updated tests to reflect new DM topic behavior and validate edge cases |
| src/telegram/draft-stream.test.ts | Updated draft stream test to expect thread ID for DM topics |
The delivery test asserted message_thread_id should NOT be present for DM-scoped threads. Updated to expect it IS present, matching the new behavior that passes through thread IDs for DM topics.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Appreciate this patch.\n\nI’m closing as superseded because the DM-topic thread-id behavior from this PR is already represented in current mainline Telegram logic (and related changelog entries), so keeping this branch open now only creates duplicate review surface.\n\nIf you see a remaining edge case not covered by main, reply with a repro and we can reopen quickly. |
Fixes #17977
Summary
buildTelegramThreadParams()unconditionally returnsundefinedforscope: "dm", strippingmessage_thread_idfrom all DM sends since19b8416a8. This breaks reply targeting for bots with Telegram DM topics enabled (Bot API 9.3, Dec 31 2025).Fix
Pass through
message_thread_idwhen present (> 0) for DM scope. Only omit it for regular DMs without topics (where thread ID would be 0 or absent). Invalid values (≤ 0) are filtered at the source rather than relying on the send-path fallback to catch API rejections.Changes
src/telegram/bot/helpers.ts: Allow positive thread IDs through for DM scopesrc/telegram/bot/helpers.test.ts: Updated tests for DM topic behaviorsrc/telegram/draft-stream.test.ts: Updated draft stream test for DM topic threadingsrc/telegram/bot/delivery.test.ts: Updated delivery test to expectmessage_thread_idfor DM topicsGreptile Summary
This PR restores DM topic support that was unintentionally broken by a previous fix. The change in
buildTelegramThreadParams()now correctly passes throughmessage_thread_idfor DMs when a topic ID is present (> 0), while filtering out invalid values (≤ 0) for regular DMs without topics. This aligns with Telegram Bot API 9.3's DM topics feature.src/telegram/bot/helpers.ts:133-136to conditionally return thread params for DM scope based on thread ID valuemessage_thread_idfor DM topics instead of omitting itConfidence Score: 5/5
Last reviewed commit: e65d964
(2/5) Greptile learns from your feedback when you react with thumbs up/down!