Skip to content

优化 Mermaid 多图文档的滚动性能 - #19

Merged
bifrost-proxy merged 1 commit into
mainfrom
codex/lazy-mermaid-preview
Aug 14, 2026
Merged

bifrost-proxy merged 1 commit into
mainfrom
codex/lazy-mermaid-preview

Conversation

@bifrost-proxy

Copy link
Copy Markdown
Owner

变更

  • Mermaid 图表接近可视区时才在空闲时段开始渲染
  • 图表离开可视区后卸载 SVG DOM,并保留原高度避免滚动跳动
  • 再次进入可视区时直接恢复缓存结果,不重复执行 Mermaid
  • 增加 content-visibility 浏览器布局/绘制优化
  • 发布版本同步至 1.2.7

验证

  • npm test:197 个测试文件通过,2403 个测试通过,7 个跳过
  • npm run lint
  • npm run renderer:build
  • node scripts/sync-tauri-version.mjs --check 1.2.7
  • Cargo locked metadata 校验

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ce82a184f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1145 to +1146
private dispose() {
this.destroyed = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reset the widget when CodeMirror remounts it

When a diagram scrolls far enough outside CodeMirror's rendered viewport, CodeMirror destroys its DOM while the decoration can retain the same MermaidDiagramWidget instance and call toDOM() again when the user scrolls back. Permanently setting destroyed here means the new DOM's observeVisibility() immediately returns, leaving the diagram stuck on “Rendering Mermaid diagram...” instead of restoring its cached SVG.

Useful? React with 👍 / 👎.

@bifrost-proxy
bifrost-proxy merged commit 5211f6b into main Aug 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants