Skip to content

refactor(react): contain snapshot runtime paths#2498

Merged
Yradex merged 6 commits intolynx-family:mainfrom
Yradex:wt/snapshot-containment-publish
Apr 22, 2026
Merged

refactor(react): contain snapshot runtime paths#2498
Yradex merged 6 commits intolynx-family:mainfrom
Yradex:wt/snapshot-containment-publish

Conversation

@Yradex
Copy link
Copy Markdown
Collaborator

@Yradex Yradex commented Apr 21, 2026

@coderabbitai summary

Overview

  • Snapshot runtime internals were still spread across public-looking runtime source and test roots, which made it unclear which code belongs to the legacy Snapshot backend and which paths ET should be allowed to depend on.
  • This change contains those Snapshot-owned runtime modules and tests under snapshot-specific roots while keeping the existing package entries and runtime root modules as the stable integration surface.

Key Points

  • Moves the legacy Snapshot implementation directories under packages/react/runtime/src/snapshot/ instead of introducing a broad facade layer.
  • Moves Snapshot-specific runtime tests, including CSS and shared test utilities, under packages/react/runtime/__test__/snapshot/ and keeps non-Snapshot runtime tests outside that subtree.
  • Adds a guardrail suite that fails if old Snapshot implementation roots reappear, if ET code imports Snapshot-private paths, or if package metadata exposes stale internal locations.
  • Leaves the existing dark-mode transform self-import unchanged because __SetClassesDarkMode is not exported from the runtime root today; the guardrail documents that as a narrow known exception.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Important

Review skipped

Too many files!

This PR contains 196 files, which is 46 over the limit of 150.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0bd7405-94fa-4a85-a03f-9d8a59434e85

📥 Commits

Reviewing files that changed from the base of the PR and between 02be891 and 90e8687.

📒 Files selected for processing (196)
  • .changeset/snapshot-testing-paths.md
  • eslint.config.js
  • packages/react/package.json
  • packages/react/runtime/__test__/guardrails/snapshot-containment.test.ts
  • packages/react/runtime/__test__/snapshot/alog/elementPAPICall.test.js
  • packages/react/runtime/__test__/snapshot/basic.test.jsx
  • packages/react/runtime/__test__/snapshot/children.test.jsx
  • packages/react/runtime/__test__/snapshot/clone.test.jsx
  • packages/react/runtime/__test__/snapshot/compat.test.jsx
  • packages/react/runtime/__test__/snapshot/compat/export.test.jsx
  • packages/react/runtime/__test__/snapshot/compat/hooks.test.jsx
  • packages/react/runtime/__test__/snapshot/compat/initData.test.jsx
  • packages/react/runtime/__test__/snapshot/createSuspender.jsx
  • packages/react/runtime/__test__/snapshot/css/compat.test.jsx
  • packages/react/runtime/__test__/snapshot/css/remove-scoped-lazy-bundle.test.jsx
  • packages/react/runtime/__test__/snapshot/css/remove-scoped-main-bundle.test.jsx
  • packages/react/runtime/__test__/snapshot/css/scoped-lazy-bundle.test.jsx
  • packages/react/runtime/__test__/snapshot/css/scoped-main-bundle.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/backgroundSnapshot-profile.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/children-with-same-key.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/describeInvalidValue.test.ts
  • packages/react/runtime/__test__/snapshot/debug/formatPatch.test.ts
  • packages/react/runtime/__test__/snapshot/debug/hooks-in-render.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/hooks-invalid-args.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/jsx-twice.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/missing-suspense.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/object-as-child.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/printSnapshot.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/profile-module.test.ts
  • packages/react/runtime/__test__/snapshot/debug/profile.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/react-hooks-profile.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/set-state-in-ctor.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/too-many-rerenders.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/undefined-component.test.jsx
  • packages/react/runtime/__test__/snapshot/debug/vnodeSource.test.ts
  • packages/react/runtime/__test__/snapshot/delayed-lifecycle-events.test.jsx
  • packages/react/runtime/__test__/snapshot/dynamicPartType.test.jsx
  • packages/react/runtime/__test__/snapshot/element.test.jsx
  • packages/react/runtime/__test__/snapshot/event.test.jsx
  • packages/react/runtime/__test__/snapshot/gesture.test.jsx
  • packages/react/runtime/__test__/snapshot/gesture/processGesture.test.ts
  • packages/react/runtime/__test__/snapshot/hooks/mainThread.test.tsx
  • packages/react/runtime/__test__/snapshot/hooks/useLynxGlobalEventListener.test.jsx
  • packages/react/runtime/__test__/snapshot/hydrate.test.jsx
  • packages/react/runtime/__test__/snapshot/lazy.test.js
  • packages/react/runtime/__test__/snapshot/lifecycle.test.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/destroy.test.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/isRendering.test.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/reload.test.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/reloadBG.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/reloadMT.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/updateData.test.jsx
  • packages/react/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx
  • packages/react/runtime/__test__/snapshot/list.test.jsx
  • packages/react/runtime/__test__/snapshot/lynx/injectLepusMethods.test.jsx
  • packages/react/runtime/__test__/snapshot/lynx/lazy-bundle.test.js
  • packages/react/runtime/__test__/snapshot/lynx/processEvalResult.test.js
  • packages/react/runtime/__test__/snapshot/lynx/suspense.test.jsx
  • packages/react/runtime/__test__/snapshot/lynx/timing.test.jsx
  • packages/react/runtime/__test__/snapshot/lynxQueueMicrotask.test.jsx
  • packages/react/runtime/__test__/snapshot/page.test.jsx
  • packages/react/runtime/__test__/snapshot/preact.test.jsx
  • packages/react/runtime/__test__/snapshot/ref.test.jsx
  • packages/react/runtime/__test__/snapshot/render.test.jsx
  • packages/react/runtime/__test__/snapshot/renderToOpcodes.test.jsx
  • packages/react/runtime/__test__/snapshot/snapshotPatch.test.jsx
  • packages/react/runtime/__test__/snapshot/spread.test.jsx
  • packages/react/runtime/__test__/snapshot/ssr.test.jsx
  • packages/react/runtime/__test__/snapshot/utils/debug.js
  • packages/react/runtime/__test__/snapshot/utils/envManager.ts
  • packages/react/runtime/__test__/snapshot/utils/globals.js
  • packages/react/runtime/__test__/snapshot/utils/inject.ts
  • packages/react/runtime/__test__/snapshot/utils/jsModule.ts
  • packages/react/runtime/__test__/snapshot/utils/nativeMethod.ts
  • packages/react/runtime/__test__/snapshot/utils/runtimeProxy.test.js
  • packages/react/runtime/__test__/snapshot/utils/runtimeProxy.ts
  • packages/react/runtime/__test__/snapshot/utils/setup.js
  • packages/react/runtime/__test__/snapshot/worklet/execIdMap.test.js
  • packages/react/runtime/__test__/snapshot/worklet/onPost.test.js
  • packages/react/runtime/__test__/snapshot/worklet/runOnBackground.test.js
  • packages/react/runtime/__test__/snapshot/worklet/runOnMainThread.test.jsx
  • packages/react/runtime/__test__/snapshot/worklet/transform.test.js
  • packages/react/runtime/__test__/snapshot/worklet/workletRef.test.jsx
  • packages/react/runtime/__test__/snapshot/workletEvent.test.jsx
  • packages/react/runtime/__test__/snapshot/workletRef.test.jsx
  • packages/react/runtime/__test__/snapshot/workletRefBG.jsx
  • packages/react/runtime/__test__/snapshot/workletRefMT.jsx
  • packages/react/runtime/src/document.ts
  • packages/react/runtime/src/index.ts
  • packages/react/runtime/src/internal.ts
  • packages/react/runtime/src/lynx-api.ts
  • packages/react/runtime/src/lynx.ts
  • packages/react/runtime/src/root.ts
  • packages/react/runtime/src/snapshot/alog/elementPAPICall.ts
  • packages/react/runtime/src/snapshot/alog/index.ts
  • packages/react/runtime/src/snapshot/alog/render.ts
  • packages/react/runtime/src/snapshot/compat/componentIs.ts
  • packages/react/runtime/src/snapshot/compat/initData.ts
  • packages/react/runtime/src/snapshot/compat/lynxComponent.ts
  • packages/react/runtime/src/snapshot/debug/component-stack.ts
  • packages/react/runtime/src/snapshot/debug/debug.ts
  • packages/react/runtime/src/snapshot/debug/describeInvalidValue.ts
  • packages/react/runtime/src/snapshot/debug/formatPatch.ts
  • packages/react/runtime/src/snapshot/debug/printSnapshot.ts
  • packages/react/runtime/src/snapshot/debug/profile.ts
  • packages/react/runtime/src/snapshot/debug/profileHooks.ts
  • packages/react/runtime/src/snapshot/debug/vnodeSource.ts
  • packages/react/runtime/src/snapshot/gesture/processGesture.ts
  • packages/react/runtime/src/snapshot/gesture/processGestureBagkround.ts
  • packages/react/runtime/src/snapshot/gesture/types.ts
  • packages/react/runtime/src/snapshot/hooks/mainThread.ts
  • packages/react/runtime/src/snapshot/hooks/react.ts
  • packages/react/runtime/src/snapshot/hooks/useLynxGlobalEventListener.ts
  • packages/react/runtime/src/snapshot/index.ts
  • packages/react/runtime/src/snapshot/legacy-react-runtime/index.ts
  • packages/react/runtime/src/snapshot/lifecycle/constant.ts
  • packages/react/runtime/src/snapshot/lifecycle/destroy.ts
  • packages/react/runtime/src/snapshot/lifecycle/event/delayEvents.ts
  • packages/react/runtime/src/snapshot/lifecycle/event/delayLifecycleEvents.ts
  • packages/react/runtime/src/snapshot/lifecycle/event/jsReady.ts
  • packages/react/runtime/src/snapshot/lifecycle/isRendering.ts
  • packages/react/runtime/src/snapshot/lifecycle/pass.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/commit.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/error.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/globalState.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/isMainThreadHydrating.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/snapshotPatch.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts
  • packages/react/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts
  • packages/react/runtime/src/snapshot/lifecycle/ref/delay.ts
  • packages/react/runtime/src/snapshot/lifecycle/reload.ts
  • packages/react/runtime/src/snapshot/lifecycle/render.ts
  • packages/react/runtime/src/snapshot/list/list.ts
  • packages/react/runtime/src/snapshot/list/listUpdateInfo.ts
  • packages/react/runtime/src/snapshot/list/pendingListUpdates.ts
  • packages/react/runtime/src/snapshot/lynx/calledByNative.ts
  • packages/react/runtime/src/snapshot/lynx/component.ts
  • packages/react/runtime/src/snapshot/lynx/dynamic-js.ts
  • packages/react/runtime/src/snapshot/lynx/env.ts
  • packages/react/runtime/src/snapshot/lynx/injectLepusMethods.ts
  • packages/react/runtime/src/snapshot/lynx/lazy-bundle.ts
  • packages/react/runtime/src/snapshot/lynx/performance.ts
  • packages/react/runtime/src/snapshot/lynx/runWithForce.ts
  • packages/react/runtime/src/snapshot/lynx/suspense.ts
  • packages/react/runtime/src/snapshot/lynx/tt.ts
  • packages/react/runtime/src/snapshot/renderToOpcodes/constants.ts
  • packages/react/runtime/src/snapshot/renderToOpcodes/hydrate.ts
  • packages/react/runtime/src/snapshot/renderToOpcodes/index.ts
  • packages/react/runtime/src/snapshot/renderToOpcodes/opcodes.ts
  • packages/react/runtime/src/snapshot/snapshot/backgroundSnapshot.ts
  • packages/react/runtime/src/snapshot/snapshot/constants.ts
  • packages/react/runtime/src/snapshot/snapshot/definition.ts
  • packages/react/runtime/src/snapshot/snapshot/dynamicPartType.ts
  • packages/react/runtime/src/snapshot/snapshot/event.ts
  • packages/react/runtime/src/snapshot/snapshot/gesture.ts
  • packages/react/runtime/src/snapshot/snapshot/index.ts
  • packages/react/runtime/src/snapshot/snapshot/list.ts
  • packages/react/runtime/src/snapshot/snapshot/platformInfo.ts
  • packages/react/runtime/src/snapshot/snapshot/ref.ts
  • packages/react/runtime/src/snapshot/snapshot/snapshot.ts
  • packages/react/runtime/src/snapshot/snapshot/snapshotInstanceHydrationMap.ts
  • packages/react/runtime/src/snapshot/snapshot/spread.ts
  • packages/react/runtime/src/snapshot/snapshot/types.ts
  • packages/react/runtime/src/snapshot/snapshot/utils.ts
  • packages/react/runtime/src/snapshot/snapshot/workletEvent.ts
  • packages/react/runtime/src/snapshot/snapshot/workletRef.ts
  • packages/react/runtime/src/snapshot/worklet/call/delayedRunOnMainThreadData.ts
  • packages/react/runtime/src/snapshot/worklet/call/execMap.ts
  • packages/react/runtime/src/snapshot/worklet/call/functionCall.ts
  • packages/react/runtime/src/snapshot/worklet/call/runOnBackground.ts
  • packages/react/runtime/src/snapshot/worklet/call/runOnMainThread.ts
  • packages/react/runtime/src/snapshot/worklet/call/transformToWorklet.ts
  • packages/react/runtime/src/snapshot/worklet/ctx.ts
  • packages/react/runtime/src/snapshot/worklet/destroy.ts
  • packages/react/runtime/src/snapshot/worklet/functionality.ts
  • packages/react/runtime/src/snapshot/worklet/hmr.ts
  • packages/react/runtime/src/snapshot/worklet/indexMap.ts
  • packages/react/runtime/src/snapshot/worklet/ref/updateInitValue.ts
  • packages/react/runtime/src/snapshot/worklet/ref/workletRef.ts
  • packages/react/runtime/src/snapshot/worklet/ref/workletRefPool.ts
  • packages/react/runtime/src/utils.ts
  • packages/react/runtime/types/types.d.ts
  • packages/react/runtime/vitest.config.ts
  • packages/react/testing-library/src/__tests__/act.test.jsx
  • packages/react/testing-library/src/__tests__/lazy-bundle/index.test.jsx
  • packages/react/testing-library/src/__tests__/list.test.jsx
  • packages/react/testing-library/src/__tests__/lynx.test.jsx
  • packages/react/testing-library/src/__tests__/renderComponent.test.jsx
  • packages/react/testing-library/src/__tests__/setState-jsx.test.jsx
  • packages/react/testing-library/src/__tests__/spread.test.jsx
  • packages/react/testing-library/src/__tests__/text.test.jsx
  • packages/react/testing-library/src/pure.jsx
  • packages/react/testing-library/src/setupFiles/common/runtime-setup.js
  • packages/react/types/react.docs.d.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/rspeedy/plugin-react-alias/test/index.test.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: 90e8687

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@lynx-js/react Patch
@lynx-js/react-umd Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 21, 2026

Merging this PR will degrade performance by 18.84%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 79 untouched benchmarks
⏩ 26 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
003-hello-list-destroyBackground 2.8 ms 3.4 ms -18.84%
002-hello-reactLynx-destroyBackground 894.7 µs 669.1 µs +33.7%

Comparing Yradex:wt/snapshot-containment-publish (90e8687) with main (02be891)

Open in CodSpeed

Footnotes

  1. 26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 21, 2026

React Example

#7474 Bundle Size — 224.41KiB (0%).

90e8687(current) vs 02be891 main#7453(baseline)

Bundle metrics  Change 1 change
                 Current
#7474
     Baseline
#7453
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 179 179
No change  Duplicate Modules 69 69
Change  Duplicate Code 44.51%(+0.02%) 44.5%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7474
     Baseline
#7453
No change  IMG 145.76KiB 145.76KiB
No change  Other 78.65KiB 78.65KiB

Bundle analysis reportBranch Yradex:wt/snapshot-containment-p...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 21, 2026

React External

#592 Bundle Size — 583.28KiB (~+0.01%).

90e8687(current) vs 02be891 main#571(baseline)

Bundle metrics  Change 1 change
                 Current
#592
     Baseline
#571
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
Change  Cache Invalidation 30.2% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#592
     Baseline
#571
Regression  Other 583.28KiB (~+0.01%) 583.27KiB

Bundle analysis reportBranch Yradex:wt/snapshot-containment-p...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 21, 2026

Web Explorer

#9048 Bundle Size — 898.15KiB (0%).

90e8687(current) vs 02be891 main#9028(baseline)

Bundle metrics  Change 2 changes
                 Current
#9048
     Baseline
#9028
No change  Initial JS 44.47KiB 44.47KiB
No change  Initial CSS 2.22KiB 2.22KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 9 9
No change  Assets 11 11
Change  Modules 231(+0.87%) 229
No change  Duplicate Modules 11 11
Change  Duplicate Code 27.21%(-0.04%) 27.22%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#9048
     Baseline
#9028
No change  JS 494.3KiB 494.3KiB
No change  Other 401.63KiB 401.63KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch Yradex:wt/snapshot-containment-p...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Apr 21, 2026

React MTF Example

#607 Bundle Size — 195.57KiB (0%).

90e8687(current) vs 02be891 main#586(baseline)

Bundle metrics  Change 1 change
                 Current
#607
     Baseline
#586
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 173 173
No change  Duplicate Modules 66 66
Change  Duplicate Code 44%(+0.02%) 43.99%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#607
     Baseline
#586
No change  IMG 111.23KiB 111.23KiB
No change  Other 84.34KiB 84.34KiB

Bundle analysis reportBranch Yradex:wt/snapshot-containment-p...Project dashboard


Generated by RelativeCIDocumentationReport issue

@Yradex Yradex marked this pull request as ready for review April 21, 2026 14:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1963d17a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/react/runtime/__test__/guardrails/snapshot-containment.test.ts Outdated
Comment thread packages/react/runtime/__test__/guardrails/snapshot-containment.test.ts Outdated
@Yradex Yradex enabled auto-merge (squash) April 21, 2026 14:39
@Yradex Yradex merged commit e9fe5c5 into lynx-family:main Apr 22, 2026
49 of 50 checks passed
@Yradex Yradex deleted the wt/snapshot-containment-publish branch April 22, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants