refactor(webui): unify code and diff highlighting (#6412)

* refactor(webui): unify code and diff highlighting

Replace Prism with shared Highlights tokens and Pierre read-only diffs, retaining rare grammars through lazy Shiki and preserving source, copy, preview and diff controls.

Restore single-session Composer ownership inside the conversation column while retaining the shared multi-pane footer. Keep the measured large-diff scroll regression explicit during review.

* fix(webui): contain highlighting errors and retain diff selections

Refs NAN-343

* test(webui): align pane fixtures after main rebase

* chore(webui): update highlighting dependencies

Keep grammar fallback coverage on a language that still requires Shiki, and align reading-size assertions with main.
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-06 16:41:12 +08:00
1 parent f5c359476b
commit 3a37269f3f
44 files changed
+2261 -1072

No files matched your search

+3 -13
View File
@@ -32,7 +32,7 @@ function startupSkeleton(): Plugin {
const GZIP_MIN_BYTES = 4 * 1024;
const GZIP_ASSET_PATTERN = /\.(?:css|html|js|json|mjs|svg)$/i;
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "markdown-diagrams-", "MermaidBlock-", "syntax-highlight-", "katex-"];
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "markdown-diagrams-", "MermaidBlock-", "HighlightedCode-", "code-highlighter-", "PierreFileDiff-", "katex-"];
export function entryLazyFeatureImports(imports: string[]): string[] {
return imports.filter((fileName) =>
@@ -105,21 +105,9 @@ export function webuiManualChunk(id: string): string | undefined {
) {
return "react-vendor";
}
if (id.includes("node_modules/refractor/lang/")) {
return;
}
// Streamdown retains a lazy viewer shell, not the native Mermaid engine.
if (id.includes("node_modules/streamdown/dist/mermaid-")) return "markdown-diagrams";
if (id.includes("node_modules/streamdown/dist/highlighted-body-")) return "markdown-code";
// Refractor reaches this HAST helper through hastscript. Keeping it with
// Refractor prevents syntax-highlight <-> markdown-vendor circular chunks.
if (
id.includes("node_modules/react-syntax-highlighter")
|| id.includes("node_modules/refractor/core")
|| id.includes("node_modules/hast-util-parse-selector")
) {
return "syntax-highlight";
}
if (
id.includes("node_modules/streamdown")
|| id.includes("node_modules/remend")
@@ -159,6 +147,8 @@ export default defineConfig(({ mode }) => {
// so nested overlays can dismiss the wrong layer in development.
include: [
"@radix-ui/react-dialog",
"@pierre/diffs", "@pierre/diffs/worker", "@pierre/highlights",
"shiki/core", "shiki/langs", "shiki/engine/javascript",
// Vite's HTML scan does not follow the lazy Worker entry. Discovering
// these imports on first render would reload the page and lose UI state.
"pele/lazy", "saxes", "css-tree/parser", "css-tree/walker", "css-tree/generator",