Skip to content

fix(editor): release oversized Markdown classification inputs - #34798

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-markdown-retention
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-markdown-retention

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12

Problem

When a Markdown file is open in rich view mode, every draft change runs the whole-document rich-mode eligibility check. For files over the 1 MiB hard render cap (MARKDOWN_RENDER_OVERRIDE_MAX_SIZE_BYTES), that check still ran the full unsupported-syntax scan: frontmatter extraction, code stripping, regex scans and, for documents containing HTML, a whole-document codec round-trip. The result could never change what renders. Above the hard cap the editor always falls back to source, and "Open anyway" is not offered. The 4-entry eligibility cache also kept up to four of these multi-MB strings alive after their tabs closed.

Fix

  • getMarkdownRichModeEligibilityDecision returns { exceedsSizeLimit: true, unsupportedReason: null } right away when the content is over the hard cap.
  • The eligibility cache no longer stores those decisions, so it doesn't retain oversized documents. The check runs after the cache lookup, so cache hits don't pay for the UTF-8 size probe.

Files between the soft limit (600 KiB) and the hard cap are still classified, so unsupported syntax still blocks "Open anyway". The only visible change: a file over 1 MiB that also contains unsupported syntax now shows the size-limit banner instead of the unsupported-syntax banner. Neither banner offers an override.

Test

  • markdown-rich-mode.test.ts: a document over the hard cap that contains a reference link now reports only the size limit (unsupportedMessage: null), while a small reference-link document is still flagged. This test fails without the fix.
  • pnpm check:changed passes.

@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-markdown-retention branch from 7f9e84a to 6de8afb Compare October 28, 2026 23:45
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:08
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 480074a4-ad12-46b1-b7ec-8349aac16d80
Commits

Reviewing files that changed from the base of the PR and between b2feed0 and 7979caa.

Files selected for processing: 3
  • src/renderer/src/components/editor/markdown-rich-mode-eligibility-cache.ts
  • src/renderer/src/components/editor/markdown-rich-mode.test.ts
  • src/renderer/src/components/editor/markdown-rich-mode.ts
  • Autofix · 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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining cache-test suggestion is non-blocking.

Findings

  1. P2 Cache bypass lacks test coverage ▶

Summary

The PR skips unsupported-syntax checks for Markdown documents above 1 MiB and stops retaining those documents in the eligibility cache.

  • Markdown drafts above 1 MiB skip syntax checks and show the size limit.
  • The eligibility cache no longer holds Markdown drafts above 1 MiB.

Reviews (2) · Last reviewed commit: "perf(editor): skip Markdown classificati..." · Reviewed by Greptile

Comment on lines +50 to +53
// Don't retain hard-cap documents; checked after lookup so cache hits skip the UTF-8 probe.
if (decision.exceedsSizeLimit && exceedsMarkdownRenderOverrideSizeLimit(content)) {
return decision
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Cache bypass lacks test coverage

The new test calls getMarkdownRichModeEligibility, so it never exercises this cache guard. Removing the guard would restore retention of oversized strings without failing that test. Add a cache regression test that confirms oversized requests are not cached and do not evict existing small-document entries.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Above the 1 MiB override cap a Markdown file can never render rich, so
skip the unsupported-syntax scan and keep those documents out of the
eligibility cache.
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-markdown-retention branch from 6de8afb to 7979caa Compare October 29, 2026 00:28
@OrcaWin
OrcaWin merged commit c8fe5d4 into main Oct 29, 2026
33 of 35 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