Repository navigation
fix: preserve code blank lines when formatted replies split - #154875
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 9:37 AM ET / 13:37 UTC. ClawSweeper reviewWhat this changesThe shared Markdown splitter keeps internal code whitespace away from message edges where receiving services may trim it, with regression coverage for ordinary and Unicode boundaries. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main retains the problematic splitting behavior, and the supplied recipient observation isolates the repair. No blocking correctness or security finding was identified. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw parses replies into text and formatting spans, then splits them against each channel’s rendered message limit. Channel adapters deliver those formatted chunks to recipients. flowchart LR
A[Markdown reply] --> B[Parsed text and formatting]
B --> C[Rendered size splitter]
C --> D[Code and Unicode boundary checks]
D --> E[Channel formatted chunks]
E --> F[Recipient messages]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +31, Tests +23. Total +54 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep boundary selection in the shared renderer, preserving code content through transport trimming while retaining existing size and Unicode progress rules. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the trigger: escaping forces a code block to split at internal whitespace that the recipient trims. The supplied regressions and Telegram observation support it; this review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, the patch adjusts the existing shared owner using parsed code spans and the existing grapheme helper, without introducing another parser or channel-specific workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ed5937fbd981. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
landpr-approve-unrelated-red |
|
Merged as cc18d2d. The shared renderer now avoids avoidable code-whitespace cuts at message edges while retaining existing size and Unicode rules. The independent Telegram Test Server capture preserved all 1,402 intended code units, including the internal blank line; focused renderer and sibling consumer checks passed. Exact-head review passed, and the unrelated SQLite disk-budget CI failure is documented in the scoped approval above. This fix does not change final payload preparation or Telegram paragraph grouping in #153576. |
…153576) 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. Co-authored-by: Ayaan Zaidi <[email protected]>
…#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]>
…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]>
) Render-aware chunking cut the source at the limit, then re-split a chunk whose rendered form overflowed by its wrapper (for example a Telegram <pre><code> block) and emitted the overflow as its own tiny message: a ~6.8k code block arrived as 3952/48/2801 characters, broken mid-word. The overflow is now carried into the next source window, so the same block arrives as 3952/2849 with exact content; #154875 whitespace protection is unchanged. Found by our Telegram Test Server bug hunt. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#167958) Render-aware chunking cut the source at the limit, then re-split a chunk whose rendered form overflowed by its wrapper (for example a Telegram <pre><code> block) and emitted the overflow as its own tiny message: a ~6.8k code block arrived as 3952/48/2801 characters, broken mid-word. The overflow is now carried into the next source window, so the same block arrives as 3952/2849 with exact content; openclaw#154875 whitespace protection is unchanged. Found by our Telegram Test Server bug hunt. Co-authored-by: Ayaan Zaidi <[email protected]>
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
&characters, an internal blank line, and 700Bcharacters. 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.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.