fix(markdown): render file previews statically#913
Conversation
📝 WalkthroughWalkthroughTwo new props, mode="static" and parseIncompleteMarkdown={false}, were added to the Streamdown component in MarkdownPreviewPane.tsx, altering its markdown parsing/rendering behavior. A new test file was added to verify these configuration values via source extraction. ChangesMarkdown Preview Rendering Configuration
Estimated code review effort: 1 (Trivial) | ~3 minutes Related PRs: None identified. Suggested labels: markdown, tests Suggested reviewers: None identified. No secret sauce needed here — flipping Streamdown to static mode and turning off incomplete-markdown repair is a two-line change, and the test cleverly regex-scrapes the source to keep it honest. Bundle size, RAM, and terminal-first ethos: unaffected. My only nudge — the regex-based test is a bit brittle to formatting changes in the JSX, but for a two-prop guardrail, it's fine. Ship it. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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 |
What
Render file-backed Markdown previews in
staticmode instead of Streamdown's streaming/incomplete-repair path. Add a regression test to lock the preview configuration.Why
Opening a 7,646-line Markdown note made the entire app sluggish after the preview loaded, not just the preview pane. The preview path was treating a complete file like streaming AI output, doing extra incomplete-markdown repair work and leaving an expensive rendered tab mounted.
Local benchmark on the same Markdown content:
The reduced CPU/main-thread rendering work matches the manual result: after the fix, opening the large Markdown file no longer makes the rest of the app feel stuck.
How
Only the rendered Markdown file preview path changed:
MarkdownPreviewPanenow passesmode="static"andparseIncompleteMarkdown={false}toStreamdown. AI chat rendering still uses the existing streaming behavior.Testing
pnpm test src/modules/markdown/MarkdownPreviewPane.test.tspnpm check-typespnpm exec biome lint src/modules/markdown/MarkdownPreviewPane.tsx src/modules/markdown/MarkdownPreviewPane.test.tspnpm tauri devNotes reviewer
This is intentionally narrow: only the rendered Markdown file preview changed.
AGENTS.generated.mdwas left untracked and not committed.