Skip to content

fix(telegram): extract canonical rich block text#100570

Merged
openclaw-clownfish[bot] merged 1 commit into
openclaw:mainfrom
wangwllu:fix-telegram-rich-message-inbound
Jul 6, 2026
Merged

fix(telegram): extract canonical rich block text#100570
openclaw-clownfish[bot] merged 1 commit into
openclaw:mainfrom
wangwllu:fix-telegram-rich-message-inbound

Conversation

@wangwllu

@wangwllu wangwllu commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Refs #99471

What Problem This Solves

Telegram Bot API 10.1 rich-message reply/forward echoes can carry visible text only in canonical rich block fields. Current main already extracts markdown, html, and basic rich block text, but it misses several visible fields that appear in real rich-message block payloads: details summary, list item label, block-level expression, and caption objects with nested text / credit.

When those fields are the only visible content in the echoed rich_message, OpenClaw can still collapse the reply/forward context to [unsupported Telegram rich_message received], so the agent loses the message being replied to or forwarded.

This PR only addresses the rich-message block extraction addendum from #99471. It does not close the broader issue and does not attempt to fix the typing breaker or empty rich payload send behavior tracked there.

What Changed

  • Broaden Telegram inbound rich-message text extraction to include canonical visible block fields that can appear in Bot API 10.1 reply/forward echoes:
    • summary for details/collapsible blocks
    • label for list items
    • block-level expression for mathematical expression blocks
    • caption objects with text and credit
  • Keep RichText caption spans inline so table captions such as Total + bold Q1 render as Total Q1, not as separate lines.
  • Preserve the existing placeholder fallback for empty or unrenderable rich messages.

Evidence

  • Source-level reproduction: current main rich-message block flattening does not read the canonical summary, label, block-level expression, or caption-object credit fields this PR targets.
  • Shared extraction point: inbound message body, reply-target descriptions, and message-cache contexts already consume the same rich-message body helper, so the change covers the direct inbound and reply/forward context paths without adding separate parsers.
  • Regression tests passed locally:
    • node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.body.test.ts extensions/telegram/src/bot/helpers.test.ts extensions/telegram/src/message-cache.test.ts — 3 files, 133 tests passed
    • pnpm exec oxfmt --check --threads=1 extensions/telegram/src/bot/body-helpers.ts extensions/telegram/src/bot-message-context.body.test.ts extensions/telegram/src/bot/helpers.test.ts
    • git diff --check
  • Oracle second-model review:
    • First review found a valid table-caption inline-span regression risk.
    • Fixed that issue and added regression coverage.
    • Follow-up Oracle review reported no remaining actionable findings.
  • ClawSweeper source review agreed this is the narrow shared owner boundary and rated patch quality as strong, while requesting real Telegram/Mantis proof before merge.

Real Behavior Proof Status

Manual Telegram live proof captured on 2026-07-06 15:44 Asia/Shanghai using the PR candidate Gateway from commit 094dbd153e2a66077ce0dc28169e5f0acafc05ca.

Proof flow:

  1. Temporarily ran the Gateway from the PR worktree with channels.telegram.richMessages=true.
  2. Sent a Bot API 10.1 rich seed message into a private Telegram forum topic. The seed included:
    • <details><summary>OC_RICH_SUMMARY_100570</summary>...
    • <ol><li>OC_RICH_LIST_100570</li></ol>
    • <tg-math-block>OC_RICH_EXPR_100570</tg-math-block>
    • <figcaption>OC_RICH_CAPTION_100570<cite>OC_RICH_CREDIT_100570</cite></figcaption>
  3. Replied to that rich seed from a Telegram client.
  4. The agent received the reply target as visible text, not as the unsupported placeholder:
[Replying to: "OC_RICH_SUMMARY_100570 OC_RICH_BODY_100570 • OC_RICH_LIST_100570 OC_RICH_EXPR_100570OC_RICH_CAPTION_100570OC_RICH_CREDIT_100570"]
canary reply

Result: the reply context preserved the targeted summary, list label/body text, math expression, caption text, and caption credit tokens, and did not render [unsupported Telegram rich_message received] for the reply target.

No chat id, token, screenshot, or private transcript is included here; only the synthetic canary tokens and the sanitized received text are recorded.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 4:23 AM ET / 08:23 UTC.

Summary
The branch broadens Telegram rich-message block flattening to extract details summaries, list labels, mathematical expressions, and caption text/credit, with inbound and reply-target tests.

PR surface: Source +21, Tests +118. Total +139 across 3 files.

Reproducibility: yes. Current main's renderer omits the canonical fields this PR targets, so payloads whose only visible content is summary, label, block-level expression, or caption credit can still resolve to missing text or the unsupported placeholder; I did not rerun live Telegram in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #99471
Summary: This PR is a partial candidate fix for the rich-message blocks addendum in the broader open Telegram UX issue; earlier merged PRs addressed related rich-message extraction but not these canonical fields.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Mark the draft ready when the author is done so normal maintainer review and required checks can gate the exact head.

Next step before merge

  • No ClawSweeper repair is indicated; this review found no actionable patch defect, and the remaining work is normal draft-to-ready and maintainer review handling.

Security
Cleared: The diff only changes Telegram text extraction logic and tests; no dependency, workflow, secret, permission, or code-execution surface is introduced.

Review details

Best possible solution:

Land the shared rich-message resolver update after the draft is marked ready and required checks/review pass, while keeping the broader linked Telegram UX issue open for the unrelated typing and rich-send failures.

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

Yes. Current main's renderer omits the canonical fields this PR targets, so payloads whose only visible content is summary, label, block-level expression, or caption credit can still resolve to missing text or the unsupported placeholder; I did not rerun live Telegram in this read-only review.

Is this the best way to solve the issue?

Yes. The shared rich-message helper is the narrowest maintainable fix point because inbound body, reply-target, and cached context all consume it; separate parsers in each caller would create drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0c38082c6db9.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes copied live Telegram output from the exact PR head showing canary rich-message fields preserved in reply context; this is sufficient redacted live-output proof for this non-visual Telegram behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body now includes copied live Telegram output from the exact PR head showing canary rich-message fields preserved in reply context; this is sufficient redacted live-output proof for this non-visual Telegram behavior.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The PR addresses a Telegram channel reply-context message-loss bug with limited channel-specific blast radius and an open canonical issue.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body now includes copied live Telegram output from the exact PR head showing canary rich-message fields preserved in reply context; this is sufficient redacted live-output proof for this non-visual Telegram behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now includes copied live Telegram output from the exact PR head showing canary rich-message fields preserved in reply context; this is sufficient redacted live-output proof for this non-visual Telegram behavior.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change affects visible Telegram reply/forward context and can be demonstrated in a short Telegram Desktop or live transcript proof.
Evidence reviewed

PR surface:

Source +21, Tests +118. Total +139 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 22 1 +21
Tests 2 118 0 +118
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 140 1 +139

What I checked:

Likely related people:

  • obviyus: Authored and merged the recent rich-message extraction PR that introduced the shared resolver this PR extends. (role: recent rich-message extraction contributor; confidence: high; commits: 8c7050423e4e, 477b27b6f87e, 389d88b01c6e; files: extensions/telegram/src/bot/body-helpers.ts, extensions/telegram/src/bot-message-context.body.ts, extensions/telegram/src/message-cache.ts)
  • vincentkoc: PR and commit metadata show the earlier Bot API 10.1 rich-message placeholder/cache work that shaped the paths this PR extends. (role: earlier rich-message placeholder contributor and merger; confidence: high; commits: 09c74be1c656, c9815f299184, ee3b7eb7c07d; files: extensions/telegram/src/bot/body-helpers.ts, extensions/telegram/src/bot/helpers.ts, extensions/telegram/src/message-cache.ts)
  • steipete: Current-main blame for the rich-message helper comes from a recent rebase/maintenance merge touching the relevant Telegram files. (role: recent area contributor; confidence: medium; commits: 5d9cec16f356; files: extensions/telegram/src/bot/body-helpers.ts, extensions/telegram/src/bot-message-context.body.ts, extensions/telegram/src/message-cache.ts)
  • xzh-icenter: Opened the earlier merged Bot API 10.1 rich-message PR whose merge commit changed the placeholder and cache paths this PR builds on. (role: earlier rich-message PR author; confidence: medium; commits: ee3b7eb7c07d; files: extensions/telegram/src/bot/body-helpers.ts, extensions/telegram/src/bot/helpers.ts, extensions/telegram/src/message-cache.ts)
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.

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 eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an 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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-06T03:15:08.696Z sha 094dbd1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-06T03:35:16.849Z sha 094dbd1 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 6, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026
@wangwllu
wangwllu marked this pull request as ready for review July 6, 2026 08:41
@openclaw-clownfish
openclaw-clownfish Bot merged commit 314c53b into openclaw:main Jul 6, 2026
223 of 241 checks passed
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc vincentkoc changed the title [codex] fix(telegram): extract canonical rich block text fix(telegram): extract canonical rich block text Jul 6, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants