Skip to content

统一网页前端的 Markdown 与 Mermaid 渲染能力 - #157

Open
Postroggy wants to merge 7 commits into
superduck-ai:mainfrom
Postroggy:codex/quickstart-markdown-156
Open

统一网页前端的 Markdown 与 Mermaid 渲染能力#157
Postroggy wants to merge 7 commits into
superduck-ai:mainfrom
Postroggy:codex/quickstart-markdown-156

Conversation

@Postroggy

@Postroggy Postroggy commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

问题

模型输出会出现在 Quickstart、Session transcript 和 Workbench。此前 Quickstart assistant 消息按普通字符串展示,Session 使用功能内手写的有限 Markdown parser,Workbench Preview/Evaluate 仍按纯文本展示,导致同一模型输出在不同页面的语法能力、安全策略和 Mermaid 行为不一致。

Closes #156
Closes #158
Closes #159

实现

  • 新增共享 MarkdownContent,基于 react-markdownremark-gfm 渲染 CommonMark/GFM,并统一接入 Quickstart assistant、Session transcript/thinking、Workbench Response Preview 和 Evaluate 模型输出。
  • 删除 Session 专属手写 parser、block 类型和重复 URL 白名单;JSON、日志、指标、命令及 tool payload 继续走原有结构化展示。
  • 用户消息、可编辑 prompt/system prompt、错误、状态和普通产品文案不解释为 Markdown,避免改变原始语义。
  • 普通代码围栏复用项目现有 Highlight.js 能力,支持 JavaScript、JSON、Python、Bash、TypeScript 和 YAML;未知语言安全降级为纯文本。
  • mermaid 围栏按需动态加载 Mermaid,并针对浅色/深色主题重新渲染;流式围栏闭合前仅展示源码。
  • Mermaid 使用严格安全模式、20,000 字符源码上限和 flowchart 边数上限;非法、超限或加载失败时保留源码并显示本地化状态。
  • 跳过原始 HTML 和远程图片,限制链接协议,拒绝 javascript: 与协议相对 URL;外部链接使用 noreferrer noopener
  • 新增中文跨功能设计文档,记录消费边界、安全、流式和失败回退合同。

验证

  • 完整前端测试:386 个测试、9781 条断言、0 失败。
  • Managed Agents:143 个测试、1771 条断言、0 失败。
  • Workbench:76 个测试、745 条断言、0 失败。
  • bun run buildjust web-format-checkbun run lint:namingjust duplicatesjust complexityjust large-files 通过。
  • Playwright 加载实际共享组件验证标题、强调、删除线、引用、GFM 表格和 Mermaid;Mermaid 生成 595 x 278 的 SVG,包含 11 条 path。
  • 提交时针对暂存文件的全部 pre-commit hook 通过。
image image

已知基线问题

  • 全仓库 bun run lint 在当前基线上已有 88 个错误;本次修改的 Session 文件也包含既有 effect/setState lint 错误,本次没有扩大该问题。
  • just hooks-run 的全量私钥扫描会命中两个既有密钥生成测试夹具;其余 hook 全部通过。

Summary by CodeRabbit

  • New Features

    • Added consistent Markdown rendering for assistant responses in Quickstart, session transcripts, Workbench, and Evaluate views.
    • Added syntax highlighting for supported code blocks.
    • Added Mermaid diagram rendering with theme support and responsive display.
    • Added localized Mermaid error and size-limit messages.
  • Safety Improvements

    • Prevented unsafe links, raw HTML, and remote images from rendering.
    • User messages remain plain text.
    • Mermaid failures preserve the original source for review.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Postroggy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 315a912e-6cc8-41eb-ae59-600c3e33131e

📥 Commits

Reviewing files that changed from the base of the PR and between fe951c4 and 36d5605.

📒 Files selected for processing (2)
  • docs/design/fe/shared-markdown-rendering.md
  • web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx
📝 Walkthrough

Walkthrough

Model-generated text now uses a shared safe Markdown renderer across Quickstart, Session transcripts, and Workbench. Code fences support shared highlighting, closed Mermaid fences render asynchronously with fallbacks, and user or structured content retains non-Markdown handling.

Changes

Shared Model Markdown Rendering

Layer / File(s) Summary
Safe Markdown renderer
web/package.json, web/src/shared/ui/markdown-content.tsx
Adds GFM rendering, safe URL filtering, HTML and image suppression, and custom code-block handling.
Code and Mermaid rendering
web/src/shared/ui/syntax-highlighting.ts, web/src/shared/ui/syntax-code-block.tsx, web/src/shared/ui/remark-mermaid-fence-state.ts, web/src/shared/ui/mermaid-diagram.tsx, web/src/shared/i18n/messages/*.json
Adds shared syntax highlighting, closed-fence detection, queued asynchronous Mermaid rendering, limits, theming, and localized source-preserving fallbacks.
Frontend surface integration
web/src/features/managed-agents/quickstart/..., web/src/features/managed-agents/sessions/..., web/src/features/workbench/evaluate.tsx, web/src/features/managed-agents/components/CodeBlocks.tsx
Routes assistant, transcript, and Workbench model output through shared Markdown rendering while preserving plain-text or structured-content paths.
Validation and contracts
web/src/features/managed-agents/*.suite.tsx, web/src/features/workbench/WorkbenchPage.test.tsx, docs/design/fe/*.md, web/src/test/setup.ts
Adds rendering, safety, Mermaid, Workbench, localization-support, and SVG test coverage and documents the shared contract.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModelOutput
  participant QuickstartTextTurn
  participant SessionTracePanel
  participant Workbench
  participant MarkdownContent
  participant MermaidDiagram
  ModelOutput->>QuickstartTextTurn: provide assistant text
  ModelOutput->>SessionTracePanel: provide transcript text
  ModelOutput->>Workbench: provide model output
  QuickstartTextTurn->>MarkdownContent: render assistant Markdown
  SessionTracePanel->>MarkdownContent: render transcript Markdown
  Workbench->>MarkdownContent: render preview or successful output
  MarkdownContent->>MermaidDiagram: render closed Mermaid fence asynchronously
  MermaidDiagram-->>MarkdownContent: return SVG or preserved source fallback
Loading

Possibly related issues

  • #159 — Directly covers the shared Markdown/Mermaid renderer and migration implemented here.

Possibly related PRs

Suggested reviewers: arthur-zhang, jh0904

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds shared Markdown and Mermaid rendering, safety controls, and tests that match #156 and #158 requirements.
Out of Scope Changes check ✅ Passed The docs, shared UI, dependency, and test updates all support the Markdown/Mermaid work and appear in scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了此次前端统一 Markdown 与 Mermaid 渲染能力的主要改动。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Postroggy
Postroggy marked this pull request as ready for review July 25, 2026 08:24

@duckpr duckpr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DuckPR reviewer: opencode
Model: anthropic/glm-5.2

✅ 安全实现到位,可以合并。

Reviewed changes — 本 PR 为 Quickstart 助手文本气泡启用 GitHub Flavored Markdown 渲染,新增共享组件 MarkdownContent 并仅对 assistant 角色启用,用户消息保持纯文本,SSE 与后端合同不变。

  • 新增共享 MarkdownContent 组件web/src/shared/ui/markdown-content.tsx)— 基于 react-markdown@10 + remark-gfm@4,通过 skipHtml 跳过原始 HTML、urlTransform 白名单(safeMarkdownUrl 仅放行 https?:/mailto:///#)和 img 渲染为 null 三道防线阻止 XSS;react-markdown v10 的 urlTransform 在 props 到达自定义 a 组件之前应用,组合安全模型正确。
  • QuickstartTextTurn 集成web/src/features/managed-agents/quickstart/chatLayout.tsx)— isUser ? content : <MarkdownContent value={content} />,用户/助手角色分流最小且正确。
  • 聚焦测试ManagedAgentsPage.quickstart.suite.tsx)— 新增 2 个用例覆盖加粗、行内代码、列表、代码块、GFM 表格、安全/危险链接过滤、原始 HTML 跳过与用户消息纯文本。
  • 依赖与文档react-markdown/remark-gfm 加入 package.json 并更新 bun.lock;设计文档记录渲染与安全边界。

ℹ️ Nitpicks

  • Markdown 代码块未接入仓库已有的 highlight.js 体系(web/src/features/managed-agents/components/CodeBlocks.tsxweb/AGENTS.md 约定 quickstart 代码块应产出 code.language-*hljs-* token span)。当前 MarkdownContentcode/pre 只输出纯文本。是否让模型返回的 Markdown 代码块与 template 驱动的代码块保持一致的语法高亮,属于产品决策,建议作为后续 issue 跟进。

Pullfrog  | View workflow run | Using anthropic/glm-5.2𝕏

Comment thread web/src/shared/ui/markdown-content.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
web/src/shared/ui/markdown-content.tsx (2)

57-70: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Hoist remarkPlugins to avoid a new array on every render.

markdownComponents is already a module-level constant; remarkPlugins={[remarkGfm]} isn't, so it's reallocated on every render — notably on every streaming delta re-render of assistant messages.

♻️ Proposed hoist
+const remarkPlugins = [remarkGfm];
+
 export function MarkdownContent({ value, className }: { value: string; className?: string }) {
   return (
     <div className={clsx('space-y-3 whitespace-normal break-words', className)}>
       <ReactMarkdown
-        remarkPlugins={[remarkGfm]}
+        remarkPlugins={remarkPlugins}
         components={markdownComponents}
         skipHtml
         urlTransform={safeMarkdownUrl}
       >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/shared/ui/markdown-content.tsx` around lines 57 - 70, Hoist the
remarkPlugins array used by MarkdownContent to module scope, alongside
markdownComponents, and reuse that stable constant in the ReactMarkdown props
instead of allocating [remarkGfm] during each render.

10-22: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Drop anchors for blocked markdown links

For unsafe URLs, urlTransform returns '', and MarkdownLink currently renders <a href="">Unsafe link</a>. That’s a non-navigable placeholder anchor rather than a proper link, so render the children as plain text when href is empty and avoid the invalid anchor.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/shared/ui/markdown-content.tsx` around lines 10 - 22, Update
MarkdownLink to detect an empty href, including the blocked-URL result from
urlTransform, and render children without an anchor in that case. Preserve the
existing anchor attributes and external-link behavior for non-empty href values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/shared/ui/markdown-content.tsx`:
- Around line 6-8: Update safeMarkdownUrl so the site-internal path check
accepts a single-slash path but rejects protocol-relative URLs beginning with
"//". Preserve the existing https, mailto, fragment, and valid internal-path
behavior.

---

Nitpick comments:
In `@web/src/shared/ui/markdown-content.tsx`:
- Around line 57-70: Hoist the remarkPlugins array used by MarkdownContent to
module scope, alongside markdownComponents, and reuse that stable constant in
the ReactMarkdown props instead of allocating [remarkGfm] during each render.
- Around line 10-22: Update MarkdownLink to detect an empty href, including the
blocked-URL result from urlTransform, and render children without an anchor in
that case. Preserve the existing anchor attributes and external-link behavior
for non-empty href values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cdc04573-e179-4a99-9a66-d37759a98aaa

📥 Commits

Reviewing files that changed from the base of the PR and between 6a05c2a and 70cb839.

⛔ Files ignored due to path filters (1)
  • web/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • docs/design/fe/managed-agent-quickstart-interactions.md
  • web/package.json
  • web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx
  • web/src/features/managed-agents/quickstart/chatLayout.tsx
  • web/src/shared/ui/markdown-content.tsx

Comment thread web/src/shared/ui/markdown-content.tsx
@Postroggy Postroggy changed the title 修复 Quickstart 助手消息的 Markdown 渲染 完善 Quickstart 助手消息的 Markdown 与 Mermaid 渲染 Jul 25, 2026

@duckpr duckpr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DuckPR reviewer: opencode
Model: anthropic/glm-5.2

✅ 未发现新问题。

Reviewed changes — 本轮覆盖自上一次 DuckPR 评审(70cb839)以来的增量:补齐显式语言代码高亮、新增异步 Mermaid 图表渲染、抽取共享语法高亮模块,并修复上一轮的全部 nitpick。

  • 抽取共享语法高亮web/src/shared/ui/syntax-highlighting.tssyntax-code-block.tsx)— 将原 CodeBlocks.tsx 内联的 highlight.js 注册、normalizeHighlightLanguagehighlightCodeHTMLhighlightBashYAMLCommandHighlightedCode/SyntaxCodeBlock 迁移到 shared/ui,并在 CodeBlocks.tsx 通过 export { ... } 保留原公共导出(highlightBashYamlCommand/highlightCodeHtml 按命名规范别名),MiniCodeBlock/NumberedCodeBlock/ScrollableCodeBlock/TemplateCard 等行为不变。机械迁移边界干净,没有把会话级语义泄漏到共享层。
  • Markdown 代码围栏接入高亮markdown-content.tsx)— pre 组件读取子 codelanguage-* class 与文本源,转发给共享 SyntaxCodeBlockremarkPlugins 已提升为模块级常量 markdownRemarkPlugins,避免每次流式重渲染重新分配数组。
  • Mermaid 异步渲染mermaid-diagram.tsx + remark-mermaid-fence-state.ts)— mermaid 围栏走独立路径:自定义 remark 插件依据 position offset 标注 data-mermaid-closed,未闭合的流式围栏只展示源码;MermaidDiagramuseId 生成稳定渲染 ID,模块级 renderQueue 串行化初始化避免多图表/主题切换互相覆盖配置,renderSequence 保证每次 mermaid.render 拿到唯一 ID。150ms 稳定窗口 + current flag 防止卸载或源码变化后旧异步结果覆盖新内容;renderKey 携带 resolvedTheme + source,主题切换正确触发重渲染。
  • 安全边界 — Mermaid 固定 securityLevel: 'strict'startOnLoad: falsesuppressErrorRendering: true,先 mermaid.parse(source, { suppressErrors: true })mermaid.render,失败/超限(20,000 字符、flowchart 200 边)走源码 + 本地化状态回退;SVG 经 Mermaid 内置 DOMPurify 清洗后通过 dangerouslySetInnerHTML 注入,与官方“不可信输入”指引一致。MarkdownLink 已按上一轮反馈改为 rel="noreferrer noopener",并对空 href(含被 safeMarkdownUrl 拦截为 '' 的 URL)降级为纯文本。
  • 测试与文档 — 新增 Mermaid 非法语法、超限、未闭合流式围栏、六种显式语言高亮、协议相对链接拦截、自动链接、任务列表、引用等回归;test/setup.ts 补充 getBBox/SVGElement/SVGGraphicsElement/CSSStyleSheet 以支撑 Mermaid 在 happy-dom 下渲染;设计文档补全 Mermaid 渲染、安全与回退合同及流程图。

PullfrogView workflow run | Using anthropic/glm-5.2𝕏

Pullfrog  | View workflow run | Using anthropic/glm-5.2𝕏

@Postroggy Postroggy changed the title 完善 Quickstart 助手消息的 Markdown 与 Mermaid 渲染 统一模型输出的 Markdown 与 Mermaid 渲染 Jul 25, 2026

@duckpr duckpr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DuckPR reviewer: opencode
Model: anthropic/glm-5.2

✅ 未发现新问题。

Reviewed changes — 本轮覆盖自上一次 DuckPR 评审(7024dba)以来的增量:删除 Session 专属手写 Markdown parser 并接入共享 MarkdownContent、Workbench Response Preview 与 Evaluate 输出接入同一共享组件,并新增跨功能设计文档。

  • Session 迁移到共享渲染器SessionTracePanel.tsxsessionTraceModel.tstypes.ts)— 删除 parseTranscriptCode/parseTranscriptMarkdownBlocks/isSafeTranscriptMarkdownHref/TranscriptMarkdownBlockrenderTranscriptMarkdown* 系列,TranscriptContent 直接渲染 MarkdownContentTranscriptTypedContent 仍按 displayKindjson/log/metric/command)走结构化 SyntaxCodeBlock 分支,原始 JSON 展示边界不变。确认无残留死代码引用,looksLikeJson/prettyCode 仍被 debug JSON 路径使用。
  • Workbench 接入共享 Markdownevaluate.tsx)— ResponsePreview 仅在 responseText 存在时用 MarkdownContentEvaluateOutputCell 仅在成功且有 output 时使用。运行中状态、错误和空状态保持纯文本,并由 **Model** request failed.alert.querySelector('strong')null 的回归保护。
  • 跨功能设计文档docs/design/fe/shared-model-output-markdown.md)— 记录四个消费边界、共享合同(CommonMark/GFM、显式语言高亮、Mermaid 安全与回退)、Session 与 Workbench 迁移细节和验收标准,含 Mermaid 消费边界流程图。
  • 依赖与测试门禁package.json 新增 mermaid 11.16.0(锁定版本)、react-markdown ^10.1.0remark-gfm ^4.0.1type-fest ^4.41.0(devDependency);Workbench 新增 Response Preview 与 Evaluate 的 Markdown 渲染用例,error 用例改为带 Markdown 标记验证错误不解释为 Markdown;Quickstart/resources suite 随 Session 迁移更新 testid 并补充 blockquote/em/del 断言。

Pullfrog  | View workflow run | Using anthropic/glm-5.2𝕏

@Postroggy Postroggy changed the title 统一模型输出的 Markdown 与 Mermaid 渲染 统一网页前端的 Markdown 与 Mermaid 渲染能力 Jul 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx (1)

273-287: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Anchor the streaming-fence wait to the Mermaid delay constant instead of a hard-coded 300 ms.

If MERMAID_RENDER_DELAY_MS is ever raised above 300 ms, this test passes for the wrong reason (nothing has had time to render yet) rather than because the fence is still open.

♻️ Suggested approach

Export the delay constant from web/src/shared/ui/mermaid-diagram.tsx and sleep MERMAID_RENDER_DELAY_MS * 2, or assert via waitFor that markdown-code-block keeps the partial source while [data-mermaid-state] stays absent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx`
around lines 273 - 287, Update the streaming-fence test around the Mermaid
rendering delay to use the shared MERMAID_RENDER_DELAY_MS constant instead of a
hard-coded 300 ms timeout. Export and import that constant from
mermaid-diagram.tsx, then wait at least twice its duration before asserting that
no Mermaid diagram or state exists while the partial markdown remains visible.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx`:
- Around line 273-287: Update the streaming-fence test around the Mermaid
rendering delay to use the shared MERMAID_RENDER_DELAY_MS constant instead of a
hard-coded 300 ms timeout. Export and import that constant from
mermaid-diagram.tsx, then wait at least twice its duration before asserting that
no Mermaid diagram or state exists while the partial markdown remains visible.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e00d1e54-f40d-440c-9e22-1716fdbb6c64

📥 Commits

Reviewing files that changed from the base of the PR and between 70cb839 and fe951c4.

⛔ Files ignored due to path filters (1)
  • web/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • docs/design/fe/managed-agent-quickstart-interactions.md
  • docs/design/fe/shared-model-output-markdown.md
  • web/package.json
  • web/src/features/managed-agents/ManagedAgentsPage.quickstart.suite.tsx
  • web/src/features/managed-agents/ManagedAgentsPage.resources.suite.tsx
  • web/src/features/managed-agents/ManagedAgentsPage.test-utils.tsx
  • web/src/features/managed-agents/components/CodeBlocks.tsx
  • web/src/features/managed-agents/sessions/SessionTracePanel.tsx
  • web/src/features/managed-agents/sessions/sessionTraceModel.ts
  • web/src/features/managed-agents/types.ts
  • web/src/features/workbench/WorkbenchPage.test.tsx
  • web/src/features/workbench/evaluate.tsx
  • web/src/shared/i18n/messages/en.json
  • web/src/shared/i18n/messages/zh-CN.json
  • web/src/shared/ui/markdown-content.tsx
  • web/src/shared/ui/mermaid-diagram.tsx
  • web/src/shared/ui/remark-mermaid-fence-state.ts
  • web/src/shared/ui/syntax-code-block.tsx
  • web/src/shared/ui/syntax-highlighting.ts
  • web/src/test/setup.ts
💤 Files with no reviewable changes (2)
  • web/src/features/managed-agents/types.ts
  • web/src/features/managed-agents/sessions/sessionTraceModel.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/package.json
  • web/src/shared/ui/markdown-content.tsx

@Postroggy

Copy link
Copy Markdown
Contributor Author

本轮 review 已在 525e871 处理:未闭合 Mermaid fence 的测试不再等待硬编码 300ms,而是同步断言解析结果仍为普通代码块,且没有创建 Mermaid 渲染节点。这个断言直接验证组件边界,也不再与实现中的 debounce 时间耦合。聚焦测试、完整前端测试(386 项)、构建、duplicates、complexity、命名、格式及大文件检查均通过。

@duckpr duckpr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DuckPR reviewer: opencode
Model: anthropic/glm-5.2

✅ 未发现新问题。

Reviewed changes — 本轮覆盖自上一次 DuckPR 评审(fe951c4)以来的增量:文档命名与消费边界澄清,以及流式围栏测试同步化。

  • 修正设计文档命名docs/design/fe/shared-markdown-rendering.mdf856a46)— 标题从「模型输出 Markdown 统一渲染」改为「网页前端 Markdown 与 Mermaid 统一渲染」,背景表述从「模型生成文本」泛化为「Markdown 内容可能来自模型、用户或其他数据源」,与共享能力不限内容来源、由消费页面决定渲染策略的实现一致。
  • 澄清消费边界(同文件,1a70a71)— 将「消费边界」重组为「能力与消费边界」,更新 Mermaid 流程图区分「声明为 Markdown」与「保留原始语义」两条路径,并显式说明新增消费方不得自行实现另一套 parser。
  • 稳定流式围栏测试ManagedAgentsPage.quickstart.suite.tsx525e871)— 将 does not start Mermaid rendering until a streaming fence is closedasync 改为同步,移除 await new Promise(setTimeout 300ms) 硬编码等待。未闭合围栏经 remarkMermaidFenceState 标注 data-mermaid-closed=false 后走 SyntaxCodeBlock 同步路径,MermaidDiagram 组件根本不会挂载,MERMAID_RENDER_DELAY_MS(150ms)render delay 不适用,断言即时成立。这同时回应了 CodeRabbit 关于硬编码 300ms 超时的 nitpick。

Pullfrog  | View workflow run | Using anthropic/glm-5.2𝕏

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

Labels

None yet

Projects

None yet

1 participant