[perf] Replace StatusBadge inline styles with CSS module#118
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[perf] Replace StatusBadge inline styles with CSS module#118github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Replace runtime style object creation in StatusBadge with a static CSS
module. The previous code spread two style objects on every render:
style={{ ...baseStyles, ...variantStyles[variant] }}
This allocates two new plain objects per render cycle.
With a CSS module, variant styles are defined once in static CSS and
applied via class name lookup — zero object allocation per render.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
Pull request created: #118 |
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.
Tier 2 — Render Performance: Eliminate per-render style object allocation
Baseline
StatusBadgespread two plain objects on every render:Two module-level
React.CSSPropertiesobjects (baseStyles,variantStyles) were defined as constants but then spread into a new object on every render, which:StatusBadgeis used widely — every AI activity event, TTFT badge, conversation badge, model badge, and MCP tools badge renders it. In the AIActivityPanel (which shows streaming data), this component can re-render many times per second.Fix
Moved all styles to a CSS module (
StatusBadge.module.css) with one base class (.badge) and four variant classes (.success,.warning,.info,.neutral), then replaced the inline style with static class name lookup: