refactor(host): use ZephyrNativeCache facade and RNEF export#7
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughConsolidate cache management by migrating types and handlers to ChangesType Migration and Plugin Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
README.mdapps/host/package.jsonapps/host/rnef.config.mjsapps/host/src/App.tsxapps/host/src/components/DevToolsPanel.tsxapps/host/src/components/SourceOverlay.tsxapps/host/src/hooks/useCacheStatus.tsapps/mini/package.jsonapps/mini/rnef.config.mjsapps/nested-mini/package.jsonapps/nested-mini/rnef.config.mjspackages/zephyr-metro-rnef-plugin/index.d.tspackages/zephyr-metro-rnef-plugin/index.mjspackages/zephyr-metro-rnef-plugin/package.jsonvendor/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
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/host/src/App.tsx (1)
93-97: ⚡ Quick winAvoid 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
📒 Files selected for processing (1)
apps/host/src/App.tsx
033d9e0 to
a0c9ad2
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
README.mdapps/host/rnef.config.mjsapps/host/src/App.tsxapps/host/src/components/DevToolsPanel.tsxapps/host/src/components/SourceOverlay.tsxapps/host/src/hooks/useCacheStatus.tsapps/mini/rnef.config.mjsapps/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
zephyr-native-cache no longer exposes __MFE_BUNDLE_HASHES__; bundle hashes now live on globalThis.__ZEPHYR__.runtime.nativeCache.refs.bundleHashes.
Summary
ZephyrNativeCacheinstead of raw native-cache internals or app-local hook wiringZephyrNativeCache.checkForUpdates,clearCache, andreloadApp, with failure logging for manual actionszephyrMetroRNEFPlugindirectly fromzephyr-metro-pluginzephyr-native-cacheandzephyr-metro-pluginto0.0.0-canary.60__ZEPHYR__.runtime.nativeCache, the MF compatibility bridge, and legacy__MFE_*aliasesNotes
vendor/mf-coresubmodule remains out of scope for this PRuseCacheStatusis imported fromzephyr-native-cache/react, matching the canary package export mapValidation
pnpm installpnpm --filter cache-test-host list zephyr-native-cache zephyr-metro-plugin --depth 0pnpm --filter cache-test-mini list zephyr-metro-plugin --depth 0pnpm --filter cache-test-nested-mini list zephyr-metro-plugin --depth 0git diff --checkpnpm --filter cache-test-host exec tsc --noEmitstill fails on existing MF/RN ambient type issues (FederationRuntimePlugin,__DEV__,__NATIVE__, and native-cache source globals), but the canary rootuseCacheStatusexport mismatch is fixed