Skip to content

perf: skip Markdown fence scans when no toggle opens - #26324

Merged
nwparker merged 2 commits into
mainfrom
nwparker/perf-markdown-details-fence-reuse
Oct 8, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/perf-markdown-details-fence-reuse

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Saving ordinary Markdown still scans the whole document for code fences even when there is no toggle opening tag to examine. This skips that scan while preserving the saved text.

What Changed

Create one lazy matcher per encoding call. It uses the existing shared fence scanner only after a complete opening tag matches, then reuses those ranges for sibling toggles. The current parser, editor transport and save timing stay intact.

Why

The shared scanner already handles the parsing rules. Keeping its result inside one encoding call avoids stale ranges after edits and removes work without adding a persistent cache.

Linked Issue

Maintainer performance audit; no separate issue.

Visual Proof

N/A — string-processing change with no visual or interaction change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Six focused editor suites / 135 tests pass on macOS with the background launch policy. Renderer typecheck passes. The changed-code quality gate passes. Hosted checks will run on the refreshed branch.

A deterministic exercise compared 2,137 inputs under two encoder options: all 4,274 outputs exactly match current main. It covers nested and malformed toggles, code fences, comments, line endings and reference links. The scanner runs once for 50 siblings and zero times in four cases with no matched opening tag. Current-main parsing differences from the older branch remain preserved.

Review

Independent review checked the conflict resolution against current main and exercised the actual encoder and codec. The update preserves the shared scanner already on main and changes only lazy admission and its tests.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer code or fixtures copied.

Notes

No IPC, path handling, keyboard shortcuts, execution-host decisions or wire formats change. Local, folder and SSH workspaces use the same encoder. Physical Windows and Linux runs were not performed locally.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Visual proof is N/A with a reason
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and path/shortcut impact considered
  • Local focused tests, renderer typecheck and changed-code quality gate pass; CI covers the full branch

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 1b1c3a9a-8e68-4202-8fc4-fcb83bfb2f6b
📥 Commits

Reviewing files that changed from the base of the PR and between 7b26725 and a7ee837.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/details-markdown-html.ts
  • src/renderer/src/components/editor/raw-markdown-html.details-fences.test.ts
  • src/renderer/src/components/editor/raw-markdown-html.ts

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


📝 Walkthrough

Walkthrough

The encoder now uses a matcher that computes Markdown fence ranges lazily and reuses them while scanning a document. Added tests cover scan reuse, non-matching content, nested and mixed-case toggles, codec reuse across documents, and fenced code around editable and non-editable details blocks.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to a7ee8

The Markdown toggle optimization has no identified issue requiring a fix before merge.

🚥 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 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the main performance change: avoiding Markdown fence scans when no toggle opening matches. It is concise and specific.
Description check ✅ Passed The description includes all required sections, explains the change and rationale, documents testing, records visual proof as not applicable, and addresses compatibility and scope. It states that no s…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 changed the title perf: avoid repeated fence scans when saving Markdown toggles perf: skip Markdown fence scans when no toggle opens Oct 8, 2026
@nwparker
nwparker merged commit 10a2a6c into main Oct 8, 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.

1 participant