Skip to content

fix(telegram): preserve forum topic origin targets#83351

Merged
steipete merged 2 commits into
mainfrom
fix/telegram-topic-originating-to-83302
May 18, 2026
Merged

fix(telegram): preserve forum topic origin targets#83351
steipete merged 2 commits into
mainfrom
fix/telegram-topic-originating-to-83302

Conversation

@steipete

@steipete steipete commented May 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #83302.

Summary

  • Preserve Telegram forum-topic routing targets when creating inbound session context, audio-preflight context, and skipped-message hook context.
  • Centralize inbound origin-target construction in buildTelegramInboundOriginTarget so DM thread ids stay metadata-only while real forum topics are encoded in-band for queued follow-up routing.
  • Add regression coverage for forum-topic OriginatingTo, skipped-message hook delivery metadata, and the origin-target helper contract.

Verification

  • Behavior addressed: Telegram forum-topic follow-up delivery keeps telegram:<chatId>:topic:<message_thread_id> as the originating target instead of flattening to the chat id while retaining only MessageThreadId metadata.
  • Real environment tested: local OpenClaw checkout plus Testbox changed-gate run on branch fix/telegram-topic-originating-to-83302.
  • Exact steps or command run after this patch: pnpm test extensions/telegram/src/bot/helpers.test.ts extensions/telegram/src/bot-message-context.body.test.ts extensions/telegram/src/bot-message-context.dm-threads.test.ts extensions/telegram/src/bot-message-context.dm-topic-threadid.test.ts; .agents/skills/autoreview/scripts/autoreview --mode local; pnpm check:changed.
  • Evidence after fix: focused Telegram tests passed 4 files / 107 tests locally; autoreview clean with no accepted/actionable findings; Testbox tbx_01krwa6t09mdem4845m0pr8qrc / GitHub Actions run https://github.com/openclaw/openclaw/actions/runs/26008265323 completed with extensions, extensionTests, and docs lanes passing.
  • Observed result after fix: inbound, audio-preflight, skipped-message hook, and helper-contract tests all preserve topic-qualified forum origins while DM thread origins remain chat-scoped.
  • What was not tested: live Telegram delivery against the Telegram API; this patch is covered by the Telegram context/regression unit path and changed gates.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by maintainer comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors can comment @clawsweeper re-review or @clawsweeper re-run on their own open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR preserves non-General Telegram forum-topic targets in inbound session, audio-preflight, and skipped-message hook contexts, with regression tests and a changelog entry.

Reproducibility: yes. at source level: current main carries the forum thread id while flattening OriginatingTo to telegram:<chatId> in the affected inbound paths. I did not establish a live Telegram reproduction in this read-only review.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Summary: The implementation looks focused and covered by regression tests, but merge readiness is blocked by missing live Telegram proof and a failed proof gate.

Rank-up moves:

  • Add redacted live Telegram forum-topic proof showing a follow-up stays in the originating non-General topic.
  • Correct or replace the PR body's Testbox evidence with a run tied to the PR head, or remove the stale cancelled run reference.
  • Re-run or request a fresh ClawSweeper review after the proof is added to the PR body.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Needs real behavior proof before merge: The PR provides tests and CI-style checks only, explicitly lacks live Telegram delivery proof, and the head has a failing real-behavior-proof check; add redacted live transcript/logs/recording before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion
A native Telegram proof would directly show whether follow-up delivery remains in the originating forum topic. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

telegram desktop proof: verify a non-General Telegram forum-topic follow-up stays in the originating topic and does not fall back to the group.

Next step before merge
This protected maintainer-labeled Telegram PR has no code blocker from review, but it needs live Telegram proof and maintainer handling rather than an automated repair task.

Security
Cleared: The diff only changes Telegram routing metadata, tests, and changelog text; I found no concrete security or supply-chain regression.

Review details

Best possible solution:

Land the helper-based routing fix after maintainer review and redacted live Telegram proof that a non-General forum-topic follow-up stays in the originating topic while General-topic and DM behavior remain unchanged.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main carries the forum thread id while flattening OriginatingTo to telegram:<chatId> in the affected inbound paths. I did not establish a live Telegram reproduction in this read-only review.

Is this the best way to solve the issue?

Yes, the proposed code direction is the narrow maintainable fix because it reuses the existing Telegram routing-target helper. Merge readiness still depends on live topic proof and maintainer handling.

What I checked:

  • Current main flattens normal inbound origin target: Current main builds reply.originatingTo from a flat telegram:<chatId> target while separately carrying messageThreadId: threadSpec.id, matching the reported split metadata path. (extensions/telegram/src/bot-message-context.session.ts:416, 5434769e47e6)
  • Current main flattens audio and skipped-message hook targets: Audio preflight and the mention-skip hook context preserve thread ids but still set OriginatingTo/originatingTo and conversation target fields to the flat chat target. (extensions/telegram/src/bot-message-context.body.ts:265, 5434769e47e6)
  • Existing helper contract supports topic-qualified routing: buildTelegramRoutingTarget already keeps real forum topic ids in-band while keeping the General topic chat-scoped, so the PR uses an existing Telegram contract rather than adding new routing policy. (extensions/telegram/src/bot/helpers.ts:329, 5434769e47e6)
  • PR diff follows the existing helper path: The PR passes a forum thread spec into the body builder and switches the affected session/body origin fields to buildTelegramRoutingTarget, with tests for audio preflight, skipped-message hooks, and normal inbound context. (extensions/telegram/src/bot-message-context.body.ts:210, 53e2f34ba588)
  • Maintainer Telegram proof standard applies: The Telegram maintainer note says behavior PRs touching topics or reply context need real Telegram proof, preferably a bot-to-bot QA lane or equivalent live probe, rather than synthetic validation only. (.agents/maintainer-notes/telegram.md:35, 5434769e47e6)
  • Head checks are mostly green but proof gate failed: GitHub checks for head 53e2f34... include many successful lanes, but the Real behavior proof check is failed; the Testbox run linked in the PR body is cancelled and points at a different head, so it does not supply live after-fix proof. (53e2f34ba588)

Likely related people:

  • Robin Waslander: Introduced the topic-qualified Telegram routing helper pattern and forum-topic routing fixes that this PR reuses. (role: adjacent feature contributor; confidence: high; commits: 3847ace25b84, 865160e57292; files: extensions/telegram/src/bot/helpers.ts, extensions/telegram/src/bot-native-commands.ts, extensions/telegram/src/bot-native-commands.session-meta.test.ts)
  • Vincent Koc: Recent Telegram body/session helper split and current-line blame connect this area to the context builders touched by the PR. (role: recent area contributor; confidence: medium; commits: 16c5bd466c42, 703a3635893a, 79212f9869b7; files: extensions/telegram/src/bot-message-context.body.ts, extensions/telegram/src/bot-message-context.session.ts, extensions/telegram/src/bot-message-context.ts)
  • Ayaan Zaidi: Recent Telegram topic cache and helper refactors touched the same topic/context helper surface. (role: recent adjacent contributor; confidence: medium; commits: c91d3d4537f3, 8465ddc1cc1e, 9905f39e9ddf; files: extensions/telegram/src/bot-message-context.session.ts, extensions/telegram/src/bot/helpers.ts)
  • Ptah.ai: Recently changed Telegram topic names in agent context and nearby tests, making them a useful reviewer for topic metadata behavior. (role: recent topic-context contributor; confidence: medium; commits: 8c43768e27b0; files: extensions/telegram/src/bot-message-context.session.ts, extensions/telegram/src/bot-message-context.dm-threads.test.ts)

Remaining risk / open question:

  • No live Telegram forum-topic delivery proof is present; the PR body explicitly says live Telegram API delivery was not tested.
  • The PR body cites a Testbox run as passing, but the public API shows that run was cancelled and not tied to the PR head.
  • The General-topic behavior must continue to stay chat-scoped because the helper intentionally omits message_thread_id=1 for sends.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 5434769e47e6.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels May 18, 2026
@clawsweeper clawsweeper Bot temporarily deployed to qa-live-shared May 18, 2026 00:52 Inactive
@openclaw-mantis

openclaw-mantis Bot commented May 18, 2026

Copy link
Copy Markdown

Mantis Telegram Desktop Proof

Summary: Mantis skipped Telegram Desktop before/after GIF proof because this PR did not have an honest native Telegram-visible before/after.

@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 18, 2026
@steipete steipete merged commit 9aa4684 into main May 18, 2026
121 of 123 checks passed
@steipete steipete deleted the fix/telegram-topic-originating-to-83302 branch May 18, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. proof: override Maintainer override for the external PR real behavior proof gate. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram forum-topic follow-up delivery can lose topic context when OriginatingTo is flattened

1 participant