Skip to content

[react-devtools-cdt-mcp] chrome-devtools-mcp integration#36600

Draft
hoxyq wants to merge 5 commits into
mainfrom
rtcm-1-integration
Draft

[react-devtools-cdt-mcp] chrome-devtools-mcp integration#36600
hoxyq wants to merge 5 commits into
mainfrom
rtcm-1-integration

Conversation

@hoxyq
Copy link
Copy Markdown
Contributor

@hoxyq hoxyq commented Jun 2, 2026

Stacked on #36599, see this commit.

hoxyq added 4 commits June 1, 2026 18:52
Introduces react-devtools-facade, a private, source-only library of building
blocks for querying React runtime state.

This first commit adds installFacade(target): it installs only
__REACT_DEVTOOLS_GLOBAL_HOOK__ (the global React looks for at init) and returns
a Facade handle {hook, fiberRoots, rendererInternals, profilingState}. It
installs no tool globals — integrators (e.g. a chrome-devtools-mcp package)
compose the Facade into tools and decide what to expose.

Its tests rely on the devtools build/dev setup, so the package is excluded from
the general test runners and runs only under the build-devtools jest project —
matching react-devtools-shared and react-devtools-extensions.

Tool building blocks and a createTools(facade) assembler land in follow-ups.
Adds the component-tree building blocks and the createTools assembler.

createTools(facade) reads the facade's tracked state and returns the tools
object (no globals): getTreeSnapshot, getComponentByLabel, findComponents,
getComponentSource, getOwnersStack, getOwnersBranch. Tools return typed plain
JavaScript values (see ReactDevToolsFacadeTree); serialization is left to the
integration package.

getComponentByLabel includes the component's props and, for function
components, its inspected hooks tree (via react-debug-tools).
Adds the profiler building blocks to createTools: startProfiling,
stopProfiling, getTraceOverview, getCommitReport. A profiling session records
per-commit render timing (via the hook's onCommit/onPostCommit, wired in the
scaffold commit) and reports per-component actual/self durations, sorted
descending. Tools return typed plain JavaScript values; serialization is left
to the integration package.
Adds cross-cutting tests that exercise the tools across multiple React roots:
- inject() registers additional renderers and initializes their internals
- getTreeSnapshot and findComponents aggregate across roots with globally
  unique labels
- getComponentByLabel resolves labels from any root
- profiling records one commit per root with correctly attributed components

Completes the react-devtools-facade building-block package.
@meta-cla meta-cla Bot added the CLA Signed label Jun 2, 2026
@react-sizebot
Copy link
Copy Markdown

react-sizebot commented Jun 2, 2026

Comparing: 63e95c2...f50a741

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 614.26 kB 614.26 kB = 108.57 kB 108.57 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB +0.05% 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 680.19 kB 680.19 kB = 119.51 kB 119.51 kB
facebook-www/ReactDOM-prod.classic.js = 700.61 kB 700.61 kB = 123.09 kB 123.09 kB
facebook-www/ReactDOM-prod.modern.js = 690.93 kB 690.93 kB = 121.48 kB 121.48 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-server/cjs/react-server.production.js = 152.31 kB 151.97 kB = 26.89 kB 26.84 kB
oss-stable-semver/react-server/cjs/react-server.production.js = 148.77 kB 148.43 kB = 26.10 kB 26.06 kB
oss-stable/react-server/cjs/react-server.production.js = 148.77 kB 148.43 kB = 26.10 kB 26.06 kB

Generated by 🚫 dangerJS against f50a741

@hoxyq hoxyq force-pushed the rtcm-1-integration branch from 8416b72 to e4c2a54 Compare June 3, 2026 08:41
Adds react-devtools-cdt-mcp, a public package integrating React tools with
chrome-devtools-mcp.

On import it installs the react-devtools-facade hook eagerly (before React); the
tools are built lazily inside the devtoolstooldiscovery handler and registered
via chrome-devtools-mcp's __dtmcp third-party-tool protocol, so the React tools
become discoverable and callable in a chrome-devtools-mcp session. Each tool
maps a JSON-Schema param object onto a facade tool and returns its result
directly.

A Rollup build bundles the facade into a self-contained CommonJS module (React
is left external); a root index.js re-exports the built bundle, matching the
structure of other React packages. The package runs under the build-devtools
jest project and is excluded from the general test runners. A fixtures/ folder
(not published) provides a webpack app that renders assorted React components
against React from source (like react-devtools-shell) for testing the tools with
chrome-devtools-mcp.
@hoxyq hoxyq force-pushed the rtcm-1-integration branch from e4c2a54 to f50a741 Compare June 3, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants