refactor(web): chat markdown code blocks live in their own module#22690
ChatMarkdown.tsx was a 3,560-line file that held every markdown renderer. This stack splits it into focused modules so each piece is readable on its own.
The code block, its frame and the Shiki renderers move to chat/MarkdownCodeBlock.tsx, along with the highlight cache. The fence parsing helpers move to MarkdownCodeBlock.logic.ts. The shared action-failure logger moves to chat/markdownActionFailure.ts. ComposerCodeBlockNodeView now imports MarkdownCodeBlockFrame from the new module.
This is a pure move. Each renderer was already its own component, so no render boundary changes. Behavior is unchanged.
| Before | After | |
|---|---|---|
ChatMarkdown.tsx lines | 3560 | 3069 |
| New files | chat/MarkdownCodeBlock.tsx (390), MarkdownCodeBlock.logic.ts (119), markdownActionFailure.ts (15) | |
| Renders | unchanged: no component, subscription or context boundary moved | unchanged |
Renders were not measured for this layer. It changes no render boundaries: the components, their props, and the two contexts stay exactly as they were.
Tests run:
vp test run --project browser src/components/ChatMarkdown.browser.test.tsx src/components/ChatMarkdown.permissions.browser.test.tsx(11 passed)vp test run --project unit src/reactCompilerCoverage.test.tsfor every touched file (0 bailouts)tsc --noEmitfor apps/web, andvp linton changed files
🤖 Generated with Claude Code
Checks
- SuccessfulCodeRabbitGitHub
Review completed
- Skipped
- Skipped
- Skipped
- SuccessfulRemove preview downloadGitHub
- SuccessfulCheckGitHub
- SkippedRustGitHub
- SkippedRelease SmokeGitHub
- Skipped
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulTest WebGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulLabel PR 22690GitHub
- Skipped
- Skipped
- SkippedDeploy web previewGitHub
- SkippedEAS PreviewGitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulLintGitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulNative fingerprint diffGitHub
- SuccessfulChangesGitHub
- Skipped
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- Skipped
Approvability
Verdict: Approved at 1791171
Macroscope's review found this PR approvable — This PR mechanically extracts existing chat markdown code-block components and helpers into focused modules while preserving their implementations, props, state behavior, and render paths. The only other runtime change is an equivalent import-path update for the composer frame, with no product-default or static-analysis configuration changes.
No code changes detected at eadb13d. Prior analysis still applies.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
a6c9586b-99ae-40f0-9a4f-d625988561fc
📥 Commits
Reviewing files that changed from the base of the PR and between 6a6c84f9906cbdfa7f533fecfc39ce18c2f4c273 and 17911714648b1debf9d6d6fc4fea6c95bf86f83d.
📒 Files selected for processing: 5
apps/web/src/components/ChatMarkdown.tsxapps/web/src/components/chat/ComposerCodeBlockNodeView.tsxapps/web/src/components/chat/MarkdownCodeBlock.logic.tsapps/web/src/components/chat/MarkdownCodeBlock.tsxapps/web/src/components/chat/markdownActionFailure.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
📝 Walkthrough
Code-block parsing, rendering, highlighting, and action-failure reporting moved from
ChatMarkdown.tsxinto dedicated chat modules. The shared renderer provides copy, wrapping, shell execution, diagram controls, streaming-aware highlighting, fallback rendering, and bounded caching.ComposerCodeBlockNodeViewnow imports the shared frame from its local module.Changes: Markdown code-block rendering
Layer / File(s) Summary Code-block parsing and cache utilities
apps/web/src/components/chat/MarkdownCodeBlock.logic.tsUtilities extract fence language and titles, read code metadata, detect closed fences, flatten and validate code nodes, and create highlight cache keys and size estimates. Code-block rendering and highlighting
apps/web/src/components/chat/MarkdownCodeBlock.tsx,apps/web/src/components/chat/markdownActionFailure.tsThe shared renderer provides framing, titles, copy and wrap controls, validated shell execution, diagram controls, streaming-aware highlighting, bounded caching, and fallback rendering. A shared function logs action failures with operation context and causes. Markdown and composer integration
apps/web/src/components/ChatMarkdown.tsx,apps/web/src/components/chat/ComposerCodeBlockNodeView.tsxChatMarkdown.tsximports the shared modules and removes its local code-block and highlighting implementations.ComposerCodeBlockNodeViewimports the shared frame from its local module.Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Suggested reviewers:
maria-rcks
Merge Risk: ⚪ Minimal · up to 17911
This is a behavior-preserving refactor that splits code-block rendering out of the large chat markdown file. No concrete merge-blocking risk was identified.
Pre-merge checks: Passed 3 · Failed 1
Failed Failed checks: 1 warning
Check name Status Explanation Resolution Description check Warning The description explains the problem, change, behavior-preservation goal, and verification results. It does not provide the required Scope and approval information, and it does not clearly identify bo… Add the triaged issue or maintainer approval with its discussion or approval comment. If no prior issue or discussion exists, explain why this focused refactor qualifies for an exemption. End with the model and harness used to perform the w… Passed Passed checks: 3 passed
Check name Status Explanation Title check Passed The title clearly and concisely describes the primary change: moving chat markdown code blocks into a dedicated module. 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.
Full details: Description check
Explanation
The description explains the problem, change, behavior-preservation goal, and verification results. It does not provide the required Scope and approval information, and it does not clearly identify both the model and harness used.
Resolution
Add the triaged issue or maintainer approval with its discussion or approval comment. If no prior issue or discussion exists, explain why this focused refactor qualifies for an exemption. End with the model and harness used to perform the work.
✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Added 1 commit
- refactor(web): chat markdown code blocks live in their own moduleeadb13d