perf(web): pull request comments reuse their markdown parse#27808

merged1
main
t3/pr-markdown-cache
opened1d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 20h ago

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.
  • ChatMarkdown shares 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, beforeCode tab, afterTimeline tab, beforeTimeline tab, after
Main-thread task time55.6 / 51.5 s46.2 / 46.4 s58.4 / 57.7 s48.4 / 52.5 s
Script time37.6 / 33.7 s25.9 / 26.4 s40.9 / 39.2 s30.1 / 32.3 s
Blocking time in long frames32.5 / 29.5 s20.8 / 20.6 s33.9 / 34.8 s24.9 / 26.8 s
JS heap peak992 / 973 MB620 / 601 MB1,185 / 1,068 MB852 / 780 MB
micromark CPU1.7 / 1.3 s0.86 / 0.80 s2.2 / 2.0 s1.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

1 failing · 24 successful · 16 skipped
Some checks failed

Failing1

f9469bc
Synced from GitHub

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.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
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.tsx
  • apps/web/src/components/ChatMarkdown.tsx
  • apps/web/src/components/chat/TimelineWorkEntryRow.logic.ts
  • apps/web/src/components/chat/TimelineWorkEntryRow.tsx
  • apps/web/src/components/chat/TimelineWorkGroupRows.tsx
  • apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
  • apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
  • apps/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.tsx
ChatMarkdown 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.tsx
The 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.tsx
The 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 nameStatusExplanationResolution
Description checkWarningThe 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 nameStatusExplanation
Title checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck 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