Skip to content

fix(v2026-6-9): telegram richMessages breaks paragraph breaks and table rendering#95822

Merged
obviyus merged 5 commits into
openclaw:mainfrom
zhangguiping-xydt:feat/issue-95554
Jun 24, 2026
Merged

fix(v2026-6-9): telegram richMessages breaks paragraph breaks and table rendering#95822
obviyus merged 5 commits into
openclaw:mainfrom
zhangguiping-xydt:feat/issue-95554

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Related: #95554

What Problem This Solves

Telegram rich messages can render Markdown tables, but OpenClaw's Markdown IR discarded markdown-it column alignment and the Telegram rich renderer emitted bare <table> markup. Tables from Markdown therefore lost the expected bordered/striped rich-table presentation and left/center/right alignment on Telegram rich payloads.

Why This Change Was Made

  • Preserve table alignment metadata in markdown-core's table IR.
  • Use that metadata when Telegram renders rich HTML table headers and cells.
  • Render rich Markdown tables as <table bordered striped> while keeping the existing code-block fallback for over-wide or code-mode tables.

User Impact

Telegram users with richMessages: true and Markdown table mode block receive rich table payloads that preserve visible table styling and column alignment. Plain Telegram HTML sends, explicit textMode: "html", non-Telegram renderers, and over-wide table fallback are unchanged.

Evidence

  • Branch refreshed on latest main; PR head after conflict resolution: a4e2aa295de4.

  • Current-head send-path proof, Darwin 25.5.0 / Node v24.15.0:

    [telegram] outbound send ok accountId=default chatId=123456789 messageId=95822 operation=sendRichMessage deliveryKind=text chunkCount=1
    ok: true
    sendRichMessageCalls: 1
    sendMessageFallbackUsed: false
    richMessageSource: html
    skipEntityDetection: true
    missingFragments: []
    
  • Captured rich_message.html excerpt from the same sendMessageTelegram path:

    <table bordered striped><thead><tr><th align="left">Feature</th><th align="center">Status</th><th align="right">Count</th></tr></thead><tbody><tr><td align="left">PR 95822 head a4e2aa295de4</td><td align="center">current</td><td align="right">1</td></tr><tr><td align="left">bordered striped table</td><td align="center">present</td><td align="right">2</td></tr><tr><td align="left">aligned columns</td><td align="center">present</td><td align="right">3</td></tr></tbody></table>
  • Tests and checks run after final rebase:

    pnpm test extensions/telegram/src/format.test.ts extensions/telegram/src/send.test.ts extensions/telegram/src/bot-message-dispatch.test.ts packages/markdown-core/src/ir.table-block.test.ts test/scripts/plugin-sdk-surface-report.test.ts
    Test Files 3 Vitest shards passed
    Tests 1 + 7 + 328 passed
    
    pnpm test extensions/telegram/src/draft-stream.test.ts extensions/telegram/src/bot/delivery.test.ts extensions/telegram/src/send.chunks.test.ts
    Test Files 3 passed
    Tests 109 passed
    
    pnpm check:test-types
    pnpm exec oxlint --deny=warn --ignore-path=.oxlintignore <changed files>
    pnpm build
    git diff --check
    
  • Plugin SDK surface check after maintainer cleanup:

    node scripts/plugin-sdk-surface-report.mjs --check
    
  • Full changed-file gate note: pnpm check:changed did not reach repo checks because the local crabbox binary failed its own version/help sanity check before dispatching. The narrower local tests, lint, type test check, SDK surface check, build, and path-matched send proof above completed.

  • What was not tested: live Telegram Desktop rendering was not re-run for this rebased head because no Telegram token/chat configuration is available in the current shell.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S scripts Repository scripts labels Jun 22, 2026
@zhangguiping-xydt
zhangguiping-xydt marked this pull request as draft June 23, 2026 00:42
@zhangguiping-xydt
zhangguiping-xydt marked this pull request as ready for review June 23, 2026 00:43
@zhangguiping-xydt
zhangguiping-xydt force-pushed the feat/issue-95554 branch 2 times, most recently from 8bc9d3c to 2131a96 Compare June 23, 2026 10:44
@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 9:13 AM ET / 13:13 UTC.

Summary
The PR preserves Markdown table alignment metadata in markdown-core, renders Telegram rich Markdown tables as bordered/striped/aligned HTML, updates focused tests, and refreshes plugin SDK surface budgets.

PR surface: Source +33, Tests +13, Other 0. Total +46 across 7 files.

Reproducibility: yes. for the source path: current main and v2026.6.10 emit bare rich Markdown tables and do not carry alignment metadata, while the linked issue and contributor screenshot show the visible Telegram rendering problem. I did not run a fresh live current-main Telegram repro in this read-only review.

Review metrics: 1 noteworthy metric.

  • Plugin SDK Surface: 1 public type export added, 1 optional table metadata field added. The patch promotes table alignment metadata through plugin-facing text-chunking types, which is compatibility-sensitive before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #95554
Summary: This PR is a candidate fix for the remaining Markdown rich-table styling and alignment portion of the canonical Telegram richMessages regression issue; the paragraph-break portion was separately fixed on main.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🐚 platinum hermit
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:

  • Get maintainer acceptance for the plugin SDK alignment metadata surface, or revise the PR to keep that metadata internal.

Mantis proof suggestion
Independent Telegram Desktop proof would materially help review because the changed behavior is visible rich table and paragraph rendering in the native client. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify rich Markdown paragraph breaks and bordered/striped/aligned tables render through sendRichMessage on this PR head.

Risk before merge

  • [P1] The patch promotes MarkdownTableAlignment and optional table aligns metadata through plugin-sdk/text-chunking, so maintainers should explicitly accept that public SDK contract.
  • [P1] The rich Telegram HTML payload changes for richMessages users; the final merged head should keep the proven sendRichMessage rich HTML path and table attributes intact.

Maintainer options:

  1. Accept The SDK Alignment Surface (recommended)
    Maintainers can explicitly accept MarkdownTableAlignment and optional aligns metadata as supported plugin text-chunking API before merging the focused fix.
  2. Keep Alignment Internal
    If the SDK surface should not grow, revise the PR so Telegram can use alignment metadata without exporting a new public type or metadata field.
  3. Request Independent Telegram Proof
    If maintainers want stricter live-path confidence, ask Mantis to record the current PR head rendering the rich Markdown table in Telegram Desktop.

Next step before merge

  • [P2] Maintainer review should decide whether to accept the public plugin SDK alignment metadata; there is no narrow automated repair while that API direction is open.

Security
Cleared: No concrete security or supply-chain concern found; the diff adds no dependencies, workflow changes, lockfile changes, secret handling, or downloaded-code paths.

Review details

Best possible solution:

Land the focused table-renderer fix after maintainer acceptance of the SDK alignment surface, without folding in adjacent rich-message auto-routing or config-migration work.

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

Yes for the source path: current main and v2026.6.10 emit bare rich Markdown tables and do not carry alignment metadata, while the linked issue and contributor screenshot show the visible Telegram rendering problem. I did not run a fresh live current-main Telegram repro in this read-only review.

Is this the best way to solve the issue?

Yes for the table-renderer portion: carrying markdown-it alignment metadata into the Telegram rich renderer is the narrow owner-boundary fix. The remaining solution-fit question is whether maintainers want that metadata promoted through the public plugin SDK surface.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a focused fix for a visible Telegram richMessages regression affecting users who enabled the opt-in rich-message path.
  • merge-risk: 🚨 compatibility: The diff expands the public plugin SDK text-chunking type surface with alignment metadata.
  • merge-risk: 🚨 message-delivery: The diff changes the rich Telegram HTML payload emitted for Markdown tables in the rich send/edit/draft path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Sufficient: the contributor's Telegram Desktop screenshot directly shows after-fix paragraph separation and rendered table layout, and the PR body includes current-head send-path log plus rich HTML output.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: the contributor's Telegram Desktop screenshot directly shows after-fix paragraph separation and rendered table layout, and the PR body includes current-head send-path log plus rich HTML output.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Sufficient: the contributor's Telegram Desktop screenshot directly shows after-fix paragraph separation and rendered table layout, and the PR body includes current-head send-path log plus rich HTML output.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram rich Markdown table rendering that a short Telegram Desktop proof can demonstrate.
Evidence reviewed

PR surface:

Source +33, Tests +13, Other 0. Total +46 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 40 7 +33
Tests 3 16 3 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 7 59 13 +46

What I checked:

  • Repository policy applied: Root AGENTS.md, scoped extensions/plugin-sdk/scripts AGENTS.md files, and the Telegram maintainer note were read; the review applied the Telegram visible-proof expectation and plugin SDK compatibility guidance. (AGENTS.md:1, ae9474b5fdc0)
  • Current main table output: Current main renders rich Markdown tables as bare without bordered/striped attributes or per-column align attributes. (extensions/telegram/src/format.ts:968, ae9474b5fdc0)
  • Current main IR metadata gap: Current main MarkdownTableData contains headers and rows only, and table collection does not preserve alignment metadata. (packages/markdown-core/src/ir.ts:81, ae9474b5fdc0)
  • PR renderer change: At PR head, renderTelegramRichHtmlTable applies optional align attributes to th/td cells and emits
  • . (extensions/telegram/src/format.ts:969, a4e2aa295de4)
  • PR alignment metadata path: At PR head, markdown-core adds MarkdownTableAlignment, carries optional aligns metadata, and records alignment from header tokens. (packages/markdown-core/src/ir.ts:81, a4e2aa295de4)
  • Existing rich HTML sanitizer support: Current main already allows table bordered/striped attributes and td/th align values, so the PR uses an existing Telegram rich HTML sanitizer contract. (extensions/telegram/src/format.ts:307, ae9474b5fdc0)
  • Likely related people:

    • obviyus: Authored and merged the rich HTML renderer and Markdown table support path that this PR extends. (role: rich-message renderer contributor; confidence: high; commits: da92615816b6; files: extensions/telegram/src/format.ts, extensions/telegram/src/rich-message.ts, extensions/telegram/src/send.ts)
    • amknight: Authored the merged current-main line-break fix in the shared Telegram rich-message preparation path, addressing the other half of the linked regression cluster. (role: recent adjacent rich-message fix author; confidence: high; commits: 9dbc21d28359; files: extensions/telegram/src/format.ts, extensions/telegram/src/rich-message.ts, extensions/telegram/src/send.test.ts)
    • steipete: Authored the markdown-core extraction and plugin SDK text-chunking surface refactor that owns the public type boundary touched by this PR. (role: markdown-core and plugin SDK area contributor; confidence: medium; commits: 99ffd714ce92; files: packages/markdown-core/src/ir.ts, src/plugin-sdk/text-chunking.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.

@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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 24, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

Real Telegram PC client proof

Re-tested the current Telegram rich Markdown path with a real Telegram PC client. The live message was sent through OpenClaw's Telegram rich delivery path using rich_message.markdown and was visually confirmed in the client.

Observed in the screenshot:

  • paragraph separation is preserved;
  • the Markdown table renders as a table rather than raw pipe-delimited text;
  • the table content includes the expected Feature / Expected / Count columns and rows.

Telegram PC rich Markdown proof

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 24, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 24, 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 24, 2026
@obviyus obviyus self-assigned this Jun 24, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Jun 24, 2026
@obviyus
obviyus force-pushed the feat/issue-95554 branch from f790d84 to 9839052 Compare June 24, 2026 13:40
@obviyus
obviyus merged commit f1e38f2 into openclaw:main Jun 24, 2026
43 checks passed
@obviyus

obviyus commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Scoped tests: node scripts/plugin-sdk-surface-report.mjs --check; node scripts/run-vitest.mjs extensions/telegram/src/format.test.ts extensions/telegram/src/send.test.ts extensions/telegram/src/bot-message-dispatch.test.ts packages/markdown-core/src/ir.table-block.test.ts test/scripts/plugin-sdk-surface-report.test.ts; node scripts/run-tsgo.mjs -p tsconfig.plugin-sdk.dts.json --declaration true; node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-pr95822-land.tsbuildinfo; git diff --check; .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main
  • Real Telegram proof: bot-to-bot rich table reply on the rebased head; Telegram update contained rich_message table blocks with bordered/striped table metadata and left/center/right cell alignment.
  • Changelog: not updated; release generation owns CHANGELOG.md.
  • Land commit: 9839052
  • Merge commit: f1e38f2

Thanks @zhangguiping-xydt!

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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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