Skip to content

feat(ui): toggle wrapping on code blocks in your own messages - #197804

Merged
vyctorbrzezowski merged 4 commits into
mainfrom
openclaw/nova-barnacle-4
Nov 12, 2026
Merged

vyctorbrzezowski merged 4 commits into
mainfrom
openclaw/nova-barnacle-4

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #196070

What Problem This Solves

Code blocks in your own chat messages wrap long lines, with no way to see the lines as they were written. Long commands, logs, and URLs are harder to read when they are split across rows.

User Impact

User impact: when a line in a code block you sent wraps, a small toggle in the block's top-right corner switches the block to horizontal scrolling and back. Wrapped stays the default.

  • Blocks where nothing wraps look as they do today and show no control.
  • Line spacing in these blocks now matches assistant code blocks, so they are slightly more compact than before.
  • The pending preview after starting a new chat shows the same block. Its toggle appears once the chat opens.

Why This Change Was Made

Human-message code fences were passive, so the wrap default from #196070 could not be turned off. They now reuse the wrap control and click handling that assistant code blocks already have, without the copy, reveal, or JSON tools.

The toggle sits in the corner of the first row instead of a toolbar row, so it adds no height to the block. Wrapped text on the first row stops short of the control. With wrapping off, the first row fades out before the control and scrolls clear of it.

The pending new-chat preview renders the same block so rows do not reflow when Chat takes over. It stays passive until then. Aligned block art is unchanged.

Accepted edge case: after turning wrapping off, widening the pane until nothing overflows hides the toggle until a row overflows again. The block reads the same in both states at that width.

Evidence

Screenshots are the real Control UI build against a mocked Gateway with synthetic messages, at 1180 px in the dark theme and 100% scale. "Before" is the original base 5cef30a310125838abdbd3400a4db3dd334e8220.

Before (original base: wraps, no control)

Before: code block in a sent message on main, wrapped with no control

After (wrapped, toggle in the corner)

After: the same block with a wrap toggle in its top-right corner

After (wrapping turned off)

After: wrapping off, lines scroll horizontally and fade at the edge

390 px, light theme
Wrapped Wrapping off
390 px light theme, wrapped 390 px light theme, wrapping off

Author checks on the original candidate:

  • ui/src/e2e/chat-code-block-fences.e2e.test.ts: 7 passed. The new scenario runs at 1180 px (dark) and 390 px (light) and covers the default wrapped state, Enter and Space on the toggle, unchanged code text, no page overflow, no text under the control, no control on a short block, and the passive pending preview.
  • ui/src/e2e/new-session-page.transition.e2e.test.ts: 8 passed.
  • Unit suites for code blocks, chat JSON text, the new-session page, and highlighting: 94 passed.
  • UI typecheck, oxlint, stylelint, oxfmt, and the Control UI controller guard pass.
  • pnpm ui:check-performance:base against the merge base flags this change's stylesheet growth: about 1.2 KiB raw and 0.2 KiB gzip of total CSS. main is already over the total CSS cap, so the check allows no growth; it fails locally and is an advisory warning in CI. No JavaScript, startup, or request budget is affected.
  • Local autoreview (Codex engine, P0–P2) on the complete local change against 5cef30a. The first pass found one P2: the toggle could hide after turning wrapping off when a row fit the viewport but not its padded scroll area. That is fixed with a regression test, and a second pass on the final change reported no findings. The reviewer saw the diff only and did not run code.

Not covered: WebKit and Firefox, right-to-left messages, and a live Gateway.

Requested and directed by @vyctorbrzezowski.

Maintainer verification

The review found that the end padding was outside the overflow created by the wide code child: at maximum horizontal scroll, the final characters were still faded. The unwrapped human-message pre now sizes to its content (with a viewport-width minimum), so its existing padding remains reachable by scrolling. No new preference lookup, polling, cache, or rendering owner was introduced.

The incoming candidate failed the endpoint proof at 1180px and 390px. The correction passed real wheel scrolling in both directions, the first-row suffix beside the toggle, long-message expansion, and the complete New Session → Chat handoff with unchanged code text. The existing seven code-fence browser cases, UI typecheck, scoped lint/style/format, and test-line guard pass. The two Side chat typography cases also pass after scoping assistant-control assertions to the assistant row and replacing the obsolete no-user-wrapper expectation with checks for the intended short-code behavior. Independent P0–P2 review of the complete corrected candidate found no actionable issues. The runtime logic also retains the previously passing 65 focused unit tests and eight New Session transition cases.

Current inspected screenshots and proof limits. These checks use the production UI with synthetic Gateway history in Chromium; they do not claim live-provider, WebKit, Firefox, or RTL coverage. The original author evidence remains above.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 12, 2026 15:33
Code fences in human messages wrap long lines by default but offered no
way back to the literal line layout. Give them a wrap toggle in the
corner of the block's first row, reusing the shared code-block click
owner. The toggle appears only while a row soft-wraps, keeps the passive
block's box, and adds no copy, reveal, or JSON tools. Turning wrapping
off scrolls horizontally, with the first row fading out before the
control. The pending new-chat preview shares the markup so rows do not
reflow at handoff, and stays passive until Chat mounts.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 716949f3-0c10-4490-abad-6a729e04b018
@clawsweeper

clawsweeper Bot commented Nov 12, 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 labels Nov 12, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 12, 2026 15:39
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Adds a reversible wrapping control to code blocks in human chat messages while keeping wrapping enabled by default.

Example: A sent code block contains a long https://example.com/design/ URL at a 390 px viewport width.

  • Before: The URL wraps across rows with no control to restore its original line layout.
  • After: The corner toggle switches between wrapping and horizontal scrolling without changing the source text.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The feature has direct visual evidence and appropriate shared ownership, but two deterministic, change-caused CI failures remain.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected screenshots exercise the actual Control UI build with synthetic Gateway messages and show the human fence before the change, wrapped with its toggle, and unwrapped with horizontal clipping; mobile evidence shows the wrapped control at 390 px.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Long commands, logs, and URLs in sent code blocks cannot be viewed in their original line layout.
Reason: The maintainer-authored direction adds a useful reversible action while preserving the established wrapping default and existing interaction ownership.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this useful, maintainer-directed PR open. The visible behavior is supported by screenshots, but two change-caused CI failures need focused repairs.

Priority: P2
Reviewed head: f4d816e3228b8720051130d895fe030486abe782

Before merge

  • Update side-chat assertions for human wrap controls (P2) - Adding a wrap button and viewport to every human fence invalidates this existing consumer test. At both viewport widths, side.locator('.code-block-wrap') now resolves to two buttons and throws a strict-mode violation, as recorded by the exact-head UI E2E job. After scoping that locator, the code locator also needs assistant scoping, and the assertion that human messages have zero wrappers must reflect the new presentation. Update these assertions while retaining assistant wrapping, clipboard, human source-fidelity, and containment coverage.
  • Bring the added styles within the enforced CSS growth budget (P2) - The new wrap-only styles increase compiled total CSS by 1,277 raw bytes and 217 gzip bytes. Because the measured base already exceeds both ceilings, the checker permits only 64 bytes of build variance, so this PR fails control-ui-performance and the aggregate CI gate. This is a change-caused failure, despite the PR body's description of it as advisory. Consolidate the added styling with existing rules to pass the unchanged budget.

Findings

  • [P2] Update side-chat assertions for human wrap controls — ui/src/e2e/chat-side-chat-typography.e2e.test.ts:92-96
  • [P2] Bring the added styles within the enforced CSS growth budget — ui/src/styles/chat/text.css:1198-1205
Agent review details

How this fits together

Control UI message presentation supplies interaction options to the shared Markdown renderers; the existing code-block owner measures overflow and handles the toggle, while CSS controls wrapping and scrolling.

flowchart TD
  A[Human message Markdown] --> B[Message presentation options]
  B --> C[Shared Markdown renderer]
  C --> D[Code block markup]
  D --> E[Existing interaction owner]
  E --> F[Wrapped or scrolling code]
  G[Pending chat preview] --> C
Loading

Technical review

Best possible solution:

Keep the shared wrap-control implementation, update the affected side-chat assertions, and reduce stylesheet growth to satisfy the existing budget.

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

Current-main source and the supplied before screenshot establish wrapped human code without a toggle; exact-head CI independently records the two validation failures.

Is this the best way to solve the issue?

Reusing the existing renderer, overflow measurement, and click owner is an appropriate small extension; the remaining repairs belong in the affected consumer test and stylesheet.

Full review comments:

  • [P2] Update side-chat assertions for human wrap controls — ui/src/e2e/chat-side-chat-typography.e2e.test.ts:92-96
    Adding a wrap button and viewport to every human fence invalidates this existing consumer test. At both viewport widths, side.locator('.code-block-wrap') now resolves to two buttons and throws a strict-mode violation, as recorded by the exact-head UI E2E job. After scoping that locator, the code locator also needs assistant scoping, and the assertion that human messages have zero wrappers must reflect the new presentation. Update these assertions while retaining assistant wrapping, clipboard, human source-fidelity, and containment coverage.
    Confidence: 1
  • [P2] Bring the added styles within the enforced CSS growth budget — ui/src/styles/chat/text.css:1198-1205
    The new wrap-only styles increase compiled total CSS by 1,277 raw bytes and 217 gzip bytes. Because the measured base already exceeds both ceilings, the checker permits only 64 bytes of build variance, so this PR fails control-ui-performance and the aggregate CI gate. This is a change-caused failure, despite the PR body's description of it as advisory. Consolidate the added styling with existing rules to pass the unchanged budget.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Human-message wrapping and static code presentation changes intended behavior with a stated reason (fix(ui): keep fenced prompts readable after starting a chat #196070: Keep submitted fenced prompts readable within human-message bubbles without changing their source.)
  • Shared code-block controls and measurement keeps the original intent (631b0c7: Centralize contextual wrapping, overflow containment, and interaction handling across code-block hosts.)
  • Direct DOM rendering of streaming Markdown keeps the original intent (b688518: Avoid repeated HTML serialization and parsing for supported live tails while retaining sanitization and settled rendering boundaries.)
  • Pending New Session preview keeps the original intent (85082d9: Defer transcript rendering until needed and keep the pending preview passive.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test:ui:e2e ui/src/e2e/chat-side-chat-typography.e2e.test.ts ui/src/e2e/chat-code-block-fences.e2e.test.ts ui/src/e2e/new-session-page.transition.e2e.test.ts
  • pnpm lint:ui:styles
  • pnpm ui:check-performance:base 5cef30a
  • git diff --check

What I checked:

Likely related people:

  • Vyctor H. Brzezowski: Raw commit 631b0c7 adds ui/src/components/markdown-code-blocks.ts:143 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 631b0c77a136; files: ui/src/components/markdown-code-blocks.ts)
  • Peter Steinberger: Raw commit 8f47a67 adds ui/src/components/markdown-code-blocks.ts:155 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8f47a67d1ffe; files: ui/src/components/markdown-code-blocks.ts)

PR surface

Source +97, Tests +182, Docs +1. Total +280 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 125 28 +97
Tests 4 188 6 +182
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 316 36 +280

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Compiled CSS growth +1,277 B raw; +217 B gzip The exact-head base comparison exceeds the existing 64-byte growth allowance and fails the performance check.

Labels

Label changes:

  • add P2: A useful, limited-scope chat readability improvement with focused CI repairs required.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: A useful, limited-scope chat readability improvement with focused CI repairs required.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • 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.

Reviewed November 12, 2026, 10:56 AM ET / 15:56 UTC.

@vyctorbrzezowski

vyctorbrzezowski commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Maintainer review found one concrete defect: at maximum horizontal scroll, trailing characters remained under the fade. The unwrapped pre now includes its existing end padding in its intrinsic scrollable width. No new state, cache, polling, or preference lookup was added.

The incoming candidate failed the endpoint check at both 1180px and 390px. The corrected candidate passed actual wheel scrolling in both directions, the first-row suffix beside the toggle, long-message expansion, and the complete New Session → Chat handoff with unchanged text. The existing seven code-fence browser cases, UI typecheck, scoped lint/style/format and test-line guard pass. Independent P0–P2 review found no actionable issues.

Proof scope: production Control UI with synthetic Gateway history in Chromium. WebKit, Firefox, RTL and a live provider call are not claimed.

Corrected desktop block, wrapped by default

Phone: first-line suffix remains readable after horizontal scrolling

@vyctorbrzezowski
vyctorbrzezowski enabled auto-merge (squash) November 12, 2026 16:18
@vyctorbrzezowski
vyctorbrzezowski merged commit c097873 into main Nov 12, 2026
92 of 95 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the openclaw/nova-barnacle-4 branch November 12, 2026 17:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…aw#197804)

Allow code blocks in user messages to switch between wrapped lines and horizontal scrolling through the existing Markdown control owner. Keep the pending New Session preview passive until Chat takes ownership.

Include the end padding in the scrollable width so the last characters remain readable beyond the fade. Verified desktop and phone scrolling, keyboard control, unchanged text, long-message expansion, and New Session handoff.

Co-authored-by: vyctorbrzezowski <[email protected]>
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 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants