Reduce ChatMarkdown settings rerenders - #3536
Merged
juliusmarminge merged 1 commit intoJun 23, 2026
Merged
Conversation
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
juliusmarminge
marked this pull request as ready for review
June 23, 2026 18:24
Contributor
ApprovabilityVerdict: Approved Small performance optimization that replaces reactive hook subscriptions with one-time reads for initializing word wrap state. The change is self-contained with no new features or significant behavioral impact. You can customize Macroscope's approvability policy. Learn more. |
juliusmarminge
deleted the
cursor/component-performance-optimization-f123
branch
June 23, 2026 18:47
simonbetton
pushed a commit
to simonbetton/reviewer
that referenced
this pull request
Jun 29, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
ChatMarkdowntable/code-block local wrap state to read the initial word-wrap preference from the client settings snapshot instead of subscribing every markdown table and code block to future client settings updates.Why
React Doctor flagged
ChatMarkdownforrerender-lazy-state-init:useState(useClientSettings(...))subscribed each markdown table/code block and reran settings selection on every render even though the result was only used as initial local state. This caused markdown tables and code blocks to rerender when the global word-wrap setting changed, despite their local wrap state not changing.React Scan evidence captured with React Scan enabled:
before_chat_markdown_react_scan_rerenders.mp4— toggling word wrap flashesMarkdownTableandMarkdownCodeBlockrender boxes.after_chat_markdown_react_scan_no_rerenders.mp4— the same toggles flash only the toggle control; markdown tables/code blocks no longer rerender.UI Changes
No user-facing visual change intended. This is an interaction/render-performance fix validated with before/after React Scan recordings.
Checklist
Note
Reduce rerenders in
ChatMarkdownby replacing hook-based state initializersIn ChatMarkdown.tsx,
MarkdownTableandMarkdownCodeBlockpreviously calleduseClientSettingsas a state initializer, which subscribed each component to settings store updates on every render. They now use a plainreadInitialWordWrapSettinggetter (wrappinggetClientSettings()) as a lazy initializer, so the settings store is only read once at mount time.Macroscope summarized 0b1e390.
Note
Low Risk
Render-performance only; local wrap toggles are unchanged and there is no auth, data, or API surface change.
Overview
Stops every markdown table and code block from subscribing to client settings when they only need the global word-wrap value once at mount.
MarkdownTableandMarkdownCodeBlockno longer calluseClientSettingsinsideuseState. They use a lazy initializerreadInitialWordWrapSetting()backed bygetClientSettings(), so wrap/expand toggles stay local and global word-wrap changes no longer rerender those blocks. Intended behavior is unchanged aside from fewer renders.Reviewed by Cursor Bugbot for commit 0b1e390. Bugbot is set up for automated code reviews on this repo. Configure here.