ui: highlight WebChat code blocks#83569
Conversation
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
|
Codex review: passed. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. PR rating Rank-up moves:
What the crustacean ranks mean
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. PR egg Rarity: 🥚 common. What is this egg doing here?
Real behavior proof Mantis proof suggestion Next step before merge Security Review detailsBest possible solution: Land this PR after the exact-head CI and dependency gate completes, keeping highlighting inside the sanitized WebChat markdown renderer with the bounded language set. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Is this the best way to solve the issue? Yes. The renderer-level highlight.js integration is the narrow maintainable solution because it preserves DOMPurify, markdown caching, copy buttons, language labels, and JSON collapse behavior. Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 46c622aa3b35. |
|
Dependency-change follow-up: this dependency update is intentional. |
6f85023 to
c6dc90b
Compare
c6dc90b to
7bb95c4
Compare
|
The selector/DOM mismatch was fixed in |
|
@clawsweeper automerge |
|
🦞✅ Source: What merged:
Automerge notes:
The automerge loop is complete. Automerge progress:
|
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c47edd4cd27037da33dda85de5ae72948f4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c47edd4cd27037da33dda85de5ae72948f4 Review: openclaw/openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c47edd4cd27037da33dda85de5ae72948f4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c47edd4cd27037da33dda85de5ae72948f4 Review: openclaw/openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary: - The PR adds highlight.js-backed WebChat code-block highlighting, scoped token CSS, regression tests, a type shim, and a direct UI dependency. - Reproducibility: not applicable. as a bug reproduction; this is a feature addition. The feature gap is source-evident because current main renders code blocks as escaped plaintext without hljs token markup. Automerge notes: - No ClawSweeper repair was needed after automerge opt-in. Validation: - ClawSweeper review passed for head 7bb95c4. - Required merge gates passed before the squash merge. Prepared head SHA: 7bb95c4 Review: openclaw#83569 (comment) Co-authored-by: zhengzuo0-ai <zheng.zuo0@gmail.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Fixes #10029.
Summary
highlight.jsto the Control UI markdown renderer using the core highlighter plus a bounded set of common chat/code languages.Verification
OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=60000 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui.config.ts ui/src/ui/markdown.test.ts ui/src/styles/components.test.ts./node_modules/.bin/tsgo --noEmit --project test/tsconfig/tsconfig.test.ui.jsonCOREPACK_HOME=/private/tmp/corepack /usr/local/bin/corepack pnpm exec oxfmt --check --threads=1 ui/src/ui/markdown.ts ui/src/ui/markdown.test.ts ui/src/types/highlight-js-subpaths.d.ts ui/src/styles/components.css ui/src/styles/components.test.ts../node_modules/.bin/vite buildfromui/COREPACK_HOME=/private/tmp/corepack /usr/local/bin/corepack pnpm buildgit diff --check -- ui/src/ui/markdown.ts ui/src/ui/markdown.test.ts ui/src/types/highlight-js-subpaths.d.ts ui/src/styles/components.css ui/src/styles/components.test.ts ui/package.json pnpm-lock.yamlOPENCLAW_ADDITIONAL_BOUNDARY_SHARD=1/4 OPENCLAW_ADDITIONAL_BOUNDARY_CONCURRENCY=4 node scripts/run-additional-boundary-checks.mjsReal behavior proof
Behavior addressed: WebChat markdown code blocks now render syntax-highlight token markup for explicit languages and confident auto-detected unlabeled blocks, while existing code-block chrome still exposes the original text for copy actions.
Real environment tested: macOS local OpenClaw checkout on Node v24.13.1, branch
fix/webchat-code-syntax-highlighting, using the Control UI markdown renderer with a jsdom browser DOM and a Chrome local renderer proof page generated from this PR head.Exact steps or command run after this patch: Ran a live Control UI markdown renderer probe with
node --import tsx --input-type=module, created a jsdom browser DOM, imported./ui/src/ui/markdown.ts, rendered C++ and HTML fenced blocks withtoSanitizedMarkdownHtml, and queried the resulting DOM. Also opened a local proof page generated from this PR head (7bb95c47ed) usingtoSanitizedMarkdownHtmloutput plus the currentcomponents.css.Evidence after fix: Terminal output from the renderer probe:
Observed result after fix: The actual renderer output contained
hljstoken markup for the C++ block, preserved the copy payload as the original plain text, and kept the HTML script sample as inert code text with 0 script elements inside the rendered code block.Manual WebChat browser proof after selector fix: The screenshot shows fenced TypeScript and C++ code blocks with visible syntax-highlight colors under the generated
.code-block-wrapper pre code.hljsDOM path. I clicked a Copy button, and it changed toCopied!, confirming the existing copy-button state still works while highlighted code remains visible.What was not tested: A full authenticated Gateway/WebChat session against a live model was not tested. The browser proof used a local renderer proof page generated from this PR head with the same
toSanitizedMarkdownHtmloutput andcomponents.css, plus the renderer probe above verified the DOM and copy payload.AI assistance
AI-assisted with Codex. I reviewed the implementation and understand the code path and validation above.