emrg: gui renderer — restore production markdown/hljs wiring + vanilla CSS (Batch 5 promise items) - #1025
Conversation
…a CSS (Batch 5 promise items)
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 2026-08-27T06:41:13
Verified this PR fixes a genuine Batch 5 regression (confirmed on master before checkout):
- main.tsx imported only ./shell.css — the vanilla css/ suite deleted by #1024 was never re-imported, so the shipped GUI had no theme tokens (var(--*) unresolved) and no chat styling
- TranscriptView fell back to the no-dep markdown renderer (escaped plain text)
- ResultPanel read window.hljs which nothing ever set (code blocks degraded)
Reviewed the full diff:
- vendorMarkdown.ts: clean UMD wiring (marked/DOMPurify default imports, hljs side-effect import setting window.hljs), follows the design construct-injection pattern; lazy window.hljs read avoids module-eval-order issues
- 4 tests assert against the degraded path (real strong tags / hljs token spans / window.hljs availability / DOMPurify XSS sanitization)
- Shell.tsx: useMemo-cached renderer passed to TranscriptView; fallback still guards
- main.tsx: correct dependency order (tokens → base → components → layout → animations → shell overrides)
- CSS restoration byte-identical to pre-#1024 (verified via git diff against the 2cec0cf blob) — only the stray-brace fix in components.css (required by lightningcss)
Local verification on this branch: vitest 415/415 (42 files), typecheck clean, build CSS 1.9→48.26 kB + JS 453 kB (vendor bundled), GUI npm test 81 pass + 8 skip, pytest 1106 passed + 1 skipped, doc-count guard exit 0. Built CSS confirmed to contain .msg/.tool-row/.composer-card/.dialog/hljs rules and var(--*) theme tokens. CI double-green (run 33018360656). No issues found.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 2026-08-27T06:49:13
Second independent review (cycle 064113 → 064913, consecutive, no issues in between). Re-verified: head a612e67 unchanged, CI double-green (run 33018360656, test + test-windows), MERGEABLE/CLEAN. Full diff reviewed in cycle 064113 with local verification (vitest 415/415, typecheck, build CSS 1.9→48.26 kB, GUI 89, pytest 1106+1, doc-count 0); CSS restoration byte-identical to pre-#1024. No issues found.
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 2026-08-27T07:03:10
Third independent review (064113 → 064913 → 070310, consecutive, no issues in between). Re-verified: head a612e67 unchanged, CI double-green (run 33018360656), MERGEABLE/CLEAN. Full diff + local verification in prior cycles (vitest 415/415, typecheck, build CSS 48.26 kB, GUI 89, pytest 1106+1, doc-count 0). No issues found.
Uh oh!
There was an error while loading. Please reload this page.
… vendor wiring, renderer count 421)
Summary
Restores two production-quality items that the Batch 5 final switch (#1023/#1024) shipped without, both explicitly promised by the migration design:
TranscriptViewfalls back tocreateMarkdownRenderer({ t })(no deps) because no one wired the real vendor libs;ResultPanelreadswindow.hljswhich is never set (ResultPanel comment literally says "Batch 5 接真实 hljs").css/suite (tokens/base/components/layout/animations, ~2718 lines) was deleted with the vanilla renderer (emrg: gui renderer Batch 5 cleanup — delete vanilla renderer + legacy vm.runInContext tests #1024) but never re-imported into the React bundle. React components referencevar(--token)variables (fromtokens.css) and the vanilla class names (components.css/layout.css) — the shipped GUI renders with no theme (inlinevar()unresolved) and no chat styling. The TranscriptView contract says "复用 vanilla CSS,无需改样式表" (reuse vanilla CSS unchanged).Changes
renderer/src/lib/vendorMarkdown.ts(new): wires the real vendor deps into the bundle —marked.min.js/dompurify.min.jsas default imports (UMD),highlight.custom.jsas a side-effect import (setswindow.hljsat runtime, no-op at build time), plus thehighlight.github-dark.csstheme. ExportscreateProdMarkdownRenderer()following the design's construct-injection pattern.renderer/src/lib/vendorMarkdown.test.ts(new, 4 tests): asserts real markdown renders (<strong>,<code>, links), code blocks get hljs language + token spans,window.hljsis available (ResultPanel contract), and DOMPurify sanitizes XSS.renderer/src/vendor.d.ts(new): module declarations for the UMD vendor files.renderer/src/components/Shell.tsx: passes the production renderer toTranscriptView(useMemo-cached).renderer/src/main.tsx: re-imports the restored vanilla CSS in dependency order (tokens → base → components → layout → animations → shell.csslast for React overrides).renderer/css/*(restored verbatim from the pre-emrg: gui renderer Batch 5 cleanup — delete vanilla renderer + legacy vm.runInContext tests #1024 revision, verified byte-identical viagit diff 2cec0cf): one pre-existing malformed rule fixed — a stray trailing}incomponents.cssthat browsers tolerated but the vite lightningcss minifier rejects.Agent.md: renderer test count 411 → 415 (+4 vendorMarkdown); Batch 5 description updated.Verification
tsc --noEmitclean;vitest415 passed (42 files);npm run buildsucceeds (CSS 1.9→48.3 kB — vanilla styles now bundled; JS 295→453 kB — marked/DOMPurify/hljs bundled).distassets confirmed to contain:.msg/.tool-row/.composer-card/.dialog/hljsCSS rules,--tokenvariables,marked/DOMPurify/hljs/highlightAutoin JS, and.react-shelloverrides last.npm test81 pass + 8 skip; doc-count guard 4 passed; import + CLI OK.