Skip to content

fix(ui): preserve code formatting in human messages - #186779

Merged
vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/human-code-blocks
Oct 30, 2026
Merged

vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/human-code-blocks

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Closes #186778

What Problem This Solves

Fixes code fences and indented code rendering as prose inside human chat messages.

User Impact

Code blocks retain their lines and indentation, use a monospaced font and a distinct surface, and scroll horizontally without widening the message or chat. Existing bubble styling and inline code are preserved.

Why This Change Was Made

Remove the human-message overrides that undo the shared code styles, while retaining static rendering without assistant toolbars. Folded messages remain previews: expanding with Show more enables code scrolling and keyboard access, so hidden code cannot steal focus or shift the folded content.

Evidence

  • Sent mixed Markdown through the composer in an isolated real Gateway; inspected the same saved messages before and after at 1440px/light and 390px/dark. No injected product state, synthetic events, or network delays.
  • Code text and bubble widths were preserved; no transcript/page horizontal overflow. Copy code and Copy as markdown retained the original contents.
  • Verified native keyboard scrolling after expansion, and that folded code is skipped without moving the preview.
  • All 14 selected existing code-block, typography, and message-disclosure E2Es passed. Extended one existing case for the keyboard regression; it failed without the folded-preview fix. No new test cases.
  • Stylesheet lint, focused test lint, UI typecheck, formatting, and independent Codex review passed.

The captures below use the actual OpenClaw UI and a test conversation. Desktop images are cropped from viewport frames; the sample text is unchanged.

ThemeBeforeAfter
Light · desktop 1440 pxBefore: human code blocks in the light themeAfter: human code blocks in the light theme
Dark · mobile 390 pxBefore: human code blocks on mobile in the dark themeAfter: human code blocks on mobile in the dark theme

Follow-up validation

Nested human code now uses the existing chat block-spacing token, preserving the surrounding 14px rhythm independently of the restored 12px mobile code font. The existing spacing regression fails with the former 1em margin and passes with the token.

The stack incorporates main 8dad19d8b7b, including the already-landed idle-render, typography sampling, and provider-notice fixes. The combined tree passed 24 focused presentation/contrast/browser tests, 39 code/table/disclosure/attachment E2E cases, stylesheet lint, targeted lint, formatting, and the UI typecheck. The scoped repair also passed independent review.

The mobile comparison below uses the same mocked-Gateway conversation and integrated source tree; only the nested-code margin differs.

Former font-relative margin Restored message spacing
Before: nested code uses 12px gaps After: nested code keeps the 14px message rhythm

@vyctorbrzezowski vyctorbrzezowski self-assigned this Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 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.

@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review October 28, 2026 13:30
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restores shared code formatting and horizontal scrolling in human messages while keeping folded previews non-scrollable.

Example: A human sends a fenced JavaScript block with an indented return statement and a long function call at a 390px viewport.

  • Before: The block uses prose typography and wraps the long call inside the message.
  • After: The block preserves code lines and indentation on a monospaced surface, with scrolling available after message expansion.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused change with inspected product screenshots, a meaningful extension of an existing regression, and the previous finding resolved.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected desktop-light and mobile-dark before/after captures show the changed CSS rendering human code correctly in the actual Control UI; the body documents real-Gateway composer submission, copying, and expanded-versus-folded keyboard behavior, and the additional mobile comparison covers the spacing repair.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Preference · Worth it: Yes · Fix scope: Complete
User problem: Code in human messages blends into prose and wraps long lines, making technical conversations harder to read.
Reason: History shows the typography was intentional, but this maintainer-authored revision supplies owner direction and concrete visual evidence for preserving code formatting.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current rendering problem, resolves the previous spacing finding, and has no remaining actionable findings; normal CI gates are still pending.

Priority: P2
Reviewed head: 11449c12240b99ff9fb20ed8ba3e9ac9673c5319

Before merge

None.

Findings

None.

Agent review details

How this fits together

Control UI renders saved human-message Markdown as static pre and code elements; shared chat CSS controls their presentation, while the existing message disclosure controls long-message previews.

flowchart LR
  A[Human message Markdown] --> B[Chat message presentation]
  B --> C[Shared Markdown renderer]
  C --> D[Static code elements]
  D --> E[Shared chat code styles]
  E --> F[Message disclosure preview]
Loading

Technical review

Best possible solution:

Use the existing shared code styles and disclosure owner, preserving nested message spacing through --chat-block-gap.

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

Current-main CSS directly explains the reported rendering, and the supplied before screenshots show it; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair: remove the conflicting human-code overrides, preserve the existing static renderer, and prevent folded code from becoming a hidden keyboard scroll target.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Human code typography, wrapping, and surface overrides changes intended behavior with a stated reason (631b0c7: The fenced-code work deliberately kept human fences in bubble typography without code chrome, extending surface overrides added in 52eb013.)
  • Nested human-code spacing keeps the original intent (32dd4cd: Attachment-spacing work preserved the nested user-fence spacing contract; the shared gap token now maintains that contract independently of code font size.)
  • Folded message layout and keyboard access keeps the original intent (12c4bdf: Natural Markdown layout replaced line clamping to avoid overlapping paragraphs during browser descendant reveal; the new code-only clipping preserves that layout.)
  • Shared block-art typography keeps the original intent (0456268: The earlier refactor shared identical typography without changing presentation; removing the now-redundant human selector retains the shared rule.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified PR scope: The introduced patch removes human-specific typography, wrapping, and surface resets, clips code only inside folded previews, uses the existing spacing token, and extends an existing keyboard regression. (ui/src/styles/chat/text.css:39, 11449c12240b)
  • Current main still has the reported behavior: Fetched main retains the human-message font inheritance, transparent code surface, forced wrapping, and visible overflow overrides. (ui/src/styles/chat/text.css:1312, e6d93baabf7a)
  • Existing rendering owner retained: Human messages already select static code rendering without assistant controls, and the shared renderer emits ordinary pre and code elements; no renderer or lifecycle replacement is needed. (ui/src/pages/chat/components/chat-message-bubble-presentation.ts:204, 11449c12240b)
  • Previous finding resolved: Nested human code now uses --chat-block-gap rather than font-relative margins, preserving the existing attachment-spacing contract when mobile code uses a 12px font. (ui/src/styles/chat/text.css:1317, 11449c12240b)
  • Inspected visual proof: The four prepared desktop-light and mobile-dark screenshots show preserved code lines, indentation, and distinct surfaces; the two additional linked mobile screenshots show the nested-spacing correction. The PR describes composer submission through an isolated real Gateway and separate native keyboard checks. (11449c12240b)
  • Intent and feature history: improve(ui): standardize fenced code collapse and wrapping #125229 deliberately retained human-bubble typography; this maintainer-authored PR explains revising that choice while preserving static rendering. History also establishes sustained ownership of code styling, disclosure, and spacing by Vyctor H. Brzezowski and Peter Steinberger. Older-history traversal encountered an unavailable creation blob, and the previous reviewed head is unavailable locally; neither prevents checking the current finding. (ui/src/styles/chat/text.css, 631b0c77a136)

Likely related people:

  • Peter Steinberger: Raw commit 12c4bdf adds ui/src/e2e/chat-user-bubble-disclosure.e2e.test.ts:114 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 12c4bdf7482f; files: ui/src/e2e/chat-user-bubble-disclosure.e2e.test.ts)

PR surface

Source -16, Tests +10. Total -6 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 7 23 -16
Tests 1 11 1 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 18 24 -6

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Human-message code readability and line layout are impaired, while chat remains usable.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-28T13:47:22.918Z sha a699ff7 :: needs changes before merge. :: [P2] Preserve nested code spacing independently of its font size

Reviewed October 30, 2026, 12:18 AM ET / 04:18 UTC (Revision 2).

@vyctorbrzezowski
vyctorbrzezowski force-pushed the brzezowski/human-code-blocks branch from a699ff7 to 11449c1 Compare October 30, 2026 04:12
@vyctorbrzezowski vyctorbrzezowski added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 30, 2026
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Updated the stack with the scoped CI repairs and current main. The PR body contains the refreshed validation and, where applicable, the nested-code spacing comparison.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 30, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@vyctorbrzezowski
vyctorbrzezowski removed this pull request from stack #188099 October 30, 2026 04:24
@vyctorbrzezowski
vyctorbrzezowski merged commit c64c6d0 into main Oct 30, 2026
115 of 116 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the brzezowski/human-code-blocks branch October 30, 2026 04:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
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 ci:full Keep ordinary native-locale CI selection on the next PR run. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

Human message code blocks lose formatting and horizontal scrolling

1 participant