Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(host): use ZephyrNativeCache facade and RNEF export#7

Merged
ryok90 merged 9 commits into
mainfrom
chore/use-zephyr-metro-plugin-rnef-export
May 14, 2026
Merged

refactor(host): use ZephyrNativeCache facade and RNEF export#7
ryok90 merged 9 commits into
mainfrom
chore/use-zephyr-metro-plugin-rnef-export

Conversation

@ryok90
Copy link
Copy Markdown
Collaborator

@ryok90 ryok90 commented May 4, 2026

Summary

  • update the host app to register and control the cache through ZephyrNativeCache instead of raw native-cache internals or app-local hook wiring
  • switch host UI cache actions to ZephyrNativeCache.checkForUpdates, clearCache, and reloadApp, with failure logging for manual actions
  • update host/mini/nested-mini RNEF configs to import zephyrMetroRNEFPlugin directly from zephyr-metro-plugin
  • pin zephyr-native-cache and zephyr-metro-plugin to 0.0.0-canary.60
  • refresh README cache wiring docs for __ZEPHYR__.runtime.nativeCache, the MF compatibility bridge, and legacy __MFE_* aliases

Notes

  • user-facing DevTools behavior remains unchanged
  • the optional vendor/mf-core submodule remains out of scope for this PR
  • useCacheStatus is imported from zephyr-native-cache/react, matching the canary package export map

Validation

  • pnpm install
  • pnpm --filter cache-test-host list zephyr-native-cache zephyr-metro-plugin --depth 0
  • pnpm --filter cache-test-mini list zephyr-metro-plugin --depth 0
  • pnpm --filter cache-test-nested-mini list zephyr-metro-plugin --depth 0
  • git diff --check
  • pnpm --filter cache-test-host exec tsc --noEmit still fails on existing MF/RN ambient type issues (FederationRuntimePlugin, __DEV__, __NATIVE__, and native-cache source globals), but the canary root useCacheStatus export mismatch is fixed

@ryok90 ryok90 self-assigned this May 4, 2026
@ryok90 ryok90 enabled auto-merge May 4, 2026 23:06
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Consolidate cache management by migrating types and handlers to zephyr-native-cache, remove the local useCacheStatus hook, update host entry wiring, unify metro plugin imports to zephyr-metro-plugin, and update README cache-layer wiring documentation.

Changes

Type Migration and Plugin Consolidation

Layer / File(s) Summary
Type imports consolidation
apps/host/src/components/DevToolsPanel.tsx, apps/host/src/components/SourceOverlay.tsx, apps/host/src/App.tsx
Type and runtime imports switched from local useCacheStatus hook to zephyr-native-cache exports (ZephyrNativeCache, useCacheStatus, CacheStatusRemoteEntry, CacheStatusSnapshot).
Function and prop signature updates
apps/host/src/App.tsx, apps/host/src/components/DevToolsPanel.tsx, apps/host/src/components/SourceOverlay.tsx
findEntry, DevToolsPanel.status, displayName, and SourceOverlay.entry updated to use CacheStatusRemoteEntry and CacheStatusSnapshot types.
Cache action handlers
apps/host/src/App.tsx, apps/host/index.js
handleCheckUpdates and handleClearCache now call ZephyrNativeCache.checkForUpdates() / .clearCache(); restart changed to ZephyrNativeCache.reloadApp(); host entry now calls ZephyrNativeCache.register(...) while AppRegistry/bootstrap remain unchanged.
Local hook removal
apps/host/src/hooks/useCacheStatus.ts
Entire file deleted, removing useCacheStatus hook and associated types (RemoteCacheEntry, CacheStatusState, CacheStatusResult).
Metro plugin import consolidation
apps/host/rnef.config.mjs, apps/mini/rnef.config.mjs, apps/nested-mini/rnef.config.mjs
zephyrMetroRNEFPlugin import source changed from zephyr-metro-rnef-plugin to zephyr-metro-plugin.
Cache layer wiring documentation
README.md
README updated to reflect new global path __ZEPHYR__.runtime.nativeCache.refs.cacheLayer and documents Zephyr controls under __ZEPHYR__.runtime.nativeCache.controls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ZephyrCloudIO/zephyr-native-cache-test#8: Both PRs modify cache-layer wiring documentation and consolidate metro plugin imports and dependency usage around zephyr-native-cache and zephyr-metro-plugin.

Poem

🐰 Types hop to fields anew,
Hooks deleted, imports true,
Metro plugins all aligned,
Host registers, docs refined,
Cache controls now in one view.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: refactoring the host to use the ZephyrNativeCache facade and updating RNEF configuration imports to use the new zephyr-metro-plugin export.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/use-zephyr-metro-plugin-rnef-export

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/host/src/components/SourceOverlay.tsx`:
- Line 28: SOURCE_LABELS[entry.status] can be undefined for unknown status
values causing an empty label; update the rendering in SourceOverlay (where
entry?: CacheStatusRemoteEntry is used) to use the same fallback pattern as
DevToolsPanel.tsx by replacing bare SOURCE_LABELS[entry.status] with
SOURCE_LABELS[entry.status] ?? entry.status (and ensure you handle optional
entry before accessing entry.status).

In `@vendor/mf-core`:
- Line 1: The vendor/mf-core submodule pointer references commit
84fef6b237652a855ab6cfa48768ffe343720ff1 which cannot be fetched; verify that
this commit exists in the upstream repo and that the submodule remote URL is
correct in .gitmodules, then update and reinitialize the submodule: run git
submodule sync && git submodule update --init --recursive (or fetch the missing
commit from upstream), and if the commit is invalid replace the pointer by
checking out a valid upstream commit for vendor/mf-core and update the
superproject commit (git add vendor/mf-core; git commit) so the PR references a
reachable commit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 347b4932-d430-4f6e-8a55-ba9d79e75c22

📥 Commits

Reviewing files that changed from the base of the PR and between df049f8 and 027d10d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • README.md
  • apps/host/package.json
  • apps/host/rnef.config.mjs
  • apps/host/src/App.tsx
  • apps/host/src/components/DevToolsPanel.tsx
  • apps/host/src/components/SourceOverlay.tsx
  • apps/host/src/hooks/useCacheStatus.ts
  • apps/mini/package.json
  • apps/mini/rnef.config.mjs
  • apps/nested-mini/package.json
  • apps/nested-mini/rnef.config.mjs
  • packages/zephyr-metro-rnef-plugin/index.d.ts
  • packages/zephyr-metro-rnef-plugin/index.mjs
  • packages/zephyr-metro-rnef-plugin/package.json
  • vendor/mf-core
💤 Files with no reviewable changes (4)
  • packages/zephyr-metro-rnef-plugin/index.mjs
  • apps/host/src/hooks/useCacheStatus.ts
  • packages/zephyr-metro-rnef-plugin/index.d.ts
  • packages/zephyr-metro-rnef-plugin/package.json

Comment thread apps/host/src/components/SourceOverlay.tsx
Comment thread vendor/mf-core Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/host/src/App.tsx (1)

93-97: ⚡ Quick win

Avoid swallowing action failures for update/cache controls.

Line 93 and Line 97 currently discard errors silently; for user-triggered actions this makes failures opaque and harder to debug.

Suggested patch
+const reportCacheActionError = (action: string, error: unknown) => {
+  console.warn(`[cache] ${action} failed`, error);
+};

 const handleCheckUpdates = useCallback(() => {
-  checkForUpdates().catch(() => {});
+  checkForUpdates().catch(error => reportCacheActionError('checkForUpdates', error));
 }, []);

 const handleClearCache = useCallback(() => {
-  clearCache().catch(() => {});
+  clearCache().catch(error => reportCacheActionError('clearCache', error));
 }, []);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/host/src/App.tsx` around lines 93 - 97, The current calls to
checkForUpdates() and clearCache() swallow errors in their .catch(() => {})
handlers; update both call sites (the useEffect that invokes checkForUpdates and
the handleClearCache callback that calls clearCache) to handle failures instead
of silencing them: catch the error, log it (e.g., console.error or your app
logger), and surface user-facing feedback (toast/notification or alert) so users
and devs see the failure; keep the async calls but replace empty .catch handlers
with a handler that accepts the error and performs logging plus a UI
notification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/host/src/App.tsx`:
- Around line 93-97: The current calls to checkForUpdates() and clearCache()
swallow errors in their .catch(() => {}) handlers; update both call sites (the
useEffect that invokes checkForUpdates and the handleClearCache callback that
calls clearCache) to handle failures instead of silencing them: catch the error,
log it (e.g., console.error or your app logger), and surface user-facing
feedback (toast/notification or alert) so users and devs see the failure; keep
the async calls but replace empty .catch handlers with a handler that accepts
the error and performs logging plus a UI notification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e015143-825a-4dc4-a3e6-2c600735ff98

📥 Commits

Reviewing files that changed from the base of the PR and between 027d10d and 3bfeae7.

📒 Files selected for processing (1)
  • apps/host/src/App.tsx

@ryok90 ryok90 force-pushed the chore/use-zephyr-metro-plugin-rnef-export branch from 033d9e0 to a0c9ad2 Compare May 8, 2026 14:00
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/host/src/App.tsx`:
- Around line 92-98: The handlers handleCheckUpdates and handleClearCache
currently swallow errors with .catch(() => {}); update both to log the caught
error instead of ignoring it by calling your logger (or console.error) inside
the catch and include a descriptive message and the error object (e.g., "Failed
to check for updates" with err) so failures are visible for users/operators;
apply this change to the promises returned by checkForUpdates and clearCache
within the useCallback wrappers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a91e1e46-22d4-495e-95e9-14b2cdec5fe0

📥 Commits

Reviewing files that changed from the base of the PR and between 033d9e0 and a0c9ad2.

📒 Files selected for processing (8)
  • README.md
  • apps/host/rnef.config.mjs
  • apps/host/src/App.tsx
  • apps/host/src/components/DevToolsPanel.tsx
  • apps/host/src/components/SourceOverlay.tsx
  • apps/host/src/hooks/useCacheStatus.ts
  • apps/mini/rnef.config.mjs
  • apps/nested-mini/rnef.config.mjs
💤 Files with no reviewable changes (1)
  • apps/host/src/hooks/useCacheStatus.ts
✅ Files skipped from review due to trivial changes (5)
  • apps/nested-mini/rnef.config.mjs
  • apps/host/rnef.config.mjs
  • apps/mini/rnef.config.mjs
  • README.md
  • apps/host/src/components/SourceOverlay.tsx

Comment thread apps/host/src/App.tsx
@ryok90 ryok90 changed the title chore: switch RNEF configs to zephyr-metro-plugin export refactor(host): use ZephyrNativeCache facade and RNEF export May 12, 2026
ryok90 added 3 commits May 12, 2026 18:25
zephyr-native-cache no longer exposes __MFE_BUNDLE_HASHES__; bundle
hashes now live on globalThis.__ZEPHYR__.runtime.nativeCache.refs.bundleHashes.
@ryok90 ryok90 merged commit bb44b81 into main May 14, 2026
4 checks passed
@ryok90 ryok90 deleted the chore/use-zephyr-metro-plugin-rnef-export branch May 14, 2026 14:29
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.

2 participants