Skip to content

fix: preserve Markdown formatting in HTML export lists - #140830

Merged
steipete merged 1 commit into
mainfrom
codex/qa-tight-list-export-20260907
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-tight-list-export-20260907

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #140785.

What Problem This Solves

Fixes an issue where users exporting a session to HTML would see literal Markdown inside tight lists, even though the same bold text, link, and inline code rendered correctly in a paragraph.

Why This Change Was Made

The shared export renderer treated composite Marked text tokens as leaves. It now delegates tokens with inline children through Marked 18.0.11's existing renderer contract. Leaf escaping and the code, raw-HTML, image, link, and URL-validation hooks keep their existing implementations. This restores the canonical traversal without adding a parser, dependency, configuration option, or stored state.

Production: +2/-2, net zero. Tests: +60. Docs: +3.

User Impact

/export-session and /export preserve bold text, authored links, and inline code in list items for both user and assistant messages. Markdown inside literal inline code stays literal.

Evidence

  • The same composed template corpus produced two intended failures and 20 passing controls before the repair, then 22/22 passing tests afterward. It uses the real template and generated pinned vendor assets; existing escaping, link, image, and hidden-message controls pass.
  • The complete three-file changed check passed in 1107.3 seconds, including typechecking, lint, and repository guards. Independent managed review completed one full pass with zero P0–P2 findings.
  • Normal pnpm build passed in 624.6 seconds. Full source inventories matched before/after; the generated export template equals the repaired source.
  • Real isolated Gateway → canonical synthetic assistant injection → normal gateway-mode TUI /export tight-list-proof.html → actual HTML in Chromium passed before and after. Both runs received the persisted export acknowledgement, exported one entry, preserved paragraph/plain-list/literal-code controls, and completed TUI/browser/session/Gateway cleanup without forced termination. Source, dependencies, and complete build inventories verified before and after each run. Screenshots and recordings were inspected.

Validation ran against the final working diff, which matches committed d3ff01fd12d446b63c57a0cd30ca6eda1bb7dd1d byte-for-byte. The live case is an injected assistant export, not a model inference run; both roles are covered by the source regression. The leaf-only hook is also present in v2026.9.2 source; its introducing commit is not attributed. Exact-head CI passed: 77 jobs succeeded and 16 inapplicable jobs were skipped.

Before — list syntax remains literal:

Before: actual HTML export leaves list Markdown literal

After — list formatting matches the paragraph:

After: actual HTML export preserves list bold, link, and code

Proof harness recovery

Earlier attempts are retained as failed evidence: one stopped at a Git preflight timeout; another completed the export but exceeded teardown while its observer repeatedly spawned per-PID process queries. The accepted runs use a single-inventory observer with fresh identity checks before signals and unchanged product assertions and shutdown limits. Both accepted runs exited normally with no survivors or open listener.

HTML session exports now preserve bold text, links, and inline code in list items for user and assistant messages. Delegate composite Marked text tokens through the existing renderer while retaining leaf escaping and child hooks.

Fixes #140785.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 1:25 AM ET / 05:25 UTC.

ClawSweeper review

What this changes

HTML session exports preserve bold text, links, and inline code inside list items, with regression coverage for user and assistant messages and updated command documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main retains the reported defect, and the proposed repair follows Marked’s supported renderer contract. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: d3ff01fd12d446b63c57a0cd30ca6eda1bb7dd1d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful regression coverage and strong recorded before/after production-flow evidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured evidence ties this renderer change to a real isolated Gateway/TUI export opened in Chromium, with repaired list formatting and preserved controls after the fix. Screenshot retrieval failed during review, but the recorded production-flow observations remain sufficient.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured evidence ties this renderer change to a real isolated Gateway/TUI export opened in Chromium, with repaired list formatting and preserved controls after the fix. Screenshot retrieval failed during review, but the recorded production-flow observations remain sufficient.
Evidence reviewed 8 items Verified introduced change: The merge-base comparison confirms the narrow renderer repair and documentation addition; the complete supplied introduction evidence also contains the regression test. The checkout matches the previously reviewed head, whose completed review reported no findings.
Still necessary on main and latest release: Both fetched main and v2026.9.2 retain the unconditional leaf-text escaping hook. The supplied GitHub context identifies this PR as the open implementation candidate for #140785, not an already-merged replacement.
Dependency boundary: package.json pins Marked 18.0.11, and generateExportHtmlVendorAssets bundles that dependency for the export viewer. The changed marked.use renderer directly depends on Marked’s fallback contract; no Codex runtime contract is involved.
Findings None None.
Security None None.

How this fits together

The session export command combines transcript records with a bundled HTML viewer. That viewer renders message Markdown through Marked and OpenClaw’s escaping and URL-safety hooks.

flowchart LR
  A[Session transcript] --> B[Export command]
  B --> C[Standalone HTML file]
  C --> D[Markdown renderer]
  D --> E{Nested inline tokens?}
  E -->|Yes| F[Existing formatting and safety hooks]
  E -->|No| G[Escaped text]
  F --> H[Rendered conversation]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +60, Docs +3. Total +63 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 60 0 +60
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 65 2 +63

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140785
Summary: This PR is the explicitly linked implementation candidate for the reported tight-list export defect; the issue remains open pending merge.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use Marked’s existing nested-token traversal while preserving OpenClaw’s leaf escaping and child safety hooks.

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

Yes: exporting a tight list containing bold text, a link, and inline code exercises the faulty current-main hook; the linked report supplies a real Gateway/TUI reproduction. This review verified the source mechanism without executing it.

Is this the best way to solve the issue?

Yes: delegating composite tokens through Marked’s supported fallback is a narrow repair that reuses the existing parser and safety hooks.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a reproducible formatting defect in exported conversations with a limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The captured evidence ties this renderer change to a real isolated Gateway/TUI export opened in Chromium, with repaired list formatting and preserved controls after the fix. Screenshot retrieval failed during review, but the recorded production-flow observations remain sufficient.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence ties this renderer change to a real isolated Gateway/TUI export opened in Chromium, with repaired list formatting and preserved controls after the fix. Screenshot retrieval failed during review, but the recorded production-flow observations remain sufficient.

Evidence

What I checked:

  • Verified introduced change: The merge-base comparison confirms the narrow renderer repair and documentation addition; the complete supplied introduction evidence also contains the regression test. The checkout matches the previously reviewed head, whose completed review reported no findings. (src/auto-reply/reply/export-html/template.js:1891, d3ff01fd12d4)
  • Still necessary on main and latest release: Both fetched main and v2026.9.2 retain the unconditional leaf-text escaping hook. The supplied GitHub context identifies this PR as the open implementation candidate for HTML session exports display list Markdown literally #140785, not an already-merged replacement. (src/auto-reply/reply/export-html/template.js:1891, d4ac1bcb9a94)
  • Dependency boundary: package.json pins Marked 18.0.11, and generateExportHtmlVendorAssets bundles that dependency for the export viewer. The changed marked.use renderer directly depends on Marked’s fallback contract; no Codex runtime contract is involved. (scripts/runtime-postbuild.mts:355, d3ff01fd12d4)
  • Upstream traversal and fallback contract: Inspected the pinned upstream sources: returning false invokes the previous renderer; its text renderer traverses nested tokens through parseInline, which dispatches through the configured child hooks. Sources: renderer, extension fallback, and inline parser. (src/Renderer.ts:179)
  • Safety hooks remain active: Nested rendering retains the existing raw-HTML escaping, inline-code escaping, remote-image flattening, safe-link protocol checks, and attribute escaping. The patch introduces no dependency, permissions, authority, configuration, or persistence changes. (src/auto-reply/reply/export-html/template.js:1848, d3ff01fd12d4)
  • Behavioral regression coverage: The added parameterized test exercises the composed export template for both message roles, checking actual strong/link/code elements and preserving paragraph, plain-list, and literal-code controls. The captured PR body reports two intended failures before the fix and 22 passing tests afterward; this review did not execute tests. (src/auto-reply/reply/export-html/template.security.test.ts:410, d3ff01fd12d4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • xingzhou: 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-07T05:10:21.336Z sha d3ff01f :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 759c237 into main Sep 7, 2026
166 checks passed
@steipete
steipete deleted the codex/qa-tight-list-export-20260907 branch September 7, 2026 05:38
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
HTML session exports now preserve bold text, links, and inline code in list items for user and assistant messages. Delegate composite Marked text tokens through the existing renderer while retaining leaf escaping and child hooks.

Fixes openclaw#140785.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

HTML session exports display list Markdown literally

1 participant