Repository navigation
fix(ui): preserve indented code in chat - #141369
Conversation
Preserve semantic Markdown whitespace through phase extraction, assistant display, recovered-message copy, and rendering. Keep streamed indented blocks whole and literal using existing parser-owned code regions, while retaining completed-prefix reuse. Shortcode removal preserves surrounding source whitespace. Validation: 290 focused owner tests, full changed-file checks, owning test type graphs, and scoped-clean P0-P2 review. After the branch refresh, 132 Markdown/message tests, three Chromium clipboard integration cases, and the actual history/stream/copy/final UI flow pass with synthetic data.
|
🦞👀 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 7, 2026, 1:42 PM ET / 17:42 UTC. ClawSweeper reviewWhat this changesPreserves indented code through chat message extraction, display, copying, and streaming, with regression coverage and updated chat documentation. Merge readiness✅ Ready for maintainer review This remains a useful fix: pinned main still removes initial Markdown indentation. No blocking introduced defect was found, and the follow-up test changes preserve framing, provenance, and immutability assertions. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI converts stored messages and incoming assistant updates into sanitized Markdown. Shared text extraction and streaming boundaries determine which whitespace reaches the renderer and copy controls. flowchart LR
A[Stored messages] --> C[Extract visible text]
B[Assistant updates] --> C
C --> D[Preserve Markdown whitespace]
D --> E[Identify streaming code boundaries]
E --> F[Render sanitized chat]
D --> G[Copy message source]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +34, Tests +165, Docs +2. Total +201 across 17 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep semantic whitespace intact through presentation and copying, with the existing Markdown parser determining which streamed text must remain literal. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a precise trigger: a message beginning with four spaces followed by Is this the best way to solve the issue? Yes. Preserving source whitespace and reusing existing parser-owned code ranges repairs the responsible boundaries without adding a competing parser or configuration mode. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6aa09cbadb59. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Update imported-history, reasoning-suffix, and shortcode assertions to retain exact source bytes under their existing owner-specific policies. Keep framing, provenance, rich metadata, and immutability checks intact. The 13 CI failures reproduced before correction; all 373 tests in the three affected files now pass. Owning test types and full-file lint/format pass after aligning the private install with the unchanged frozen lock. Fixture-only P0-P2 review is scoped-clean. No production code changes.
|
Merged via squash.
|
…1485) markdown.test.ts exceeded the max-lines lint limit after #141369 and #141431, turning the core lint lane red for every PR rebased onto main. Move the toStreamingMarkdownParts and indented-source blocks verbatim into markdown-streaming-parts.test.ts and drop the imports the remaining file no longer uses.
…141497) Main's check-lint-core-2 job fails because markdown.test.ts reached 1011 counted lines against the 1000-line max-lines limit. PRs #141431 and #141369 passed separately but combined to cross the limit when both landed. Move the cache-separation and large-text tests into a sibling file, preserving all 115 tests and their assertions without changing production code or lint rules.
* fix(ui): preserve indented code in chat Preserve semantic Markdown whitespace through phase extraction, assistant display, recovered-message copy, and rendering. Keep streamed indented blocks whole and literal using existing parser-owned code regions, while retaining completed-prefix reuse. Shortcode removal preserves surrounding source whitespace. Validation: 290 focused owner tests, full changed-file checks, owning test type graphs, and scoped-clean P0-P2 review. After the branch refresh, 132 Markdown/message tests, three Chromium clipboard integration cases, and the actual history/stream/copy/final UI flow pass with synthetic data. * test(ui): preserve exact Markdown whitespace expectations Update imported-history, reasoning-suffix, and shortcode assertions to retain exact source bytes under their existing owner-specific policies. Keep framing, provenance, rich metadata, and immutability checks intact. The 13 CI failures reproduced before correction; all 373 tests in the three affected files now pass. Owning test types and full-file lint/format pass after aligning the private install with the unchanged frozen lock. Fixture-only P0-P2 review is scoped-clean. No production code changes.
…nclaw#141485) markdown.test.ts exceeded the max-lines lint limit after openclaw#141369 and openclaw#141431, turning the core lint lane red for every PR rebased onto main. Move the toStreamingMarkdownParts and indented-source blocks verbatim into markdown-streaming-parts.test.ts and drop the imports the remaining file no longer uses.
…penclaw#141497) Main's check-lint-core-2 job fails because markdown.test.ts reached 1011 counted lines against the 1000-line max-lines limit. PRs openclaw#141431 and openclaw#141369 passed separately but combined to cross the limit when both landed. Move the cache-separation and large-text tests into a sibling file, preserving all 115 tests and their assertions without changing production code or lint rules.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Fixes an issue where users reading Control UI messages saw indented code rendered as prose when the code appeared at the start of a message. For example,
*literal*appeared italicized. Streaming could also split one code block at blank lines and add formatting punctuation to its literal source.Why This Change Was Made
Preserve Markdown source through message extraction, display, recovered-message copying, and rendering, and use the existing Markdown parser's code ranges to keep streamed blocks intact. Existing fence/list cursors retain completed prefixes, while shortcode removal changes only the shortcode's own span.
User Impact
User and assistant messages retain initial indented code, including tabs, literal punctuation, and blank lines inside a streamed block. Copying preserves the displayed source, and removing an embed leaves surrounding Markdown whitespace intact.
Evidence
The reviewed candidate passes 290 focused Markdown/message, sanitizer, phase-extraction, and shortcode tests after the original-code regressions failed. After the branch refresh, 132 Markdown/message tests, 3 Chromium clipboard-lifetime cases, and the actual Control UI history/snapshot-stream/copy/final flow pass. Clipboard proof uses a page-local substitute and synthetic Gateway fixtures.
The unchanged reviewed patch also passed full changed-file checks, owning test type graphs, full-file lint/format, and independent P0–P2 review. A retained-prefix probe with a completed 400-line code fence and 150 later prose updates measured 52.47 ms for the candidate versus 55.29 ms for the baseline.
The initial full CI run exposed 13 stale whitespace expectations in imported-history, reasoning-suffix, and shortcode fixtures. The test-only correction preserves exact source bytes and retains all framing, provenance, metadata, and immutability assertions; all 373 tests in the three affected files pass. Both owning test type graphs and full-file lint/format pass, and the fixture-only P0–P2 review is scoped-clean. The original 14-file candidate remains byte-for-byte unchanged.
The typecheck rerun first identified a stale private dependency install (
@openclaw/fs-safe0.8.1 installed versus pinned 0.8.3). A frozen install aligned dependencies without changing the lockfile or source; the 373-test and typecheck passes above were repeated after that alignment.