Skip to content

Remove Markdown parser patch and simplify preview processing - #24919

Merged
nwparker merged 1 commit into
mainfrom
nwparker/markdown-preview-cleanup
Oct 3, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/markdown-preview-cleanup

Conversation

@nwparker

@nwparker nwparker commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​84 $\color{#cf222e}{\Huge{\mathbf{−}}}$​85 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31 $\color{#cf222e}{\Huge{\mathbf{−}}}$​158 $\color{#cf222e}{\Huge{\mathbf{−}}}$​127

ELI5

Large Markdown previews keep the same behavior, while using the released table-parser fix instead of a local library patch. This also removes redundant preview work and rejects oversized blocks before allocating a copy.

What Changed

  • Upgrade the table parser from 2.1.1 to 2.1.2 and delete its patch and patch registration.
  • Replace tests that modify library internals with public parsing regressions covering alignment, escaping, inline syntax, nested tables, references, and source positions across 2,000 tables.
  • Name the normalization and expansion stages explicitly instead of selecting plugins by array position.
  • Check block limits before cloning, with a regression that verifies rejected blocks allocate no clone.
  • Remove unused front-matter computations, scroll-restoration revision plumbing, a highlight ref used only inside one effect, a duplicate cache reset, and an empty translation-catalog entry.

Why

The released parser already fixes the repeated lookup that made table-heavy documents slow. Maintaining the same fix locally is unnecessary. Auditing #24880 also found dead plumbing and avoidable allocations. The worker lifecycle, bounded caches, viewport prioritization, export guards, and loaded-row measurements address reproduced failures and remain in place. The targeted worker aliases remain necessary: native worker-condition configuration still built DOM-dependent code.

Linked Issue

Follow-up to #24880.

Visual Proof

N/A — no intended appearance or interaction change. Hidden Electron checks and inspected screenshots confirm the existing large-preview flow remains intact.

Testing

  • Manually checked rendered previews through hidden Electron screenshots on macOS.
  • Public parser and rejected-block allocation regressions added.

ORCA_BACKGROUND_LAUNCH=1 pnpm test src/renderer/src/components/editor: 1,888 passed, 3 existing skips.

Web typecheck, changed-code quality gates, localization catalog/extraction checks, frozen-lockfile install, Electron build, and web build pass.

Hidden Electron large-preview suite: all 3 scenarios passed, including 1920px/1280px layouts, Find, global references, annotations, TOC, tab restoration, resizing, refresh without collapse or scroll drift, and oversized fallbacks.

Review

Audited the entire original PR for dependency workarounds, duplicate state, parsing stages, worker ownership, cancellation, cache bounds, source annotations, virtual row measurement, navigation, and partial exports. Independent adversarial review covers the cleanup and behavior regressions.

Agent skill upstream boundary

  • Not applicable; no upstream skill implementation is copied.

Notes

No host RPC or file ownership changes. Existing SSH and folder-workspace routing remains intact. Linux, Windows, and live SSH rendering were not exercised locally; CI covers platform checks. No documentation files are included.

Checklist

  • Focused on removing unnecessary Markdown preview maintenance and work
  • Explained behavior, mechanism, and alternatives
  • N/A for appearance changes; rendered behavior verified
  • Reviewed correctness, security, and performance
  • Cross-platform and remote ownership considered
  • Focused tests, typechecking, quality gates, and builds pass; CI covers full repository gates

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes — full initial review of PR #24919 (344bf7c4e6, 14 files) against main.

  • Table parser upgrade + patch removal — bumps micromark-extension-gfm-table 2.1.1 → 2.1.2 and deletes the local patch, its pnpm-workspace.yaml/pnpm-lock.yaml registration, and the config/scripts/markdown-table-edit-map.test.mjs internals test. The upstream 2.1.2 release contains only the same EditMap.add index-map fix the patch carried, so behavior is preserved.
  • Preview plugin refactor — names MARKDOWN_REHYPE_NORMALIZATION_PLUGINS / MARKDOWN_REHYPE_EXPANSION_PLUGINS and replaces positional .slice(...) plugin selection in markdown-preview-document-tree.ts; order is identical to the old slices.
  • Redundant preview work removed — size-checks blocks before structuredClone, drops the duplicate cache.clear(), removes unused foundation front-matter computations, the dead readyRevision scroll plumbing, and a local pendingHighlight ref.
  • Tests — new public-pipeline table regressions and a clone-allocation regression for rejected blocks; the removed internals test is replaced rather than dropped.

Verification performed: confirmed the released 2.1.2 lib/edit-map.js ships the index-map fix and that the release note is limited to that perf fix; confirmed the removed foundation fields and readyRevision have no consumers/effect (document parsing is gated on large previews, where restorePixels is already false); scoped the plugin refactor as order-equivalent; ran the two changed test files (13 passed). No host RPC, SSH, folder-workspace, or wire surfaces are touched.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a50abb19-1e11-4cb4-89bf-6cd99ac52b4b
📥 Commits

Reviewing files that changed from the base of the PR and between e80b550 and 344bf7c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (13)
  • config/patches/[email protected]
  • config/scripts/markdown-table-edit-map.test.mjs
  • pnpm-workspace.yaml
  • src/renderer/src/components/editor/VirtualMarkdownPreviewBody.tsx
  • src/renderer/src/components/editor/markdown-preview-document-engine.ts
  • src/renderer/src/components/editor/markdown-preview-document-tree.ts
  • src/renderer/src/components/editor/markdown-preview-document.test.ts
  • src/renderer/src/components/editor/markdown-preview-plugins.ts
  • src/renderer/src/components/editor/markdown-preview-table-parsing.test.ts
  • src/renderer/src/components/editor/use-markdown-preview-foundation.ts
  • src/renderer/src/components/editor/use-markdown-preview-scroll-viewport.ts
  • src/renderer/src/components/editor/use-markdown-preview-viewport.ts
  • src/renderer/src/i18n/en-runtime-required.json
💤 Files with no reviewable changes (7)
  • src/renderer/src/components/editor/use-markdown-preview-viewport.ts
  • pnpm-workspace.yaml
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/components/editor/markdown-preview-document-engine.ts
  • config/scripts/markdown-table-edit-map.test.mjs
  • src/renderer/src/components/editor/use-markdown-preview-foundation.ts
  • config/patches/[email protected]

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The preview pipeline now separates normalization and expansion, and rejects oversized blocks before cloning. Tests cover oversized blocks and Markdown table parsing. Preview search, cache handling, front matter exposure, and scroll restoration are also updated. The workspace patch for micromark’s EditMap and its associated tests are removed.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 344bf

The preview and table-parser changes are mergeable after normal checks; no actionable behavior regression is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 344bf

Sanitization, document isolation, and rendering limits remain in place, while oversized blocks are rejected before copying. No new security-boundary failure was identified. The remaining uncertainty concerns the replacement dependency and incomplete security coverage.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The traced exposure remains document content processed by the preview worker and renderer, with export consuming rendered DOM rather than introducing another parser. No wider service authority or cross-document reachability was demonstrated by the changed entrypoints.

Trust Boundaries and Controls

  • observed — Potentially hostile Markdown and raw HTML pass through sanitization before block partitioning and deferred expansion. The ordinary preview retains the same ordering. Repository regression assertions check removal of script elements, executable image URLs, and event attributes, providing counterevidence to a sanitizer-bypass concern.

Resilience and Maintainability Implications

  • observed — Oversized blocks are rejected before cloning; the engine discards oversized expanded output and enforces viewport budgets. Document replacement retains active-load and client-identity guards, cancels superseded requests, and closes replaced clients. Refresh failure can retain the previous ready document without accepting an inactive load response.
🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: removing the local Markdown parser patch and simplifying preview processing.
Description check ✅ Passed The description covers the required sections, including the change, reason, issue reference, visual proof, testing, review, and checklist. It explains that there is no intended visual change and repor…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@nwparker
nwparker merged commit c99b202 into main Oct 3, 2026
41 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.

1 participant