Skip to content

fix(telegram): code blocks lose blank lines when replies are split - #153576

Merged
obviyus merged 5 commits into
openclaw:mainfrom
SunnyShu0925:fix/chunk-indented-code-split-076
Sep 21, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
SunnyShu0925:fix/chunk-indented-code-split-076

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #154857, #154875

What Problem This Solves

Fixes indented code blocks being divided at internal blank lines or reparsed as prose when Telegram replies exceed the paragraph-mode message limit.

User Impact

Telegram code snippets keep their internal blank lines and code formatting while ordinary prose paragraph grouping and configured message limits continue to work.

Why This Change Was Made

Paragraph grouping now uses the existing canonical code-region parser. Oversized Markdown paragraphs reach Telegram's existing parsed, render-aware splitter intact instead of being split twice as raw Markdown. The channel sender applies the existing configured limits and per-delivery overrides.

The producer and renderer prerequisites have landed separately in #154857 and #154875. This PR contains only the remaining nine-file paragraph/Telegram delivery change; it adds no whitespace truncation or deferred-whitespace policy, parser, configuration key, dependency, or CI change.

Thanks to @SunnyShu0925 for the original chunker repair and for removing the unrelated changes. Their latest contributor commit remains in this branch's ancestry.

Evidence

  • With both prerequisites present on main 900f00302f5, the focused paragraph regression still fails against main's chunker: one indented code block becomes two paragraph chunks. Restoring the candidate owner makes that same regression pass.

  • Fresh built-Gateway proof exercised the registered send RPC through durable outbound delivery and the real leased Telegram Test Server, without a model generating the message. At newline mode and a 256-unit limit, the recipient received three native code entities of 232, 24, and 2 UTF-16 units. Their combined text exactly preserved both 128-character code lines and the internal blank line. The run completed and removed credential scratch state. One unrelated mocked Activity recap request was recorded and distinguished from message generation.

  • Earlier real-recipient indented-code, hard-Unicode/combining/ZWJ, and ordinary-prose controls remain applicable: the production owner-file hashes, including the now-merged prerequisites, match the tested cleaned source. The two consumer regressions now live in focused sibling suites with the same assertions and existing test support. The related parser, grapheme, Telegram formatter/sender, delivery-plan, and dependency-lock inputs are unchanged. These controls were retained rather than rerun merely for integration; Telegram's omission of the renderer-added terminal newline is recorded explicitly.

  • The four affected owner test files previously passed 532 tests in 41.21 seconds. Additional prerequisite/renderer consumer coverage is recorded with the two merged PRs. The integrated runtime build passed, including 95 bundled plugins and the bootstrap/control-plane checks; scoped core and Telegram type-aware lint also passed against the integrated main contracts.

  • After relocating the consumer regressions out of oversized suites, both focused tests passed through the maintained Telegram test registration in 24.92 seconds (22 ms and 13 ms test bodies). Scoped formatting and type-aware lint passed, and the line-cap ratchet passed against the exact CI main parent. Production source is byte-identical to the real-recipient-tested revision; no runtime build or native send was repeated for this test-only move.

No screenshots, native-client automation, or live verification of other channels are claimed.

@clawsweeper

clawsweeper Bot commented Sep 20, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 2:06 PM ET / 18:06 UTC (Revision 26).

ClawSweeper review

What this changes

Preserves blank lines and formatting in split Telegram code replies by protecting complete code regions and letting Telegram’s renderer own message splitting.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary after the merged prerequisites. The focused implementation and recorded real Telegram recipient proof support it, and no blocking correctness or security finding remains.

Priority: P2
Reviewed head: ef73ec115e179403794aca34d2b1e3116f2fb535

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant real-recipient proof and no identified blocking defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded built-Gateway send RPC evidence reaches the changed Telegram delivery owners and a real Test Server recipient, preserving the exact internal code text under a 256-unit newline-mode limit; retained Unicode and prose controls supplement that result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded built-Gateway send RPC evidence reaches the changed Telegram delivery owners and a real Test Server recipient, preserving the exact internal code text under a 256-unit newline-mode limit; retained Unicode and prose controls supplement that result.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head patch: paragraph code-region detection, Telegram splitting ownership and option forwarding, and focused regressions. Unrelated base-branch changes are outside this PR’s introduced delta.
Current main still has the defect: Current main protects only fenced code in paragraph grouping and still pre-splits Markdown before Telegram rendering. Two indented 128-character lines separated by a blank line exceed a 256-unit budget and are treated as separate paragraphs.
Latest release retains fenced-only grouping: Inspection of the supplied latest release commit found parseFenceSpans(normalized) and isSafeFenceBreak in paragraph grouping; the remaining repair is not already present there.
Findings None None.
Security None None.

How this fits together

OpenClaw’s reply pipeline passes Markdown and delivery settings to the Telegram plugin. The plugin groups paragraphs, renders bounded messages, and sends them to the recipient.

flowchart TD
  A[Reply Markdown] --> B[Telegram delivery adapter]
  C[Account limits and delivery overrides] --> B
  B --> D[Code-aware paragraph grouping]
  D --> E[Rendered message splitting]
  E --> F[Telegram recipient]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests -78. Total -79 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 26 27 -1
Tests 4 97 175 -78
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 123 202 -79

Review metrics

None.

Technical review

Best possible solution:

Keep code intact through paragraph grouping and use the existing Telegram renderer as the single owner of bounded message splitting.

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

Yes: current main’s fenced-only paragraph guard splits the supplied oversized indented-code fixture at its internal blank line. This review establishes the path from source; it did not execute a reproduction.

Is this the best way to solve the issue?

Yes: the patch reuses canonical code-region detection and the existing rendered-size splitter, removing redundant raw-Markdown splitting while carrying existing delivery settings to their owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 14393070236e.

Labels

Label justifications:

  • P2: Repairs code formatting and internal whitespace preservation in oversized Telegram replies with limited blast radius.
  • 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 (live_output): Recorded built-Gateway send RPC evidence reaches the changed Telegram delivery owners and a real Test Server recipient, preserving the exact internal code text under a 256-unit newline-mode limit; retained Unicode and prose controls supplement that result.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded built-Gateway send RPC evidence reaches the changed Telegram delivery owners and a real Test Server recipient, preserving the exact internal code text under a 256-unit newline-mode limit; retained Unicode and prose controls supplement that result.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Code formatting and blank-line preservation are Telegram-visible behavior, and the recorded Test Server recipient evidence covers them.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head patch: paragraph code-region detection, Telegram splitting ownership and option forwarding, and focused regressions. Unrelated base-branch changes are outside this PR’s introduced delta. (extensions/telegram/src/outbound-adapter.ts:423, ef73ec115e17)
  • Current main still has the defect: Current main protects only fenced code in paragraph grouping and still pre-splits Markdown before Telegram rendering. Two indented 128-character lines separated by a blank line exceed a 256-unit budget and are treated as separate paragraphs. (src/auto-reply/chunk.ts:225, 14393070236e)
  • Latest release retains fenced-only grouping: Inspection of the supplied latest release commit found parseFenceSpans(normalized) and isSafeFenceBreak in paragraph grouping; the remaining repair is not already present there. (src/auto-reply/chunk.ts:224, ec9c1a13db89)
  • Merged prerequisites are complementary: GitHub REST confirmed the producer prerequisite fix(agents): preserve leading code indentation in final reply payloads #154857 and renderer prerequisite fix: preserve code blank lines when formatted replies split #154875 are merged. Their supplied descriptions expressly exclude Telegram paragraph grouping, consistent with current source.
  • Limits remain owned by the Telegram sender: The adapter forwards existing delivery-time textLimit and chunkMode settings. The sender clamps the requested limit against the account/platform resolver and invokes the existing page planner; explicit HTML retains its HTML splitter. No config key, storage format, dependency, or authorization contract is introduced. (extensions/telegram/src/send-message-text.ts:297, ef73ec115e17)
  • Real recipient proof: The captured PR body, sourceRevision d72c496badd6ba42e1d8de98ca3e80f650d20de175e4d2267ee38b9593a6a534, records a built Gateway send RPC through durable delivery to the leased Telegram Test Server. With newline mode and a 256-unit limit, three received native code entities contained 232, 24, and 2 UTF-16 units, preserving both 128-character lines and their internal blank line. It distinguishes Telegram’s omitted terminal framing newline, an unrelated mocked Activity request, and retained Unicode/prose controls. The final commit relocates tests; the body records unchanged tested production bytes. (ef73ec115e17)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (25 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-21T07:37:52.775Z sha 2096511cb7129d54ba4d1aef4050548b664fe050 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T07:53:12.543Z sha 2096511cb7129d54ba4d1aef4050548b664fe050 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T08:01:13.059Z sha 2096511cb7129d54ba4d1aef4050548b664fe050 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T08:50:40.434Z sha 1483dfcfac4b976813927064a7ae290c72f6fc0d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T14:05:07.590Z sha f04d5e3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-21T16:15:26.533Z sha 17cf6f7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T16:44:50.126Z sha ef73ec1 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T17:13:17.934Z sha ef73ec1 :: needs maintainer review before merge. :: none

@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 6120677 to 240468a Compare September 20, 2026 09:17
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 20, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 240468a to 385e809 Compare September 20, 2026 15:28
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 385e809 to 58d9b27 Compare September 20, 2026 15:47
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 58d9b27 to effe83a Compare September 20, 2026 16:00
@openclaw-barnacle openclaw-barnacle Bot added the channel: whatsapp-web Channel integration: whatsapp-web label Sep 20, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch 2 times, most recently from 5d82356 to 190f393 Compare September 20, 2026 16:45
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 20, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 190f393 to 8ae3661 Compare September 21, 2026 03:06
@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch 6 times, most recently from 687da72 to ab7ff1b Compare September 21, 2026 05:10
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Hi @obviyus — thanks for opening #154857 and #154875. I've read both and want to make sure #153576 aligns with how you'd like this split to land, rather than overlapping or competing with your two PRs.

As I read them, the three touch different layers:

The file sets don't overlap, so they look complementary rather than redundant. But your split suggests you'd prefer each layer fixed on its own, and #153576 is currently blocked on Telegram Test Server recipient proof that this machine can't produce (no Test Server credentials; ClawSweeper's reviewer request was also rejected before execution).

A couple of options, and I'm happy to follow whichever you prefer:

A. Keep #153576 scoped to just the src/auto-reply/chunk.ts chunker fix (drop the whatsapp test additions and the CI dedupe if you'd rather those move separately), and I'll keep iterating on proof.

B. Close #153576 in favor of your two PRs, if you intend the chunker-layer protection to be handled differently or not at all.

C. Something else — e.g. rebase #153576 on top of #154857 + #154875 once they land, if the chunker fix is still wanted as a third piece.

Which direction would you like? I don't want to keep pushing a large PR that cuts across the layers you've deliberately separated.

chunkByParagraph used parseFenceSpans (only fenced code) to guard
paragraph breaks, so blank lines inside 4-space indented code blocks split
the block mid-content and stripped indentation. Switch to findCodeRegions
which covers fenced, indented, and inline code. Long paragraphs now route
through chunkMarkdownText so fence-aware splitting and reopening apply to
indented code too, instead of the code-unaware chunkText fast path.
@SunnyShu0925
SunnyShu0925 force-pushed the fix/chunk-indented-code-split-076 branch from 1483dfc to f04d5e3 Compare September 21, 2026 13:51
@openclaw-barnacle openclaw-barnacle Bot removed channel: whatsapp-web Channel integration: whatsapp-web scripts Repository scripts labels Sep 21, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

Hi @obviyus — following up on my earlier question. I've gone ahead and narrowed this PR to align with the per-layer split you started with #154857 and #154875.

What I changed in this push (head f04d5e3):

So #153576 now covers only the chunkByParagraph / chunkMarkdownText layer: switching from parseFenceSpans to findCodeRegions so 4-space indented code blocks are protected when replies are split into messages. That leaves #154857 (producer payload) and #154875 (renderer IR splitter) as the other two independent pieces, with no file overlap between the three.

I'm not trying to push this ahead of your two PRs — happy to rebase on top of them once they land, close it if you'd rather fold the chunker fix in differently, or leave it sitting here until you decide. Whatever's least work for you. Just wanted to help with the chunking path since it was the original gap. Thanks for untangling the layers — the split makes the whole thing much easier to reason about.

obviyus added a commit that referenced this pull request Sep 21, 2026
Related: #153576

## What Problem This Solves

Fixes internal blank lines disappearing when formatted code exceeds a message limit and the receiving service trims whitespace at message edges.

## User Impact

Long code replies retain their internal blank lines across message boundaries. Ordinary prose splitting, size limits, Unicode boundaries, and existing progress behavior for impossible budgets remain unchanged.

## Why This Change Was Made

The existing rendered-size splitter now uses its parsed code spans to avoid placing internal code whitespace at message edges when a content-bearing cut fits. It preserves the source rather than dropping or deferring whitespace, with no new parser, configuration, or public API.

This is an independent renderer prerequisite for #153576; it does not change final-reply payload preparation or Telegram paragraph grouping.

## Evidence

- Real Telegram Test Server recipient proof from a checkout containing only this two-file renderer patch: a fenced reply containing 700 `&` characters, an internal blank line, and 700 `B` characters. Its 1,410-character Markdown source stays below the existing 4,000-character raw limit, while HTML escaping requires rendered-size splitting. The recipient received two native code entities of 1,176 and 226 UTF-16 units; their combined text exactly preserved all 1,402 intended code units, including the internal blank line. No payload-preparation or Telegram-adapter prerequisite was present.
- Both new soft-boundary and hard-Unicode regressions failed before the renderer repair. The focused renderer suite passed all 33 tests, including existing impossible-budget and grapheme cases; its latest Vitest duration was 0.249 seconds.
- Retained earlier native evidence, with final-payload and paragraph-handling fixes present but this renderer repair absent, still lost the blank line between code messages. The standalone capture above uses a different fixture; it is not a matched independent before/after pair.
- Existing Telegram, Google Chat, Signal, Slack, SMS, and WhatsApp consumer tests passed: 11 files across eight shards in 57.87 seconds. These are local consumer checks, not live verification of the other services.
- Type-aware lint passed. The independent checkout's QA runtime build passed, including all 95 bundled plugins and the bootstrap/control-plane checks.

The native observation excludes Telegram's omission of the code block's terminal framing newline; the authored internal blank line was preserved. The maintained runner completed successfully and removed its credential scratch state.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Sep 21, 2026
#154857)

Related: #153576

## What Problem This Solves

Fixes indented code losing its leading spaces when the embedded agent prepares its final reply payload.

## User Impact

CLI JSON consumers and downstream renderers receive the authored code indentation instead of a first line that looks like ordinary prose. Ordinary prose padding is still trimmed, and existing empty or hidden-only reply suppression is unchanged. No configuration or storage migration is required.

## Why This Change Was Made

Final payload preparation used generic optional-string normalization after the assistant text had already been preserved. It now uses the existing code-aware trim owner at that boundary. No parser, new API, or channel-specific policy is added.

This is the independent producer fix only. It does not change paragraph chunking or Telegram page rendering and does not claim to complete the separate channel-splitting repair.

## Evidence

- Independently reproduced through the supported `openclaw agent --local --json` command on pinned main `10c229159ceb9ae4fe42b40495d718256d68a3fc`, using an isolated configured provider and the existing loopback HTTP fixture. The provider supplied 266 bytes of indented code, and the canonical persisted assistant still contained all 266 bytes, but the public CLI payload contained only 262 bytes: the first four spaces were lost.
- With only this two-file change applied, the same public CLI path returned the exact 266-byte code fixture. A padded ordinary-prose control returned the same trimmed 15-byte answer on both baseline and candidate. Each model completed one real HTTP request to the loopback fixture; no direct calls or stubs replaced the payload builder or runner.
- The retained focused negative control fails code preservation on the original owner while its prose control passes. The isolated candidate's payload and payload-error suites passed **105 tests** in **34.78 seconds** total runner time. The shards took 24.69 and 7.31 seconds, primarily transformation/import work; the added code regression took 3 ms.
- The runtime build passed, including 95 bundled plugin builds and 53 built control-plane checks. Scoped type-aware lint, formatting, and both source-size ratchets passed. All owned providers and observed CLI children settled, and both proof ports closed.

Proof used local Node 24.21.0, fresh synthetic state and credentials, and loopback transport. It does not claim a Gateway/channel delivery, a live paid provider, or the combined Telegram fix. Both sides retain SQLite automatic-maintenance stale-input warnings; the command outcomes and canonical transcript assertions completed successfully. No external operation was admitted.

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus obviyus changed the title fix(reply): preserve indented code blocks when chunking messages fix(telegram): code blocks lose blank lines when replies are split Sep 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the channel: telegram Channel integration: telegram label Sep 21, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 21, 2026
@obviyus obviyus closed this Sep 21, 2026
@obviyus obviyus reopened this Sep 21, 2026
@obviyus obviyus closed this Sep 21, 2026
@obviyus obviyus reopened this Sep 21, 2026
@obviyus

obviyus commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 153576
head: ef73ec1
run: 35635347405 attempt: 1
failed: checks-node-compact-large-27 job=106452263159 conclusion=failure
failed: checks-node-compact-large-30 job=106452267493 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit 2e6c53b into openclaw:main Sep 21, 2026
601 of 617 checks passed
@obviyus

obviyus commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2e6c53b.

Telegram paragraph-mode delivery now preserves indented code and its internal blank lines through the existing renderer. Verified with real Telegram Test Server recipient captures, the registered Gateway send RPC, and focused paragraph, Unicode, and prose controls. The final structural and corrected-consumer checks passed; the two unrelated approval/recovery CI failures are documented in the maintainer approval.

Thanks @SunnyShu0925 for the original repair and for narrowing the PR to keep the fixes complementary.

@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@obviyus Thanks~

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…#154875)

Related: openclaw#153576

## What Problem This Solves

Fixes internal blank lines disappearing when formatted code exceeds a message limit and the receiving service trims whitespace at message edges.

## User Impact

Long code replies retain their internal blank lines across message boundaries. Ordinary prose splitting, size limits, Unicode boundaries, and existing progress behavior for impossible budgets remain unchanged.

## Why This Change Was Made

The existing rendered-size splitter now uses its parsed code spans to avoid placing internal code whitespace at message edges when a content-bearing cut fits. It preserves the source rather than dropping or deferring whitespace, with no new parser, configuration, or public API.

This is an independent renderer prerequisite for openclaw#153576; it does not change final-reply payload preparation or Telegram paragraph grouping.

## Evidence

- Real Telegram Test Server recipient proof from a checkout containing only this two-file renderer patch: a fenced reply containing 700 `&` characters, an internal blank line, and 700 `B` characters. Its 1,410-character Markdown source stays below the existing 4,000-character raw limit, while HTML escaping requires rendered-size splitting. The recipient received two native code entities of 1,176 and 226 UTF-16 units; their combined text exactly preserved all 1,402 intended code units, including the internal blank line. No payload-preparation or Telegram-adapter prerequisite was present.
- Both new soft-boundary and hard-Unicode regressions failed before the renderer repair. The focused renderer suite passed all 33 tests, including existing impossible-budget and grapheme cases; its latest Vitest duration was 0.249 seconds.
- Retained earlier native evidence, with final-payload and paragraph-handling fixes present but this renderer repair absent, still lost the blank line between code messages. The standalone capture above uses a different fixture; it is not a matched independent before/after pair.
- Existing Telegram, Google Chat, Signal, Slack, SMS, and WhatsApp consumer tests passed: 11 files across eight shards in 57.87 seconds. These are local consumer checks, not live verification of the other services.
- Type-aware lint passed. The independent checkout's QA runtime build passed, including all 95 bundled plugins and the bootstrap/control-plane checks.

The native observation excludes Telegram's omission of the code block's terminal framing newline; the authored internal blank line was preserved. The maintained runner completed successfully and removed its credential scratch state.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
openclaw#154857)

Related: openclaw#153576

## What Problem This Solves

Fixes indented code losing its leading spaces when the embedded agent prepares its final reply payload.

## User Impact

CLI JSON consumers and downstream renderers receive the authored code indentation instead of a first line that looks like ordinary prose. Ordinary prose padding is still trimmed, and existing empty or hidden-only reply suppression is unchanged. No configuration or storage migration is required.

## Why This Change Was Made

Final payload preparation used generic optional-string normalization after the assistant text had already been preserved. It now uses the existing code-aware trim owner at that boundary. No parser, new API, or channel-specific policy is added.

This is the independent producer fix only. It does not change paragraph chunking or Telegram page rendering and does not claim to complete the separate channel-splitting repair.

## Evidence

- Independently reproduced through the supported `openclaw agent --local --json` command on pinned main `c84ec3940151ebdf3050161cfdad976f9a7a7e82`, using an isolated configured provider and the existing loopback HTTP fixture. The provider supplied 266 bytes of indented code, and the canonical persisted assistant still contained all 266 bytes, but the public CLI payload contained only 262 bytes: the first four spaces were lost.
- With only this two-file change applied, the same public CLI path returned the exact 266-byte code fixture. A padded ordinary-prose control returned the same trimmed 15-byte answer on both baseline and candidate. Each model completed one real HTTP request to the loopback fixture; no direct calls or stubs replaced the payload builder or runner.
- The retained focused negative control fails code preservation on the original owner while its prose control passes. The isolated candidate's payload and payload-error suites passed **105 tests** in **34.78 seconds** total runner time. The shards took 24.69 and 7.31 seconds, primarily transformation/import work; the added code regression took 3 ms.
- The runtime build passed, including 95 bundled plugin builds and 53 built control-plane checks. Scoped type-aware lint, formatting, and both source-size ratchets passed. All owned providers and observed CLI children settled, and both proof ports closed.

Proof used local Node 24.21.0, fresh synthetic state and credentials, and loopback transport. It does not claim a Gateway/channel delivery, a live paid provider, or the combined Telegram fix. Both sides retain SQLite automatic-maintenance stale-input warnings; the command outcomes and canonical transcript assertions completed successfully. No external operation was admitted.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…penclaw#153576)

Related: openclaw#154857, openclaw#154875

## What Problem This Solves

Fixes indented code blocks being divided at internal blank lines or reparsed as prose when Telegram replies exceed the paragraph-mode message limit.

## User Impact

Telegram code snippets keep their internal blank lines and code formatting while ordinary prose paragraph grouping and configured message limits continue to work.

## Why This Change Was Made

Paragraph grouping now uses the existing canonical code-region parser. Oversized Markdown paragraphs reach Telegram's existing parsed, render-aware splitter intact instead of being split twice as raw Markdown. The channel sender applies the existing configured limits and per-delivery overrides.

The producer and renderer prerequisites have landed separately in openclaw#154857 and openclaw#154875. This PR contains only the remaining nine-file paragraph/Telegram delivery change; it adds no whitespace truncation or deferred-whitespace policy, parser, configuration key, dependency, or CI change.

Thanks to @SunnyShu0925 for the original chunker repair and for removing the unrelated changes. Their latest contributor commit remains in this branch's ancestry.

## Evidence

- With both prerequisites present on main `017c9d2a8c9`, the focused paragraph regression still fails against main's chunker: one indented code block becomes two paragraph chunks. Restoring the candidate owner makes that same regression pass.
- Fresh built-Gateway proof exercised the registered `send` RPC through durable outbound delivery and the real leased Telegram Test Server, without a model generating the message. At newline mode and a 256-unit limit, the recipient received three native code entities of 232, 24, and 2 UTF-16 units. Their combined text exactly preserved both 128-character code lines and the internal blank line. The run completed and removed credential scratch state. One unrelated mocked Activity recap request was recorded and distinguished from message generation.
- Earlier real-recipient indented-code, hard-Unicode/combining/ZWJ, and ordinary-prose controls remain applicable: the production owner-file hashes, including the now-merged prerequisites, match the tested cleaned source. The two consumer regressions now live in focused sibling suites with the same assertions and existing test support. The related parser, grapheme, Telegram formatter/sender, delivery-plan, and dependency-lock inputs are unchanged. These controls were retained rather than rerun merely for integration; Telegram's omission of the renderer-added terminal newline is recorded explicitly.
- The four affected owner test files previously passed 532 tests in 41.21 seconds. Additional prerequisite/renderer consumer coverage is recorded with the two merged PRs. The integrated runtime build passed, including 95 bundled plugins and the bootstrap/control-plane checks; scoped core and Telegram type-aware lint also passed against the integrated main contracts.

- After relocating the consumer regressions out of oversized suites, both focused tests passed through the maintained Telegram test registration in 24.92 seconds (22 ms and 13 ms test bodies). Scoped formatting and type-aware lint passed, and the line-cap ratchet passed against the exact CI main parent. Production source is byte-identical to the real-recipient-tested revision; no runtime build or native send was repeated for this test-only move.

No screenshots, native-client automation, or live verification of other channels are claimed.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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