Skip to content

improve(ui): standardize fenced code collapse and wrapping - #125229

Merged
vyctorbrzezowski merged 2 commits into
mainfrom
tmp/transcript-fence-behavior
Aug 18, 2026
Merged

vyctorbrzezowski merged 2 commits into
mainfrom
tmp/transcript-fence-behavior

Conversation

@vyctorbrzezowski

Copy link
Copy Markdown
Member

Closes #125227

What Problem This Solves

Resolves a problem where Control UI users reading fenced code would get inconsistent long-block behavior, including fully closed JSON summaries, unbounded transcript height, and long lines that had no contextual wrap control while pressuring the surrounding transcript width.

Why This Change Was Made

All Markdown code fences now use one shared behavior: blocks longer than seven lines show a seven-line preview with the exact hidden-line count, while measured horizontal overflow stays inside the fence and exposes a reversible wrap control. JSON, unlabeled, user, assistant, and detail-panel variants share the same path; copied text remains raw.

This change intentionally leaves border, fill, and header visual styling to the separate fenced-code visual work. It does not add a streaming indicator or Mermaid rendering.

User Impact

Code-heavy transcript turns are easier to scan without losing context. Users can reveal long fences, horizontally scroll unwrapped code without widening the page, or enable and disable wrapping only when the content actually overflows. Keyboard focus, accessible state labels, tooltips, and reduced-motion behavior remain available.

Evidence

  • Duplicate search found no existing issue or PR implementing this complete Control UI behavior; [Bug]: Short JSON code replies render collapsed in Control UI #122274 / fix(ui): keep short JSON replies visible #122313 only addressed short JSON visibility.
  • Source inspection confirmed the previous shared renderer used a JSON-only 40-line closed disclosure while other fences had no common collapse or wrap behavior.
  • The implementation is centralized in the shared Markdown code-block renderer and initialized in both transcript and detail-panel hosts.
  • Per request, no tests, build, checks, lint, format, install, screenshots, review automation, or CI watch were run.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 17, 2026
@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 3:10 AM ET / 07:10 UTC.

ClawSweeper review

What this changes

The branch replaces JSON-only code disclosure with seven-line previews, contained horizontal overflow, and reversible wrapping for interactive Control UI Markdown hosts.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for maintainer review: the shared renderer and host lifecycle look coherent, but the assistant-only scope needs confirmation and the UI-visible change lacks real after-fix proof.

Priority: P2
Reviewed head: 9089c2d511836e548f5a784061b17db66a8996c2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 5 items Shared owner boundary: The renderer centralizes preview, reveal, wrap, and copy markup; non-interactive hosts retain readable static fences.
Transcript lifecycle: The chat transcript initializes code-block measurement and delegates click handling through the same shared owner.
Browser coverage is mock-backed: The added browser test starts Control UI but injects a mock Gateway; it is useful regression coverage, not after-fix operator-visible proof.
Findings None None.
Security None None.

How this fits together

Control UI converts chat and sidebar Markdown into sanitized HTML. The shared code-block renderer emits optional controls, and transcript, detail-panel, and caretaker hosts initialize and handle those controls.

flowchart LR
  Message[Markdown content] --> Renderer[Shared Markdown renderer]
  Renderer --> Scope[Interactive host decision]
  Scope --> Controls[Preview, wrap, and copy controls]
  Controls --> Hosts[Chat, detail panel, caretaker]
  Hosts --> Reader[Readable code fences]
Loading

Decision needed

Question Recommendation
Should this feature intentionally limit preview and wrap controls to assistant/caretaker output while leaving user-authored fences as plain static text? Approve assistant-only controls: Keep user fences plain and static, and document that this is the intended transcript distinction.

Why: The branch makes that narrower choice, while the linked request and original PR description describe user fences as part of the unified behavior; the provided comments assert approval but do not supply the approving maintainer decision.

Before merge

  • Resolve merge risk (P1) - The branch changes established assistant code-fence behavior without supplied real Control UI before/after evidence; the available browser test uses a mock Gateway.
  • Resolve merge risk (P1) - The PR body originally includes user-message fences, while the branch intentionally leaves them static; the supplied context does not contain the maintainer decision that resolves that scope difference.
  • Resolve merge risk (P1) - Current-main equivalence and merge-result behavior could not be independently checked from this grafted, offline checkout.
  • Complete next step (P2) - A maintainer must confirm the role-specific product scope and require UI evidence; this protected member PR is not an automated repair candidate.
Agent review details

Security

None.

PR surface

Source +335, Tests +130. Total +465 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 12 413 78 +335
Tests 6 221 91 +130
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 634 169 +465

Review metrics

Metric Value Why it matters
Production versus test delta production +413/-78; tests +221/-91 The net production growth is justified only if the shared interaction capability and its three host lifecycles are the approved product scope.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/src/components/markdown.test.ts, persistent cache schema: ui/src/components/markdown.ts, serialized state: ui/src/e2e/chat-markdown-alignment.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A redacted web-chat transcript showing the initial preview and the revealed/wrapped assistant fence would materially verify the visible behavior. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify and capture an assistant fenced-code block before and after reveal and word-wrap.

Merge-risk options

Maintainer options:

  1. Prove the intended interaction matrix (recommended)
    Attach a redacted real Control UI recording or screenshots showing an assistant fence before and after reveal and wrap, then refresh against current main.
  2. Explicitly accept the narrowed scope
    A maintainer may approve assistant-only controls and static user fences as the durable product contract.
  3. Pause for a broader fence policy
    Pause this branch if every transcript fence must receive identical controls rather than role-specific behavior.

Technical review

Best possible solution:

Record the assistant-only scope decision, attach sanitized real Control UI proof showing preview, reveal, and wrap, then refresh review against current main before merge.

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

Not applicable: this is a proposed UI behavior change, not a current bug report; the source includes mock-backed browser coverage but no independently observed live result.

Is this the best way to solve the issue?

Unclear: the renderer is the right ownership boundary, but the narrowed assistant-only scope and current-main behavior need confirmation before this can be called the best solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6cc40431d173.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, 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: This is a bounded but user-visible Control UI behavior change rather than an urgent availability or data-loss issue.
  • merge-risk: 🚨 compatibility: Existing assistant transcript, detail-panel, and caretaker code fences receive new collapse and wrap behavior after merge.
  • 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: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

Likely related people:

  • vyctorbrzezowski: Authored the earlier short-JSON repair, the subsequent fenced-code visual unification, and the reviewed head. (role: feature-history contributor; confidence: high; commits: d8488a94067c, 52eb01333049, 9089c2d51183; files: ui/src/components/markdown-code-blocks.ts, ui/src/pages/chat/components/chat-message-bubble.ts)
  • Peter Steinberger: History lists prior clipboard-feedback and syntax-highlighting work on the same code-block renderer. (role: adjacent code-path contributor; confidence: medium; commits: 0dbf9b6faef9, b26776fbca69; files: ui/src/components/markdown-code-blocks.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Tighten the PR description with what changed, how it was validated, and any remaining risk.

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 (4 earlier review cycles)
  • reviewed 2026-08-17T11:18:36.132Z sha 484d68a :: found issues before merge. :: [P1] Keep collapse controls usable outside chat hosts | [P1] Update renderer tests for the new markup
  • reviewed 2026-08-18T05:41:36.083Z sha 484d68a :: found issues before merge. :: [P1] Keep collapse controls usable outside chat hosts | [P1] Replace obsolete JSON-collapse assertions
  • reviewed 2026-08-18T06:51:43.242Z sha 11c413d :: found issues before merge. :: [P1] Keep user fences on the shared interaction contract
  • reviewed 2026-08-18T07:01:56.572Z sha 9089c2d :: found issues before merge. :: [P1] Keep user fences interactive and copyable

@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review August 18, 2026 05:37
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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. labels Aug 18, 2026
Every Markdown code fence now shares one behavior instead of the JSON-only
40-line disclosure: blocks longer than seven lines show a seven-line preview
with the exact hidden-line count, horizontal overflow stays inside the fence,
and a reversible wrap control appears only once a line measurably overflows.
User fences keep the bubble's own typography and carry no code chrome.

The collapsible markup is emitted only for hosts that own the code-block
lifecycle (codeBlockInteraction: interactive), and that lifecycle collapsed to
one click owner plus one initializer so a host cannot wire half of it. The chat
thread, detail panel, and caretaker surface all run it; the skills preview gets
the click owner its copy button had never been given. The scan is deferred and
coalesced because a Lit element ref commits before that render's children, and
detached ResizeObserver targets are released before each pass.

Also adds the interaction mode to the markdown cache key so a static host cannot
serve interactive markup from a sibling render, and drops the stylesheet rules
and selector guards the removed json-collapse markup owned.
@vyctorbrzezowski
vyctorbrzezowski force-pushed the tmp/transcript-fence-behavior branch from 484d68a to 11c413d Compare August 18, 2026 06:43
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 18, 2026
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Addressed the review findings on the rebuilt branch:

  • Scoped reveal and wrap markup behind codeBlockInteraction: "interactive"; static Markdown readers keep ordinary non-collapsible fences, while the chat thread, detail panel, and caretaker own the full click and measurement lifecycle.
  • Replaced the retired details.json-collapse assertions with coverage for the seven-line preview, exact hidden-line count, reveal, reversible wrapping, static-host isolation, and cache separation.
  • Rebuilt on current main; GitHub now reports the PR mergeable.
  • Fixed the two exact-head CI issues from the first rebuilt push: formatted ui/src/styles/chat/text.css and consolidated the renderer environment assertion behind a documented boundary.

Focused proof:

node scripts/run-vitest.mjs ui/src/components/markdown.test.ts ui/src/components/markdown-code-blocks.test.ts (103 passed)

node_modules/.bin/oxfmt --check ui/src/styles/chat/text.css ui/src/components/markdown-code-blocks.ts

pnpm check:assertion-safety --base origin/main

Exact-head CI is attached to 9089c2d511836e548f5a784061b17db66a8996c2 and is in progress.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Addressed the review findings and resolved the requested product decision:

  • User-authored fences intentionally remain plain readable message text, without code-specific chrome, Copy, collapse, or wrap controls. This is the maintainer-approved and operator-validated scope, not an accidental lifecycle omission.
  • Assistant transcript fences retain the shared seven-line preview, exact hidden-line count, reveal, contextual reversible wrapping, contained horizontal scrolling, JSON parity, and raw Copy behavior.
  • Static shared-Markdown hosts emit fully readable non-collapsible fences; only hosts that own click and measurement lifecycle receive reveal/wrap markup.
  • Focused renderer coverage passes: node scripts/run-vitest.mjs ui/src/components/markdown.test.ts ui/src/components/markdown-code-blocks.test.ts (103 tests).
  • Exact-head CI is attached to 9089c2d511836e548f5a784061b17db66a8996c2 and is fully green, including openclaw/ci-gate.

The previous P1 recommendation to restore user-fence controls is superseded by the explicit maintainer scope decision above. No merge is requested until this fresh review has no open findings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@vyctorbrzezowski
vyctorbrzezowski merged commit 631b0c7 into main Aug 18, 2026
151 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the tmp/transcript-fence-behavior branch August 18, 2026 09:11
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…125229)

* improve(ui): standardize fenced code collapse and wrapping

Every Markdown code fence now shares one behavior instead of the JSON-only
40-line disclosure: blocks longer than seven lines show a seven-line preview
with the exact hidden-line count, horizontal overflow stays inside the fence,
and a reversible wrap control appears only once a line measurably overflows.
User fences keep the bubble's own typography and carry no code chrome.

The collapsible markup is emitted only for hosts that own the code-block
lifecycle (codeBlockInteraction: interactive), and that lifecycle collapsed to
one click owner plus one initializer so a host cannot wire half of it. The chat
thread, detail panel, and caretaker surface all run it; the skills preview gets
the click owner its copy button had never been given. The scan is deferred and
coalesced because a Lit element ref commits before that render's children, and
detached ResizeObserver targets are released before each pass.

Also adds the interaction mode to the markdown cache key so a static host cannot
serve interactive markup from a sibling render, and drops the stylesheet rules
and selector guards the removed json-collapse markup owned.

* fix(ui): satisfy fenced code checks
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

Control UI: standardize fenced code collapse and wrapping

1 participant