Skip to content

fix(ui): render Markdown attachments in the sidebar - #145555

Merged
roboclaw-bot merged 2 commits into
mainfrom
openclaw/render-markdown-in-sidebar-and-fix-ci
Sep 12, 2026
Merged

roboclaw-bot merged 2 commits into
mainfrom
openclaw/render-markdown-in-sidebar-and-fix-ci

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where users opening Markdown attachments in the chat side panel saw raw Markdown instead of a readable document.

Why This Change Was Made

The text-attachment preview now recognizes .md, .markdown, and Markdown MIME types and uses the existing sanitized document renderer and sidebar styles. The asynchronously rendered attachment owns the shared Markdown lifecycle, so code overflow, expand, and wrap controls initialize as soon as the file loads. Ordinary text, HTML, logs, and structured-data attachments stay literal. The existing size limit, bounded fetch, download link, and cancellation behavior are unchanged; remote images remain disabled.

Validation also found an existing undefined retainedMachine locator in the cloud-picker screenshot test. This PR binds the already-asserted machine locator and reuses it for the screenshot, restoring typecheck and capture-enabled proof without weakening assertions.

User Impact

Markdown attachment headings, emphasis, lists, tables, and fenced code are readable without leaving chat. Users can still download the original file. Requested by Peter Steinberger.

Evidence

  • Regression first: all eight new Markdown cases failed against the original renderer; the 20 existing text-preview cases passed.
  • After: node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-text-attachment.test.ts ui/src/pages/chat/components/chat-sidebar.test.ts — 84 passed initially; the expanded attachment/sidebar/code-block sibling run now passes 123 tests.
  • Changed checks passed for the original five paths and the final lifecycle paths, including core-test and UI typechecking, formatting, lint, styles, i18n, and dead-export checks.
  • Capture-enabled cloud-picker regression: OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/new-session-page.cloud-dispatch.e2e.test.ts -t "dispatches a cloud target before sending" — passed.
  • Deferred-response Chromium regression: failed before the lifecycle fix, then passed with overflow observation, aria-controls, expand and wrap verified without a parent rerender.
  • Fresh independent review through P2 after lifecycle repairs: scoped-clean.
  • The prior hosted run had one native-approval test timeout before submission. The exact unchanged scenario was rerun on the current head with the real isolated Gateway, bundled UI and Chromium: 1 passed, 2 filtered out; all approval/reload/history assertions passed. No speculative retry or timeout patch was made.
  • Real isolated Gateway + Chromium: created a synthetic session and document attachments, clicked the actual attachment Open action, loaded authenticated media successfully, verified rendered headings/bold/lists/table/code, downloaded the original Markdown, then opened a literal .txt control. No mocked network or browser errors. Both before and after measured a 480px panel with no horizontal overflow.
  • Before used the exact base attachment-renderer blob 7cd907a60dc98eab94c493724d9c3bfcba90f73f; after used this candidate. Served entry assets changed from index-ROeVX9K-.js to index-CUp6qKz1.js in the final candidate. The final screenshot is byte-identical to the inspected rendering-only screenshot. Both production UI builds passed.
  • Inspected before/after screenshots are retained and delivered in the requesting conversation. Public image upload is currently blocked: GitHub returned 400 Bad Content-Length; the approved artifact-store fallback rejected its signed upload with an empty forwarded content-length. No proof images are committed to the product repository, and no failed/expired artifact URL is presented as working evidence.

Render Markdown documents with the shared sanitized reader while preserving literal text previews and downloads. Repair the missing locator in the cloud-picker screenshot test found by validation.

Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 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: S maintainer Maintainer-authored PR labels Sep 12, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 12, 2026 03:05
@roboclaw-bot roboclaw-bot self-assigned this Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 11:57 PM ET / September 12, 2026, 03:57 UTC (Revision 2).

ClawSweeper review

What this changes

The PR renders Markdown attachments as formatted sidebar documents, initializes their asynchronous code controls, adds coverage and documentation, and repairs a screenshot-test locator.

Merge readiness

✅ Ready for maintainer review

The previous lifecycle finding is resolved, and no remaining blocking defect was found. Current main still renders these attachments literally, so this PR remains useful.

Priority: P2
Reviewed head: 8fcc37c1253b09f7e18a062e253bce8128f576db

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful regression coverage and the prior blocker addressed.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor-proof gate is exempt for this maintainer-associated bot PR. The supplied record describes the changed attachment owner exercised through real Gateway media reads and Chromium, with successful rendering, download, and literal-text control results; unavailable screenshots were not independently inspected here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor-proof gate is exempt for this maintainer-associated bot PR. The supplied record describes the changed attachment owner exercised through real Gateway media reads and Chromium, with successful rendering, download, and literal-text control results; unavailable screenshots were not independently inspected here.
Evidence reviewed 7 items Previous finding resolved: The exact-head commit adds the Markdown lifecycle to the asynchronously populated article and removes the parent directive for attachment content. Its browser regression waits for a deferred response and checks overflow, disclosure linkage, expansion, and wrapping without a parent rerender.
Still necessary on main: The fetched main revision retains the literal preformatted-text rendering branch; it does not recognize Markdown for formatted attachment previews.
Latest-release comparison: The supplied latest release also renders loaded attachment text literally; the requested presentation is not already provided by that release.
Findings None None.
Security None None.

How this fits together

The Control UI sidebar opens chat attachments from resolved media sources. Its bounded text reader now sends Markdown through the shared sanitized renderer while preserving literal previews for other text files and the original download.

flowchart LR
  A[Open chat attachment] --> B[Resolve media source]
  B --> C[Bounded text reader]
  C --> D{Markdown file or MIME type?}
  D -->|Yes| E[Sanitized document and controls]
  D -->|No| F[Literal text preview]
  B --> G[Original download]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +32, Tests +115, Docs +1. Total +148 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 38 6 +32
Tests 3 120 5 +115
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 159 11 +148

Review metrics

None.

Technical review

Best possible solution:

Keep attachment loading in its existing bounded reader and reuse the shared sanitized Markdown renderer with one lifecycle owner for the loaded document.

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

Not applicable as an established-behavior regression: existing source and tests intentionally display attachment text literally. The missing formatted preview is directly evident on main; no runtime tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes. Extending the existing attachment component with the shared renderer avoids a competing parser, and the revised child-owned lifecycle addresses the asynchronous loading problem.

AGENTS.md: found and applied where relevant.

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

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: The ordinary contributor-proof gate is exempt for this maintainer-associated bot PR. The supplied record describes the changed attachment owner exercised through real Gateway media reads and Chromium, with successful rendering, download, and literal-text control results; unavailable screenshots were not independently inspected here.
  • remove rating: 🦐 gold shrimp: 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 improvement to reading document attachments in the chat sidebar.
  • 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 ordinary contributor-proof gate is exempt for this maintainer-associated bot PR. The supplied record describes the changed attachment owner exercised through real Gateway media reads and Chromium, with successful rendering, download, and literal-text control results; unavailable screenshots were not independently inspected here.

Evidence

What I checked:

  • Previous finding resolved: The exact-head commit adds the Markdown lifecycle to the asynchronously populated article and removes the parent directive for attachment content. Its browser regression waits for a deferred response and checks overflow, disclosure linkage, expansion, and wrapping without a parent rerender. (ui/src/pages/chat/components/chat-text-attachment.ts:143, 8fcc37c1253b)
  • Still necessary on main: The fetched main revision retains the literal preformatted-text rendering branch; it does not recognize Markdown for formatted attachment previews. (ui/src/pages/chat/components/chat-text-attachment.ts:129, ec575b2ead3c)
  • Latest-release comparison: The supplied latest release also renders loaded attachment text literally; the requested presentation is not already provided by that release. (ui/src/pages/chat/components/chat-text-attachment.ts, 3a9d69db306c)
  • Rendering and security boundary: The attachment reader retains its 256 KiB bound, fatal UTF-8 decoding, cancellation, generation checks, and same-origin fetch behavior. The new branch explicitly disables remote images and uses the existing sanitized document renderer; file-link and session-link capabilities remain disabled by default. (ui/src/pages/chat/components/chat-text-attachment.ts:146, 8fcc37c1253b)
  • Recorded behavior verification: The supplied complete PR body and follow-up comment report an isolated real Gateway and Chromium run through attachment Open, authenticated media loading, formatted Markdown, original download, and a literal text control. They identify the rebuilt candidate entry asset as index-CUp6qKz1.js and separately report a passing deferred-response browser regression. Screenshots were reportedly inspected in the requesting conversation but were not available here; their upload failures are explicitly documented. These are contributor-reported observations, not executions or image inspections performed by this review. (8fcc37c1253b)
  • Feature-history routing: Git history identifies the earlier text-attachment work at df5a6f1, and the GitHub commit API maps its author to steipete and shows the attachment module as added. Local blame and follow-history inspection encountered unavailable historical blobs, so no additional line-history attribution is asserted. (ui/src/pages/chat/components/chat-text-attachment.ts:16, df5a6f1dcc87)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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-12T03:11:29.190Z sha cc832a7 :: needs changes before merge. :: [P2] Initialize Markdown controls after the attachment body loads

Give the attachment article ownership of the shared Markdown lifecycle and omit the parent directive for attachment content. Cover delayed fetch completion in Chromium, including overflow, disclosure linkage, expand and wrap controls.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Fixed the asynchronous Markdown lifecycle finding in 8fcc37c. The fetched attachment article now runs the shared markdownBlocks() lifecycle, and the parent omits its directive for attachments so it cannot tear down child-owned controls.

The new Chromium regression failed before on the missing overflow state, then passed after a deferred response without a parent rerender. It verifies overflow observation, aria-controls, expansion, and wrapping. The expanded unit/sibling run passes 123 tests, scoped changed checks pass, and fresh independent review through P2 is clean. Rebuilt real-Gateway proof also passes: actual attachment Open, authenticated media reads, Markdown rendering, download, and literal .txt control, with no browser errors or 480px-panel overflow. Final served entry: index-CUp6qKz1.js.

Exact commands:

node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-browser.config.ts ui/src/pages/chat/components/chat-text-attachment.browser.test.ts
node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-text-attachment.test.ts ui/src/pages/chat/components/chat-sidebar.test.ts ui/src/components/markdown-code-blocks.test.ts
node scripts/check-changed.mjs -- ui/src/pages/chat/components/chat-text-attachment.ts ui/src/pages/chat/components/chat-sidebar-content.ts ui/src/pages/chat/components/chat-text-attachment.browser.test.ts

The earlier hosted run had one unrelated real-Gateway approval-scenario timeout; its exact job log is under investigation while new-head CI runs. Public screenshot upload remains blocked as documented in the PR; inspected before/after captures were delivered in the requesting conversation.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 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: 🦐 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. labels Sep 12, 2026
@roboclaw-bot
roboclaw-bot merged commit 7e6613d into main Sep 12, 2026
138 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/render-markdown-in-sidebar-and-fix-ci branch September 12, 2026 04:07
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
* fix(ui): render Markdown attachments in the sidebar

Render Markdown documents with the shared sanitized reader while preserving literal text previews and downloads. Repair the missing locator in the cloud-picker screenshot test found by validation.

Co-authored-by: steipete <[email protected]>

* fix(ui): initialize asynchronously loaded Markdown controls

Give the attachment article ownership of the shared Markdown lifecycle and omit the parent directive for attachment content. Cover delayed fetch completion in Chromium, including overflow, disclosure linkage, expand and wrap controls.

Co-authored-by: steipete <[email protected]>

---------

Co-authored-by: steipete <[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 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: S 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