Skip to content

refactor(react-native): collocate Metro, companion, and DevTools - #3706

Merged
thymikee merged 3 commits into
mainfrom
refactor/react-devtools-package
Oct 16, 2026
Merged

thymikee merged 3 commits into
mainfrom
refactor/react-devtools-package

Conversation

@thymikee

@thymikee thymikee commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Collocate Metro preparation and session bindings, companion lifecycle and worker, and React inspection/profiling in private @agent-device/react-native.

One "." export points to src/index.ts. Its explicit, typed interface exposes Metro operations, session lifecycle operations, and runReactDevtools; runtime implementations load lazily. Persistence helpers and internal modules stay private. Public CLI and SDK behavior is preserved.

flowchart LR
  Adapters[CLI / SDK adapters] --> Entry[react-native index.ts]
  Entry --> Metro[Metro preparation and bindings]
  Entry --> Companion[Companion lifecycle and worker]
  Entry --> DevTools[React inspection and profiling]
  DevTools --> Metro
  Metro --> Companion
Loading

82 files touched, mostly moves. Companion protocol/lifecycle code sits beside its worker; package-wide tests exercise the root interface, SDK session tests sit with the SDK, and shared fixtures live in test-kit. Remove the obsolete root overlay re-export; retain its canonical capture-kit implementation. Update ADR 0019 and path-keyed checks.

Validation

Tested commit: 143c6deee769c72ce19b818ece338006ef518c00.

  • 1,194 focused tests and 39 overlay/command tests pass.
  • pnpm check:affected --run: all runnable checks passed; 1,845 files / 15,564 tests passed, one skipped.
  • Bundled CLI text/JSON and installed-package companion checks pass.
  • Depgraph: all external package edges target src/index.ts; no root imports, value cycles, or zone cycles.
  • Independent review at b60d2b2: no actionable findings; follow-up changes only a doc comment.
  • CI integration and coverage pending on this head.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.29 MB 5.29 MB +3.3 kB
Package (unpacked) 5.29 MB 5.29 MB +3.3 kB
Package (download) 1.59 MB 1.59 MB +1.2 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.3 ms 22.6 ms -0.7 ms
CLI --help 63.3 ms 61.3 ms -2.0 ms

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-16 12:00 UTC

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 76 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@thymikee
thymikee force-pushed the refactor/react-devtools-package branch from d112f7b to b60d2b2 Compare October 16, 2026 10:21
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at b60d2b2. All 38 checks pass, and there are no conflicts. I did not build the package, so bundled chunk placement and d.ts inlining for the ./metro subpath rest on the passing packaging checks and your installed-package companion check. I checked test preservation by name and spot reads, not line by line. Not blocking, and fine to take or leave: the doc comment at https://github.com/callstack/agent-device/blob/b60d2b2/packages/contracts/src/companion-tunnel-scope.ts#L6 still names the old client/client-companion-tunnel-contract.ts path, so it could point at the companion folder in @agent-device/react-native; the session-binding helpers in https://github.com/callstack/agent-device/blob/b60d2b2/packages/react-native/src/index.ts#L75 are now async wrappers over a dynamic import, and a static export would keep them synchronous; bindingPath in https://github.com/callstack/agent-device/blob/b60d2b2/packages/test-kit/src/metro-session.fixtures.ts#L8 repeats the production hints path rule, which is acceptable, or the test could assert through readMetroSessionRuntime; and dropping the overlay re-export in https://github.com/callstack/agent-device/blob/b60d2b2/src/commands/react-native/index.ts#L58 is an unrelated cleanup that the PR body already mentions.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 16, 2026
@thymikee
thymikee force-pushed the refactor/react-devtools-package branch from b60d2b2 to 143c6de Compare October 16, 2026 11:47
@thymikee

Copy link
Copy Markdown
Member Author

Addressed the stale ownership comment in 143c6de: it now names @agent-device/react-native and drops the old migration history.

Kept the other choices deliberately:

  • The lazy session wrappers keep the single entry within its startup budget. Using the repository's graph walker against the current source, the entry evaluates 6 modules; a static-export variant evaluates 25, above the 20-module ceiling. Every production caller awaits the facade methods.
  • The independent fixture reader verifies persisted controlBaseUrl and deviceBaseUrls, including cleanup. readMetroSessionRuntime returns only the resolved control runtime, so substituting it would lose that persistence coverage. Raw storage helpers remain private to the package.
  • The overlay change removes a redundant re-export during the requested related-code cleanup. Its canonical capture-kit implementation is unchanged, and the PR body names the deletion.

Executable code is unchanged from b60d2b2. pnpm check:affected --run passes at 143c6de (15,564 tests passed; one skipped).

@thymikee
thymikee merged commit b7c93e3 into main Oct 16, 2026
36 checks passed
@thymikee
thymikee deleted the refactor/react-devtools-package branch October 16, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant