Repository navigation
fix(editor): release oversized Markdown classification inputs - #34798
Conversation
7f9e84a to
6de8afb
Compare
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
[Medium impact] The PR appears safe to merge; the remaining cache-test suggestion is non-blocking. Findings
SummaryThe PR skips unsupported-syntax checks for Markdown documents above 1 MiB and stops retaining those documents in the eligibility cache.
Reviews (2) · Last reviewed commit: "perf(editor): skip Markdown classificati..." · Reviewed by Greptile |
| // Don't retain hard-cap documents; checked after lookup so cache hits skip the UTF-8 probe. | ||
| if (decision.exceedsSizeLimit && exceedsMarkdownRenderOverrideSizeLimit(content)) { | ||
| return decision | ||
| } |
There was a problem hiding this comment.
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.
6de8afb to
7979caa
Compare
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
getMarkdownRichModeEligibilityDecisionreturns{ exceedsSizeLimit: true, unsupportedReason: null }right away when the content is over the hard cap.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:changedpasses.