Skip to content

fix(ui): preserve literal source previews and copied whitespace - #140306

Merged
steipete merged 1 commit into
mainfrom
codex/fix-raw-markdown-preview-fences
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-raw-markdown-preview-fences

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where View Raw Text and decoded text-artifact previews stopped showing literal source at an embedded code fence. Following text could render as Markdown, and Copy code returned only part of the source. Ordinary code copying could also strip leading whitespace and the final newline.

Why This Change Was Made

Both preview producers now use the existing variable-length fence formatter. All code-copy buttons use the existing marked JSON transport, which preserves whitespace through attribute sanitization. The decoder, marker values, sanitizer policy, shared formatter and separate inline-span behavior are preserved.

User Impact

Source previews retain nested Markdown notation, and copies retain the complete code text and intentional whitespace within the existing Markdown line-ending normalization. Production code decreases by 10 lines. The Control UI guide documents the behavior.

Evidence

The original preview regressions failed before the fence repair; separate ordinary whitespace-copy cases confirmed the attribute-transport defect. All 125 distinct selected cases pass, along with 20 source checks and 10 documentation-only checks. The final eight-file managed P2 review is clean.

Before/after browser captures use actual production components, synthetic text/artifact data and real Raw/Copy actions with a mocked clipboard. They verify component behavior, not an installed-app or operating-system clipboard workflow. Both full captures were inspected before upload.

before-raw-markdown-preview

after-raw-markdown-preview

Use the shared variable-length fence formatter for raw text and decoded text artifacts. Encode all code-copy payloads with the existing marked JSON transport so attribute sanitation cannot trim indentation or a final newline. Keep decoder, marker values, parser and inline-code behavior unchanged.

Validation: original nested-fence and independent whitespace regressions fail before their repairs; 125 selected cases, 20 source checks and 10 docs checks pass. Synthetic browser component captures verify raw-view and artifact actions. Final eight-file P2 review is clean.
@clawsweeper

clawsweeper Bot commented Sep 6, 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 6, 2026
@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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR preserves nested Markdown in source previews and whitespace in copied code by reusing existing fence formatting and encoded clipboard payloads.

Merge readiness

✅ Ready for maintainer review

The repair remains useful: current main still contains the reported defects. No actionable correctness or security findings were identified, and this maintainer-authored PR is protected from automatic closure.

Priority: P2
Reviewed head: 09f22945982ad13f970e02cd23354e8685d86a35

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using established helpers, with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its body reports production sidebar Raw/Copy and artifact component captures with synthetic inputs and a mocked clipboard; the attachments were unavailable for independent inspection, and OS clipboard behavior is expressly outside that evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its body reports production sidebar Raw/Copy and artifact component captures with synthetic inputs and a mocked clipboard; the attachments were unavailable for independent inspection, and OS clipboard behavior is expressly outside that evidence.
Evidence reviewed 10 items Verified review scope: The local introduced production diff matches the supplied merge-base-to-head patch. The supplied verified test merge contains exactly the pinned base and PR head as parents; unrelated endpoint drift is not attributed to this PR.
Current main still needs the preview repair: Current main wraps raw Markdown and file content in fixed triple-backtick fences. Embedded closing fences can therefore end the literal preview early.
Artifact preview has the same active defect: The current-main artifact producer also wraps decoded UTF-8 text in fixed triple-backtick fences.
Findings None None.
Security None None.

How this fits together

The Control UI renders chat source text and downloaded text artifacts in a sidebar. Its Markdown renderer produces sanitized previews and supplies code text to the shared clipboard handler.

flowchart LR
  A[Chat source text] --> C[Literal preview formatting]
  B[Decoded text artifact] --> C
  C --> D[Sanitized Markdown renderer]
  D --> E[Sidebar preview]
  D --> F[Encoded copy payload]
  F --> G[Clipboard handler]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -10, Tests +136, Docs +6. Total +132 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 22 -10
Tests 4 168 32 +136
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 186 54 +132

Review metrics

None.

Technical review

Best possible solution:

Keep literal preview formatting and whitespace-safe copying on the existing shared paths while preserving sanitization and Markdown line-ending normalization.

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

Yes, from source: embedded triple-backtick fences terminate current-main raw previews early, and ordinary copy payloads lack the whitespace-preserving encoding already used for block art. No runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. Reusing the existing variable-length formatter and encoded copy transport repairs the producers without adding a competing renderer, changing the decoder, or weakening sanitization.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs bounded Control UI preview and copy defects without changing configuration, persistence, or provider behavior.
  • 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 maintainer-authored PR is exempt from the external-contributor proof gate. Its body reports production sidebar Raw/Copy and artifact component captures with synthetic inputs and a mocked clipboard; the attachments were unavailable for independent inspection, and OS clipboard behavior is expressly outside that evidence.

Evidence

What I checked:

  • Verified review scope: The local introduced production diff matches the supplied merge-base-to-head patch. The supplied verified test merge contains exactly the pinned base and PR head as parents; unrelated endpoint drift is not attributed to this PR. (09f22945982a)
  • Current main still needs the preview repair: Current main wraps raw Markdown and file content in fixed triple-backtick fences. Embedded closing fences can therefore end the literal preview early. (ui/src/pages/chat/components/chat-sidebar-content.ts:125, 489647702cd2)
  • Artifact preview has the same active defect: The current-main artifact producer also wraps decoded UTF-8 text in fixed triple-backtick fences. (ui/src/pages/chat/components/chat-session-workspace.ts:143, 489647702cd2)
  • Existing formatter handles embedded delimiters: The shared formatter chooses a fence longer than every embedded backtick run. Its existing tests cover nested triple backticks; the PR connects both preview producers to that implementation without changing it. (src/shared/markdown-code.ts:29, 09f22945982a)
  • Clipboard transport and security boundary: All code-copy payloads now use the existing marked JSON encoding, followed by HTML escaping. The decoder still requires both the encoding attribute and prefix, and the sanitizer already permits those attributes. A source search found only the shared click handler consuming these payloads. (ui/src/components/markdown-code-blocks.ts:203, 09f22945982a)
  • Latest release retains the older copy path: The supplied latest release, v2026.9.2, encodes only block-art payloads; ordinary code remains a plain attribute value. This release inspection does not establish that the proposed repair has shipped. (ui/src/components/markdown-code-blocks.ts:202, 3928bad9badf)

Likely related people:

  • Peter Steinberger: 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-06T17:07:34.848Z sha 09f2294 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b9cb5b8 into main Sep 6, 2026
141 checks passed
@steipete
steipete deleted the codex/fix-raw-markdown-preview-fences branch September 6, 2026 17:42
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (25 commits)
  docs(releases): keep the release-notes nav group to version routes (#140353)
  fix(ui): hide trust wrappers in imported chat history
  fix(subagents): subagent list building decodes unrelated saved prompts in large session stores (#139540)
  test(process): share relay startup fixtures (#140345)
  refactor(doctor): inline GitHub skill discovery inputs (#140343)
  refactor(ui): share channel status type definitions (#140331)
  refactor: simplify queue state and infrastructure dispatch (#140311)
  fix: require saved agent turns before update verification succeeds (#140274)
  fix(update): keep the service profile when switching to Git (#140263)
  fix(ui): prevent image avatars overlapping mobile chat (#140341)
  fix(test): accept release subpages in docs route shape (#140337)
  refactor(plugins): share uninstall mutation ownership (#140322)
  refactor(agents): use canonical tool execution arguments (#140280)
  perf(cli): keep inference metadata and domain help lazy (#140327)
  refactor(plugins): simplify self-hosted setup results (#140332)
  refactor(config): reuse parent lookup for unset operations (#140326)
  fix(plugins): preserve exact installed-index mutation receipts (#140328)
  test(agents): simplify MCP and LSP boundary fixtures (#140312)
  fix(ui): preserve literal source previews and copied whitespace (#140306)
  fix: OpenCode Go/Zen requests are missing the required x-opencode-session header (#137464)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…claw#140306)

Use the shared variable-length fence formatter for raw text and decoded text artifacts. Encode all code-copy payloads with the existing marked JSON transport so attribute sanitation cannot trim indentation or a final newline. Keep decoder, marker values, parser and inline-code behavior unchanged.

Validation: original nested-fence and independent whitespace regressions fail before their repairs; 125 selected cases, 20 source checks and 10 docs checks pass. Synthetic browser component captures verify raw-view and artifact actions. Final eight-file P2 review is clean.
@VACInc

VACInc commented Sep 7, 2026

Copy link
Copy Markdown
Member

Follow-up to the marked JSON copy payload introduced here: #141574 merged into main on September 7, 2026. It fixes another sanitization boundary: HTML-comment terminators and closing tags could cause the entire copy payload attribute to be removed even though the code remained visible.

The follow-up escapes angle brackets inside the existing JSON encoding and preserves the decoder, whitespace behavior, and source-preview work from this PR. It complements this merged change rather than replacing it.

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.

2 participants