perf(web): pull request comments reuse their markdown parse#27808
Pull request comments passed a new autolink plugin list on every render. That broke ChatMarkdown's memo and kept their Markdown out of the shared parse cache, so every render of the pull request panel parsed every comment again. On a pull request with thousands of comments, that was most of the panel's render time.
- The autolink plugin list is now built once per repository (
pullRequestAutolinkPlugins) and passed through the panel's context. ChatMarkdownshares one renderer and its parse cache for any extra plugin list that keeps its identity. The prop now says the list must stay stable.- The thought previews pass constant lists instead of inline arrays.
A new test remounts a message that has stable extra plugins and counts parses. It fails on main (2 parses) and passes here (1).
Stress rig
vp run stress --pr pingdotgg/t3code#2829 --pr-tab <tab> (#27714): five supervised Replay threads streaming beside the #2829 panel, 60 s on cups, 2 runs each, alternating order. "Before" is this branch's parent on main.
| Code tab, before | Code tab, after | Timeline tab, before | Timeline tab, after | |
|---|---|---|---|---|
| Main-thread task time | 55.6 / 51.5 s | 46.2 / 46.4 s | 58.4 / 57.7 s | 48.4 / 52.5 s |
| Script time | 37.6 / 33.7 s | 25.9 / 26.4 s | 40.9 / 39.2 s | 30.1 / 32.3 s |
| Blocking time in long frames | 32.5 / 29.5 s | 20.8 / 20.6 s | 33.9 / 34.8 s | 24.9 / 26.8 s |
| JS heap peak | 992 / 973 MB | 620 / 601 MB | 1,185 / 1,068 MB | 852 / 780 MB |
| micromark CPU | 1.7 / 1.3 s | 0.86 / 0.80 s | 2.2 / 2.0 s | 1.0 / 1.0 s |
This stacks with #27795, which virtualizes the timeline; the two touch different files.
Built by Claude Opus 5.5 in Claude Code, running in T3 Code.
🤖 Generated with Claude Code
Checks
Failing1
- CodeRabbitGitHubCancelled
Approvability
Verdict: Approved at f9469bc
Macroscope's review found this PR approvable — Pull-request comments and thought previews reuse stable markdown plugin configurations to avoid repeated parsing. The change preserves rendering safeguards and uses the existing bounded content cache, with no persistent-data or permission changes.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
External image Recent review info
-
External image Run configuration
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3/pr-markdown-cache
- File: .coderabbit.config.ts
- Commit: 70ab7b0
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
e2eb9a34-ba3b-4067-9502-fa9eb3836199
External image Commits
Reviewing files that changed from the base of the PR and between 0ce257b8804a7a6dffa2892a280a59dd20e5a159 and 70ab7b0d67092b35ceee5ed926d8b35bf73f2a9c.
External image Files selected for processing: 8
apps/web/src/components/ChatMarkdown.browser.test.tsxapps/web/src/components/ChatMarkdown.tsxapps/web/src/components/chat/TimelineWorkEntryRow.logic.tsapps/web/src/components/chat/TimelineWorkEntryRow.tsxapps/web/src/components/chat/TimelineWorkGroupRows.tsxapps/web/src/components/pullRequest/PullRequestDetailPanel.tsxapps/web/src/components/pullRequest/PullRequestMarkdown.tsxapps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Walkthrough
ChatMarkdown now reuses combined plugin lists for stable extra plugins. Thought-preview renderers use shared plugin lists, and pull-request Markdown supplies cached autolink plugins through its context.
Changes: Markdown plugin cache reuse
Layer / File(s) Summary Reuse extra plugin lists
apps/web/src/components/ChatMarkdown.tsx,apps/web/src/components/ChatMarkdown.browser.test.tsxChatMarkdown reuses combined shared and extra plugin lists. Extra plugins alone no longer select the uncached renderer path. A test checks that a stable plugin callback runs once across renders. Use stable thought-preview plugins
apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts,apps/web/src/components/chat/TimelineWorkEntryRow.tsx,apps/web/src/components/chat/TimelineWorkGroupRows.tsxThe timeline renderers use exported thought and thinking plugin lists. The reasoning preview selects a list based on whether its tool lifecycle status is inProgress.Pass cached autolink plugins to Markdown
apps/web/src/components/pullRequest/pullRequestMarkdown.logic.ts,apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx,apps/web/src/components/pullRequest/PullRequestMarkdown.tsxThe detail panel provides a cached autolink plugin list in the Markdown context. PullRequestMarkdown passes that list to ChatMarkdown. Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Possibly related issues
- pingdotgg/t3code#9661: This change adds renderer and parse-cache reuse for pull-request Markdown and thought previews, matching the issue’s performance-audit scope.
- pingdotgg/t3code#22985: Stable thought-preview plugin lists support cache reuse in the area of expensive reasoning-preview transformations described in the issue.
Possibly related PRs
- pingdotgg/t3code#27480: It introduced shared renderer instances and rendered-Markdown caching that this change extends to stable extra plugin lists.
- pingdotgg/t3code#21626: It added parsed-Markdown caching and renderer memoization used by these plugin-list changes.
- pingdotgg/t3code#23997: It introduced the change-request autolinker used to create the cached pull-request plugin list.
Suggested reviewers:
maria-rcks,macroscopeapp,t3dotgg
Merge Risk: External image Minimal · up to 70ab7
No merge-blocking issue was identified in the Markdown cache changes.
Pre-merge checks: Passed 3 · Failed 1
Failed Failed checks: 1 warning
Check name Status Explanation Resolution Description check Warning The description follows the repository template. It has a Problem section that states the cause and impact: unstable autolink plugin lists broke ChatMarkdown memoization and parse caching. It has a Ch… Add a Scope and approval section. Link the triaged bug issue or the discussion with maintainer approval, including the approval comment. If no prior issue exists, explain why this focused performance fix qualifies without one. The descripti… Passed Passed checks: 3 passed
Check name Status Explanation Title check Passed The title "perf(web): pull request comments reuse their markdown parse" matches the main change. The PR makes pull request comments reuse the shared Markdown parse cache by building a stable autolink … 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: Title check
Explanation
The title "perf(web): pull request comments reuse their markdown parse" matches the main change. The PR makes pull request comments reuse the shared Markdown parse cache by building a stable autolink plugin list once per repository. The title uses a conventional commit format and is specific to the primary change.
Full details: Description check
Explanation
The description follows the repository template. It has a Problem section that states the cause and impact: unstable autolink plugin lists broke ChatMarkdown memoization and parse caching. It has a Change section that lists the fix. Its Verification section gives a focused test (2 parses on main, 1 on this branch) and stress-rig measurements. The Scope and approval section is missing. It does not link a triaged issue or maintainer approval, and it does not explain why the change qualifies without one. The template also asks for the model and harness used, and the description includes 'Built by Claude Opus 5.5 in Claude Code, running in T3 Code', so that item is covered.
Resolution
Add a Scope and approval section. Link the triaged bug issue or the discussion with maintainer approval, including the approval comment. If no prior issue exists, explain why this focused performance fix qualifies without one. The description should also add a short, explicit Problem heading statement; the current text is present but not under the template headings. Also state what could not be checked, if anything. The stress-rig results are measured in a separate tool run and the description does not give the browser or machine details needed to reproduce them.
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
- perf(web): pull request comments reuse their markdown parsef9469bc