Repository navigation
refactor(mcp-ui): co-locate component CSS so views ship only what they import - #576
Merged
Merged
Conversation
Rodriguespn
reviewed
Nov 18, 2026
Rodriguespn
reviewed
Nov 18, 2026
Rodriguespn
approved these changes
Nov 18, 2026
Contributor
There was a problem hiding this comment.
Looks good, thanks! Left a small suggestion on the lint and a README nit, neither blocking. The failing Management API types check isn't from this PR: the regenerated types are already in main (chore: regenerate management API types), so rebasing the stack on main should turn it green.
charislam
force-pushed
the
feat/create-project-tools
branch
from
November 18, 2026 18:28
93964b5 to
eabaf9f
Compare
charislam
force-pushed
the
refactor/mcp-ui-colocated-css
branch
from
November 18, 2026 18:28
4a5ae6d to
e9bb151
Compare
charislam
force-pushed
the
refactor/mcp-ui-colocated-css
branch
2 times, most recently
from
November 18, 2026 19:21
5988843 to
9028401
Compare
…y import Every view imported one shared stylesheet, so each view's single-file HTML shipped CSS for every component whether it used it or not. That does not scale as views are added. - Split src/shared/styles.css into base.css (layer order statement, tokens, native element styles, .sr-only) and one CSS file per component, each owning its class in the components layer and imported by the TSX component that renders it. Rules moved verbatim; authoring model unchanged. - The layer order statement lives only in base.css, which must be the first import in every view's main.tsx. - Rename component custom properties from --sb-local-* to --sb-component-<component>-*. A component reading another component's properties must provide a fallback. --sb-view-<view>-* is reserved for a view's view.css. - scripts/check-css.mjs (pnpm lint:css) checks every CSS file under src/ for layer rules, layer placement per file kind, single-file ownership of component classes, the base.css import rule, and the property namespace and fallback rules. - Update README.md and the mcp-ui-css skill to describe the new layout.
- check-css.mjs now checks classes in nested components rules too: a nested :where(.icon) inside .ready-actions styled .icon from a second file, and with every components rule at zero specificity the winner followed import order. - Move the icon rule to the native layer of base.css (svg:where(.icon)) so a component that styles an icon inside it always wins, and drop icon.css. - Icons take a slot prop (data-slot); the connection details disclosure styles its indicator as [data-slot="disclosure-indicator"]. - README and skill: a view ships the CSS of the components it imports, not only those it renders.
charislam
force-pushed
the
refactor/mcp-ui-colocated-css
branch
from
November 19, 2026 21:10
9028401 to
0f63cdd
Compare
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.
Stacked on #573
What kind of change does this PR introduce?
Refactor (no intended change to rendered output; see Verification).
What is the current behavior?
Every view imports one shared stylesheet (
src/shared/styles.css), so each view's single-file HTML ships CSS for every component whether or not it renders that component. That does not scale as views are added.Related issues: none linked.
What is the new behavior?
src/shared/styles.cssis split intosrc/shared/base.css(the global core: layer order statement, tokens, native element styles,.sr-only) plus one CSS file per component. Each component file owns one class in thecomponentslayer and is imported by the TSX component that renders it. A view now shipsbase.cssplus the CSS of the components it imports. Rules were moved verbatim; the authoring model (plain CSS, cascade layers, specificity caps,:where(),data-slot/data-state/data-tone) is unchanged.base.css, which must be the first import in every view'smain.tsx.--sb-local-*to--sb-component-<component>-*, namespaced by the component's file (for example--sb-component-progress-card-radius). A component reads its own properties without a fallback. A component reading another component's properties must provide a fallback, because its file can ship without the other's.ready-actions.cssdoes this for theprogress-cardproperties it reads.--sb-view-<view>-*is reserved for a view'sview.css.scripts/check-css.mjs(pnpm lint:css) now checks every CSS file undersrc/and enforces: one block per layer per file; which layers each kind of file may contain; a component class styled in only one file; the layer statement only inbase.css, andbase.cssfirst in eachmain.tsx; and the custom property namespace and fallback rules.README.mdand.agents/skills/mcp-ui-css/SKILL.mddescribe the new layout and rules.How to Review
Shared core and tokens
packages/mcp-ui/src/shared/base.cssComponent ownership and imports
packages/mcp-ui/src/shared/badge.css,button.css,copy-field.css,icon.css,message.css,progress-card.css,ready-actions.css,summary.csscomponentslayer; confirm the matching TSX file inpackages/mcp-ui/src/shared/imports it.Cross-component property fallbacks
packages/mcp-ui/src/shared/ready-actions.cssprogress-cardcustom properties, which carry fallbacks.View entrypoints
packages/mcp-ui/src/views/create-project/main.tsxpackages/mcp-ui/src/views/create-branch/main.tsxbase.cssis the first import in each.Rules enforced by the lint
packages/mcp-ui/scripts/check-css.mjspnpm lint:cssnow runs over every CSS file undersrc/.Verification
pnpm buildinpackages/mcp-uipasses (typecheck,lint:csson 9 files, both views).pnpm exec biome check packages/mcp-uifrom the repository root passes.componentslayer.Badgeshipped about 4.9 KB of CSS and none of the other components' rules.Additional context
The two existing views use the same components, so this change does not reduce their output yet; the benefit applies to views that import a subset.