Skip to content

fix(ui): preserve indented code in chat - #141369

Merged
steipete merged 2 commits into
mainfrom
codex/qa2-22-markdown-indentation-20260907
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa2-22-markdown-indentation-20260907

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
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-safe 0.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.

Before: initial indented messages render as emphasis

Integrated: initial indented messages retain literal code

Integrated: streaming/copy retains punctuation and blank lines

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.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 docs Improvements or additions to documentation app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 17:02
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 1:42 PM ET / 17:42 UTC.

ClawSweeper review

What this changes

Preserves 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
Reviewed head: 9f90ad9ebefdf77a24136c8d626fd384e34285f5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored PR. Its captured body reports the changed extraction and renderer exercised through browser history, streaming, copying, and final output; screenshot retrieval failed, limiting independent visual inspection without creating a contributor proof failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored PR. Its captured body reports the changed extraction and renderer exercised through browser history, streaming, copying, and final output; screenshot retrieval failed, limiting independent visual inspection without creating a contributor proof failure.
Evidence reviewed 6 items Main still contains the defect: Pinned main trims raw Markdown before both static rendering and streaming truncation, removing the indentation from an initial code block. The PR therefore addresses remaining behavior.
Existing parser owns code boundaries: The changed streaming scanner uses the repository's Markdown Core code-region parser, retains list context, and excludes parser-owned blocks from punctuation repair. The parser returns source offsets for block and inline code; this path has no affirmative Codex runtime dependency.
Re-review continuity: Compared with the previously reviewed head, only three test files change. The updated assertions preserve exact whitespace while retaining wrapper eligibility, external-content markers, rich preview metadata, and original-message immutability checks. The previous review contained no findings.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +34, Tests +165, Docs +2. Total +201 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 7 54 20 +34
Tests 9 177 12 +165
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 234 33 +201

Review metrics

None.

Technical review

Best 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 *literal* loses its indentation before rendering on pinned main. Runtime reproduction was not executed during this review.

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.

Labels

Label justifications:

  • P2: Repairs incorrect chat code rendering and copying with a limited presentation-layer blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this maintainer-authored PR. Its captured body reports the changed extraction and renderer exercised through browser history, streaming, copying, and final output; screenshot retrieval failed, limiting independent visual inspection without creating a contributor proof failure.

Evidence

What I checked:

  • Main still contains the defect: Pinned main trims raw Markdown before both static rendering and streaming truncation, removing the indentation from an initial code block. The PR therefore addresses remaining behavior. (ui/src/components/markdown.ts:548, 6aa09cbadb59)
  • Existing parser owns code boundaries: The changed streaming scanner uses the repository's Markdown Core code-region parser, retains list context, and excludes parser-owned blocks from punctuation repair. The parser returns source offsets for block and inline code; this path has no affirmative Codex runtime dependency. (ui/src/components/markdown-streaming.ts:158, 9f90ad9ebefd)
  • Re-review continuity: Compared with the previously reviewed head, only three test files change. The updated assertions preserve exact whitespace while retaining wrapper eligibility, external-content markers, rich preview metadata, and original-message immutability checks. The previous review contained no findings. (ui/src/pages/chat/components/chat-imported-history.test.ts:124, 9f90ad9ebefd)
  • Captured behavior evidence and inspection limits: The supplied body at sourceRevision 16ec895d50e0a171e9b4cabbf86e38b7d4a027f5e6e2bfe59257093d213c0061 reports an actual Control UI history, streaming, copy, and final-message flow with synthetic Gateway data and a substituted clipboard. The matching browser test exercises initial user/assistant code and a streamed block containing literal punctuation and blank lines. All three supplied screenshot URLs returned fetch errors during review, so their visual contents were not independently verified. No tests were executed in this read-only review. (ui/src/e2e/chat-code-block-fences.e2e.test.ts:79, 9f90ad9ebefd)
  • Relevant merged-area history: Main history identifies Peter Steinberger's streaming ownership and transcript-rendering work and Vyctor H. Brzezowski's incremental streaming scan work. These support routing suggestions, not source-line introduction attribution. (ui/src/components/markdown-streaming.ts, 215de48bd51a)
  • Scope, security, and release checks: The complete introduced patch changes text preservation, streaming parsing, tests, and documentation; it adds no dependency, permission, persistent schema, or authority-bearing value. HTML sanitization remains in place. The supplied context establishes a protected maintainer PR. Live related-PR lookup failed to connect, and the latest-release source blob was unavailable locally, so no merged replacement or shipped fix is asserted. Final git status remained clean. (ui/src/components/markdown.ts:537, 9f90ad9ebefd)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vyctor H. Brzezowski: 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 (1 earlier review cycle)
  • reviewed 2026-09-07T17:09:16.648Z sha 8ec33ea :: blocked before merge. :: none

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.
@steipete
steipete merged commit c574f43 into main Sep 7, 2026
187 checks passed
@steipete
steipete deleted the codex/qa2-22-markdown-indentation-20260907 branch September 7, 2026 18:54
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 7, 2026
…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.
steipete added a commit that referenced this pull request Sep 7, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
* 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

1 participant