fix(channels/telegram): keep reply-threads in the main chat conversation history - #10418
fix(channels/telegram): keep reply-threads in the main chat conversation history#10418metalmon wants to merge 2 commits into
Conversation
β¦ion history
Telegram sets `message_thread_id` for genuine forum topics AND for ordinary
reply-threads in supergroups. The inbound parsers derived `thread_ts` (and the
`:tid` suffix on `reply_target`) from `message_thread_id` unconditionally, so a
reply-thread forked the conversation-history key
(`{scope}_{chat}:{tid}_{tid}_{sender}`) away from the main chat
(`{scope}_{chat}_{sender}`). Replying to the bot therefore landed in a separate,
empty-on-arrival history bucket and lost all prior context, while plain messages
and @-mentions kept it.
Gate the thread derivation on `is_topic_message` via a shared `topic_thread_id`
helper used by the text, attachment, and voice parsers. Genuine forum topics
keep their intended per-topic isolation; reply-threads resolve to the main chat
key and continue the conversation. Matrix already has an equivalent carve-out in
`conversation_history_key`.
968dc87 to
a381970
Compare
Review contextHead reviewed: a381970 I reviewed the full The central approach is sound: Telegram's π΄ Blocking β Cover the attachment and voice parser boundariesThe new helper at The added regression at Please add successful-path regressions for both attachment and voice parsing that cover (a) π΄ Blocking β Complete the required PR description and validation contractThe live body currently contains only This is substantive rather than cosmetic because the missing π΅ Suggestion β Separate history identity from Telegram reply presentation
If that top-level delivery is intentional, document and test that this PR is history-only. If Telegram reply presentation should remain intact, carry the delivery anchor separately from the history-scope identity and use Telegram's reply parameters for ordinary replies, while retaining π’ What looks good β The discriminator is centralized and preserves forum isolationUsing one Validation
Suggested verdict: request changes, primarily for the missing media success-path regressions and the incomplete required PR/validation body. |
Audacity88
left a comment
There was a problem hiding this comment.
I reviewed exact head a381970a9d3cfc137d8a01a2cee86c634a42c3e7, the complete one-file diff, all three Telegram parser paths, the shared history-key consumer, #10237, the exact-head bot review, and current checks.
This is ready. I narrowed the bot feedback after applying the sole-remaining-concern test. The PR body gaps are deterministic maintainer cleanup, so I am correcting them rather than handing them back to you. The requested attachment and voice test matrix would add future-drift hardening, but it is not required to prove this patch: all three paths use the same topic_thread_id predicate, and the text regressions exercise both ordinary replies and genuine topics through a production parser.
The reply-presentation suggestion is also separate from this fix. Ordinary replies are no longer misrepresented as forum topics; adding Telegram reply_parameters would be a distinct presentation feature rather than a condition of restoring the correct history scope.
π’ What looks good β One discriminator now owns Telegram topic identity
The helper makes is_topic_message: true the only route to topic-scoped reply_target and thread_ts, so ordinary reply gestures keep the main-chat conversation while genuine forum topics remain isolated. The changed attachment, voice, and text paths all use that same rule, and the exact-head focused, parallel, workspace, feature, and required CI evidence is green.
This is approved, but per FND-003 it still requires a second independent Core Team approval before merge.
Review contextHead reviewed: cf117a3 I reviewed the complete one-file The existing top-level review identified missing attachment and voice success-path coverage on a381970. That blocker is addressed by the new head: both media parsers now exercise genuine topics and ordinary reply threads through their successful return paths. The only formal review is @Audacity88's approval of the previous head; there are no inline review threads. The current PR body contains every applicable template section, its label snapshot matches the live labels, and The current head's GitHub checks are successful, including π΄ Blocking β Remove prohibited AI attribution from the new commitCommit cf117a3 contains an AI co-author trailer and a generated session footer. That violates the repository's commit-message hygiene requirement in @metalmon, please amend or replace this unpublished commit with the same code and tests but without AI co-author or generated-session trailers. Preserve only any permitted human attribution. This is a merge blocker because the project contract forbids those footers. π‘ Warning β Refresh the public test-count evidence for the new headThe PR body's This is non-blocking because the fresh current-head CI and local validation cover the added tests; the requested change is to make the public validation trail accurate. π‘ Warning β Use a decodable JPEG fixture for the attachment regression
This is the same regression class recorded in institutional finding β Resolved β Media parser coverage now reaches both history boundariesThe earlier coverage concern is resolved on this head. That matches the actual history-key boundary in β Resolved β Reply presentation is explicitly out of scope for this fixThe current PR body states that Telegram π’ What looks good β The discriminator is centralized at the right boundary
Validation
Suggested verdict: request changes for the prohibited commit-message attribution. The two warnings can be corrected with that cleanup but do not independently block the Telegram behavior fix. |
cf117a3 to
0dce9ec
Compare
β¦t and voice parsers `topic_thread_id` is wired into three ChannelMessage-producing parse paths (text, attachment, voice), but only the text parser had a topic-gate regression. A drift in either media parser could silently reintroduce the history fragmentation this fix closes. Add success-path regressions for both media parsers, each asserting the two boundaries: a genuine forum topic (`is_topic_message: true`) keeps `chat_id:thread_id` + `thread_ts`, while an ordinary reply-thread (no `is_topic_message`) resolves to the main-chat `reply_target` with `thread_ts: None` β the same conversation-history key as a plain message. The voice test drives the full parse path (getFile, download, and a mocked Whisper transcription endpoint) so the gate is exercised at the real `Parsed` return, not before it.
0dce9ec to
624ba4a
Compare
Review contextHead reviewed: 0dce9ec I reviewed the complete one-file PR #10418 is open and mergeable. The existing formal approval is from @Audacity88 on the previous The central implementation remains sound: π‘ Warning β Refresh the stale test-count evidenceThe live PR body's This is non-blocking because exact-head GitHub CI is green and the current local focused and parallel runs cover the added tests. It is still worth correcting because π‘ Warning β Use a decodable JPEG fixture for the attachment regressionThe new attachment regression at Please reuse the existing valid fixture at β Resolved β Media parser coverage now reaches both history boundariesThe earlier review's blocking coverage concern on That matches the downstream history boundary in β Resolved β Required PR template and public metadata are presentThe current PR body contains the required Summary, Testing, Security & Privacy Impact, Compatibility, and medium/high-risk Rollback sections. It includes exact commands, CI coverage, known gaps, and the no-live-Bot-API-smoke explanation. Its label snapshot matches the live labels ( The remaining public-artifact issue is limited to the stale test counts called out above. β Resolved β Reply-presentation scope is explicitThe earlier question about whether collapsing ordinary reply threads would also change Telegram reply presentation is now explicitly scoped in the PR body: this fix changes conversation-history identity and does not introduce π’ What looks good β One discriminator owns Telegram topic identityMaking VerdictApprove. The two Validation
|
Review contextHead reviewed: 624ba4a I reviewed the complete PR #10418 is open and mergeable. The only formal approval is @Audacity88's approval on the earlier implementation head; there are no inline review threads or active π‘ Warning β Refresh the stale channel test counts in the PR bodyThe live PR body's This is non-blocking. The exact-head GitHub required gate is green, and the current local focused test, full channels test, and nextest runs cover the added tests successfully. The correction is needed for an auditable public record, not because the implementation is failing. π‘ Warning β Make the replacement JPEG fixture actually decodableThe new Please replace the hand-written bytes with a generated or otherwise verified JPEG, and validate it with β Resolved β Attachment and voice coverage now reaches the changed boundariesThe prior blocking coverage concern on the earlier implementation head is resolved here. The shared helper at Those assertions match the downstream sender-scoped history boundary in β Resolved β Required PR template and public metadata are presentThe current body includes Summary, Testing, Security & Privacy Impact, Compatibility, and the required medium/high-risk Rollback sections. It names the checks relied on, the known no-live-Bot-API gap, and the exact scope boundary. The live label set matches the body's snapshot ( β Resolved β Reply-presentation scope is explicitThe earlier question about Telegram reply presentation is now clearly scoped in the PR body: this change corrects conversation-history identity and does not introduce π’ What looks good β One discriminator owns Telegram topic identityMaking VerdictThere is no blocking implementation defect in the current head. The two Validation
|
Summary
mastermessage_thread_idfor genuine forum topics and ordinary reply gestures. The inbound parsers previously treated both as topic boundaries, so ordinary replies forked conversation history away from the main chat.topic_thread_idhelper now derives topic identity only whenis_topic_message: true, preserving real topic isolation while ordinary replies retain the main-chat history.reply_parameterspresentation behavior.reply_targetandthread_tsfields.bug,channel,experienced contributor,channel:telegram,risk:high,size:S,needs-maintainer-reviewTesting (required)
How you can test (when useful)
How I tested
Test,Parallel Runtime Test,Lint, the workspace feature checks, platform builds/checks, andCI Required Gate.reply_targetandthread_tsas a plain message, while an update markedis_topic_message: trueretains its topic ID. No live Telegram chat smoke was performed.Security & Privacy Impact (required)
Yes, describe the risk and mitigation: N/ACompatibility (required)
Noor either surface/floor question isYes: N/ARollback (required for medium/high-risk PRs)