Skip to content

fix(telegram): keep table before blockquote/list as sibling, not nested or dropped - #168383

Merged
steipete merged 3 commits into
openclaw:mainfrom
dhruv1220:fix/telegram-table-before-quote-list
Oct 10, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
dhruv1220:fix/telegram-table-before-quote-list

Conversation

@dhruv1220

@dhruv1220 dhruv1220 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #168366

What Problem This Solves

Fixes: Telegram rich replies nest a preceding Markdown table inside a following quote or silently omit it before a following list.

User Impact

Tables and their neighboring quotes, lists, headings, code blocks, and paragraphs retain their authored boundaries. Tables at the end of a quote or list also stay in their container. Rich delivery and the plain-text recovery path preserve every table value. No configuration, schema, protocol, or SDK surface changes are required.

Why This Change Was Made

A native table previously consumed no Markdown IR coordinates, allowing an unrelated following block to share its position. The parser now reserves one whitespace coordinate for each native table and preserves it through quote closure and final trimming. Telegram can use ordinary block ordering; its table-specific ownership heuristic is deleted. The quote boundary is calculated once for both style and structural metadata.

Original fix by @dhruv1220; maintainer cleanup moves boundary preservation to the shared Markdown parser, removes the renderer special case, and extends the regressions to sibling and trailing-container cases. The contributor's ancestry and human co-author credit are preserved.

Evidence

Validated head: 170f80fd67a7833d832543d82a1328628e6c6a0b, after merging main 1041e5562854746ed2ebeac6aaf4fa89e1357397. Contributor code ran only on secretless Untrusted AWS leases using the clean-main bootstrap, --fresh-pr, --no-hydrate, no instance role, no Tailscale, and CRABBOX_ENV_ALLOW=CI. The explicitly requested r7a.xlarge instances provided approximately 31 GiB RAM.

  • Regression: 10/10 pass, pnpm test extensions/telegram/src/rich-blocks-table-segments.test.ts --maxWorkers=1, 4.26 s wall time on lease cbx_f79179dc6dd7. The five requested adjacency cases, heading/code siblings, separate quotes, and trailing quote/list tables assert independent shapes and full content in both blocks and plainText.
  • Production-only negative control: replacing only packages/markdown-core/src/ir.ts and extensions/telegram/src/rich-blocks.ts with the pinned main versions yields 5 failing / 5 passing cases in 3.54 s, including both reported defects. Tests remain unchanged. The contributor's original prefix heuristic also failed a separate-quotes probe before the rewrite.
  • Full module/importer suites: 236 files / 2,910 tests pass, 1666.27 s wall time, covering the complete default Markdown-core, Telegram, LINE, and direct core-importer collections. The explicitly selected Telegram E2E files add 3 files / 37 tests passing in 458.78 s, and the loopback HTTP live-named file adds 1 test passing in 11.03 s. Total coverage: 240 files / 2,948 tests, with no skipped selected tests.
  • Types, lint, and format: pass for pnpm tsgo:core (70.43 s), pnpm tsgo:core:test packages (105.03 s, including extension declarations), pnpm tsgo:extensions (80.45 s), and pnpm tsgo:extensions:test (122.42 s). Remote oxfmt passes. Canonical CI changed lint passes, with the core lint shards also green. The manual all-files command using oxlint.core.json incorrectly places Telegram outside its project and reports an unresolved existing MarkdownTableCell; the repository routes plugin lint through extensions/tsconfig.json, and that correctly routed job passes. No source suppression or type workaround was added.
  • Independent Codex review: scoped-clean, no actionable P0/P1/P2 findings. This was a static review; execution proof is reported separately.
  • CI regression evidence: 10 cases pass, 0.084 CI seconds summed from rounded case timings. The containing 7-file/189-test shard took 17.56 s (19.09 s harness wall); CI does not expose standalone file-process wall time.

Real Gateway delivery proof

Fresh lease cbx_fb9af8f1df7f replayed the reporter's exact Markdown (including the bold quote and both list items) through a real isolated Gateway, the Telegram plugin, a loopback fake Telegram Bot API, and the QA mock OpenAI provider. Four main-production turns and four fixed-production turns passed: each reported input was delivered successfully as rich content and again through actual plain fallback after an injected RICH_MESSAGE_ENTITY_INVALID response. Main used the two production files reverted to the pinned base; fixed used the clean pushed head. Ports and state were isolated, and all subprocess groups were stopped.

Input Main outgoing blocks Fixed outgoing blocks
Table then quote blockquote[table, paragraph] table, blockquote[paragraph]
Table then list list (table absent) table, list

For the list case, main's actual fallback was only • follow up Acme\n• send draft. The fix sends Brand | Status\nAcme | waiting\n• follow up Acme\n• send draft. Headers, cell values, quote text, and both list items retain their authored counts in both corrected rich payloads and plain fallbacks; Acme occurs twice in the reported list input and twice after the fix. The four-turn runs took 89.97 s main / 87.49 s fixed, including startup. Another eight Gateway turns with unique content sentinels also passed on lease cbx_509169b55011. This proves Gateway and Telegram-plugin delivery against the fake API, not Telegram Test Server or client rendering.

The first live harness attempt reached a successful send but waited for an outdated success-log message. The harness receipt matcher was corrected against the current send owner, then both modes passed on the fresh lease above. That attempt is not counted as passing live proof.

Remote commands and scope
crabbox warmup --provider aws --type r7a.xlarge --network public \
  --tailscale=false --tailscale-exit-node= \
  --tailscale-exit-node-allow-lan-access=false --keep --ttl 45m --idle-timeout 15m --timing-json

CRABBOX_ENV_ALLOW=CI crabbox run --provider aws --id cbx_fb9af8f1df7f \
  --fresh-pr openclaw/openclaw#168383 --no-hydrate --timing-json \
  --script scripts/crabbox-untrusted-bootstrap.sh -- \
  170f80fd67a7833d832543d82a1328628e6c6a0b bash -c '<serial proof commands>'

node /tmp/rel7-reporter-proof/live-proof.mjs --repo "$PWD" \
  --expected-sha 170f80fd67a7833d832543d82a1328628e6c6a0b \
  --expect main --artifacts /tmp/rel7-reporter-proof/main
# Restore the two production files to the pushed head, then:
node /tmp/rel7-reporter-proof/live-proof.mjs --repo "$PWD" \
  --expected-sha 170f80fd67a7833d832543d82a1328628e6c6a0b \
  --expect fixed --artifacts /tmp/rel7-reporter-proof/fixed

# Default module/type/static checks used cbx_509169b55011 (120m TTL).
pnpm test packages/markdown-core extensions/telegram/src extensions/line/src \
  src/agents/embedded-agent-block-chunker.test.ts \
  src/agents/embedded-agent-subscribe.subscribe-embedded-agent-session.final-answer-delivery.test.ts
# Additional E2E/HTTP checks used cbx_fb9af8f1df7f after the literal replay.
node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts \
  extensions/telegram/src/telegram-ingress-coalescing.e2e.test.ts \
  extensions/telegram/src/bot.media.stickers-and-fragments.e2e.test.ts \
  extensions/telegram/src/bot.media.warning-topics.e2e.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.live.config.ts \
  extensions/telegram/src/api-fetch.live.test.ts
pnpm tsgo:core
pnpm tsgo:core:test packages
pnpm tsgo:extensions
pnpm tsgo:extensions:test
# This diagnostic lint invocation failed for plugin project resolution; canonical CI lint passed.
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json \
  packages/markdown-core/src/ir.ts extensions/telegram/src/rich-blocks.ts \
  extensions/telegram/src/rich-blocks-table-segments.test.ts
pnpm exec oxfmt --check packages/markdown-core/src/ir.ts \
  extensions/telegram/src/rich-blocks.ts \
  extensions/telegram/src/rich-blocks-table-segments.test.ts \
  docs/channels/telegram/rich-messages.md

Launches unset instance-profile and Tailscale environment overrides; the trusted bootstrap verifies the full head and IMDSv2 no-role boundary before installation. One command at a time ran per lease. All five task-owned leases (cbx_45500c926b1d, cbx_b563ed605d6f, cbx_f79179dc6dd7, cbx_509169b55011, cbx_fb9af8f1df7f) returned successful stop receipts, including failed preliminary probes.

Review and inherited CI failures

The latest full ClawSweeper review of this head found no code findings and rated the repair complete. Its missing behavior evidence and QA profile 2 attribution are supplied here. The campaign requires a secretless real Gateway with a fake Bot API; this evidence therefore does not claim Telegram Test Server or client rendering. Nested trailing tables are covered by the independent renderer regressions and full module tests. The original check-lint job 114191625449 failed only because oxfmt rejected the two original changed files; formatting is corrected and current canonical lint passes. There were no human review findings or inline comments.

The current CI aggregate remains red for inherited QA failures, not claimed green. subagent-completion-direct-fallback fails its private-completion projection assertion; memory-dreaming-sweep times out after 180000 ms with no promotion bus events. Both also fail in scheduled main QA, at main b66d8da2938da040a1db9a83851d80d59320ff5c.

PR CI used merge 921c32d976882873d3e745e7568427ef47480b31 (main 6b5284f579371f0e372b6c1882f863df19ffdb57 plus this head). It differs from that main parent only in this PR's four paths. The memory-core and memory-host-sdk trees and both scenario blobs match the independently failing main run. Both runs complete dreaming with candidates=0, applied=0; the cause of missing candidates remains outside this renderer repair. The memory scenario does not send channel messages and uses the memory owner's separate line chunker, not this Markdown IR.

Exact change size against the merged main base

Area/file Added Removed Net
Production: packages/markdown-core/src/ir.ts 12 12 0
Production: extensions/telegram/src/rich-blocks.ts 1 12 -11
Tests: extensions/telegram/src/rich-blocks-table-segments.test.ts 74 0 +74
Docs: docs/channels/telegram/rich-messages.md 2 0 +2

Production total +13/-24 = -11 LOC. No changelog edit; release-note context is preserved here. No merge performed.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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 Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR preserves parser-owned table boundaries so Telegram retains separate neighboring blocks and correctly nested tables.

Example: A Brand/Status table containing Acme/waiting precedes “- follow up Acme” and “- send draft”.

  • Before: The rich reply contains the list but drops the table.
  • After: The rich reply contains the table followed by both list items.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair and independent regressions are strong; new Gateway evidence improves confidence but leaves the required Telegram proof incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Telegram rich replies incorrectly nest a preceding table inside a following quote or silently omit it before a list.
Reason: The focused repair restores delivered content and authored structure within the existing rich-message contract.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it repairs a concrete Telegram table-loss bug still present on current main, and no actionable code defect was found.

Priority: P1
Reviewed head: 170f80fd67a7833d832543d82a1328628e6c6a0b

Before merge

  • Add real behavior proof - The body supplies reviewed-head Gateway delivery output for both reported inputs, including rich payloads and injected plain fallback, through the real Telegram plugin against a fake Bot API. This adds meaningful boundary evidence but does not satisfy root policy's Test Server userbot requirement; provide screenshots, a recording, or redacted received-event logs showing both sibling layouts and a trailing nested table, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Findings

None.

Tests

  • Missing end-to-end proof: The previous exact-head request for Test Server userbot evidence of both corrected sibling layouts and a trailing nested table remains unmet by the fake-API Gateway replay.
Agent review details

How this fits together

Shared Markdown parsing produces text coordinates and table metadata; Telegram converts them into native rich blocks and plain-text recovery content for delivery.

flowchart LR
  A[Agent Markdown] --> B[Shared Markdown parser]
  B --> C[Text coordinates and table metadata]
  C --> D[Telegram rich block renderer]
  D --> E[Delivery planner]
  E --> F[Rich message]
  E --> G[Plain recovery]
Loading

Technical review

Best possible solution:

Land the focused parser-owned boundary repair once the required Telegram evidence and normal landing gates are satisfied.

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

Current-main source establishes both failures through coincident table offsets, container sorting, and list-item filtering; the reporter supplies official-release output, and the PR reports a production-revert negative control, but this read-only review executed no target code.

Is this the best way to solve the issue?

Preserving coordinates at the shared parser fixes the ownership ambiguity directly, supports trailing nested tables, and removes the Telegram-specific heuristic without changing configuration or transport contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 92a5349b3d91.

Provenance checked

  • Native-table coordinates changes intended behavior with a stated reason (54f7221: Introduced metadata extraction for native table delivery; the PR explains why zero-width coordinates cannot distinguish siblings from container children.)
  • Quote separator trimming keeps the original intent (089d777: Excluded generated paragraph separators from quote styling; the repair retains trimming while sharing a boundary that preserves native-table coordinates.)
  • Final whitespace preservation keeps the original intent (c0f1cbf: Preserved inline-code whitespace alongside code-block whitespace; the same protection remains and gains a native-table coordinate floor.)
  • Telegram table ownership heuristic changes intended behavior with a stated reason (3d8360f: Kept outside tables separate from HTML disclosures while preserving Markdown container children; parser-owned boundaries now provide that distinction without the heuristic.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 926c896 adds packages/markdown-core/src/ir.ts:877 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 926c896c9d48; files: packages/markdown-core/src/ir.ts)
  • Ayaan Zaidi: Raw commit e3bc0f3 adds extensions/telegram/src/rich-blocks.ts:505 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e3bc0f326cb2; files: extensions/telegram/src/rich-blocks.ts)
  • sunlit-deng: Raw commit 3d8360f adds extensions/telegram/src/rich-blocks.ts:407 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 3d8360fb2428; files: extensions/telegram/src/rich-blocks.ts)
  • Vincent Koc: Raw commit 54f7221 adds src/markdown/ir.ts:420 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 54f72214654b; files: src/markdown/ir.ts)

PR surface

Source -11, Tests +74, Docs +2. Total +65 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 13 24 -11
Tests 1 74 0 +74
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 89 24 +65

Review metrics

Metric Value Why it matters
Production versus regression code Production +13/-24; tests +74/-0 The repair reduces production code while adding independent content and containment regressions for the reported failures and neighboring cases.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #168366
Summary: The open linked issue documents the exact offset-collision failures this PR repairs; canonical searches found no verified replacement for this work.

Members:

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

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: Affected official releases silently drop table values from otherwise successful Telegram rich replies.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Telegram Test Server can observe corrected table placement and preservation in rich replies.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-10T10:25:14.700Z sha a66045b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T20:23:08.459Z sha 170f80f :: needs real behavior proof before merge. :: none

Reviewed October 10, 2026, 5:31 PM ET / 21:31 UTC (Revision 3).

steipete and others added 2 commits October 10, 2026 13:03
Keep native-table coordinates through parser trimming so sibling blocks cannot claim or drop table content. Remove the Telegram table ownership heuristic and cover adjacent and trailing containers.

Original fix by @dhruv1220; maintainer cleanup moves the repair to the shared Markdown parser and simplifies Telegram block planning.

Co-authored-by: Dhruv Arora <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 10, 2026
@clawsweeper clawsweeper Bot added 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 Oct 10, 2026
@steipete
steipete merged commit c1d38ec into openclaw:main Oct 10, 2026
131 of 135 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
…ed or dropped (#168383)

Co-authored-by: Dhruv Arora <[email protected]>
(cherry picked from commit c1d38ec)
RomneyDa added a commit that referenced this pull request Oct 11, 2026
RomneyDa pushed a commit that referenced this pull request Oct 12, 2026
…ed or dropped (#168383)

Co-authored-by: Dhruv Arora <[email protected]>
(cherry picked from commit c1d38ec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

2 participants