Skip to content

fix: create redux-bundler migration helpers#2388

Merged
SgtPooki merged 7 commits intomainfrom
feat/connect-provider
Aug 12, 2025
Merged

fix: create redux-bundler migration helpers#2388
SgtPooki merged 7 commits intomainfrom
feat/connect-provider

Conversation

@SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Jul 23, 2025

Created helpers, and migration guide, for migrating redux-bundler bundles to react context providers. Also migrated the identity bundle to a react context provider.

This is needed for the work on the new Diagnostics page (so we are not adding new redux-bundler bundles, but can consume data from existing bundles)

Related: #1925
Related: #2349


🚀 Feature: Redux-Bundler to React Context Migration System

Summary

Implemented a comprehensive migration system to gradually replace redux-bundler with modern React contexts while maintaining backward compatibility. Successfully migrated the identity bundle as the first example implementation.

📋 Key Changes

1. Context Bridge System (src/helpers/context-bridge.tsx)

  • useBridgeSelector<T>() - React hook to reactively consume redux bundle values
  • useBridgeContext() - React hook to expose context values to redux bundles
  • createContextSelector() - Redux bundle function to access context values
  • contextBridge.setContext() - Redux bundle function to bridge values to react context providers
  • Enables bidirectional communication during migration

2. Identity Bundle → React Context Migration

  • Replaced: src/bundles/identity.js (redux-bundler)
  • With: src/contexts/identity-context.tsx (React context)
  • Features:
    • Self-contained state management with useReducer
    • Smart polling (only when advanced node info expanded)
    • Automatic IPFS connection detection
    • Cached data sharing across page navigation

3. Component Migrations

  • Status components: connect()useIdentity() hook
    • src/status/NodeInfo.js
    • src/status/NodeInfoAdvanced.js
    • src/status/StatusPage.js
  • Performance optimizations: Fixed re-render issues with memoized comparisons

4. Bundle Compatibility Updates

  • src/bundles/ipfs-provider.js: Added reactor to bridge IPFS instance
  • src/bundles/connected.js: Added reactor to bridge connection status
  • src/bundles/peer-locations.js: Updated to consume identity from context bridge

5. Comprehensive Migration Guide (src/REDUX-BUNDLER-MIGRATION-GUIDE.md)

  • Phase 1: Bridge-based migration (current approach)
  • Phase 2: Pure React context migration
  • Phase 3: Remove bridge system entirely
  • Patterns: Detailed examples for each migration pattern
  • Checklist: 17-step migration process

🎯 Benefits

Developer Experience

  • Modern React patterns - hooks instead of redux-bundler HOCs
  • Full TypeScript support - type-safe context consumption
  • Easier testing - mock contexts instead of redux store
  • Gradual migration - maintain existing code during transition

Architecture Benefits

  • Reduced bundle size - remove redux-bundler dependencies over time
  • Cleaner state management - no redux boilerplate
  • Better separation of concerns - self-contained contexts
  • Future-proof - standard React patterns

🔄 Migration Status

✅ Completed (Identity Bundle)

  • Context bridge system
  • Identity context implementation
  • Component migrations (NodeInfo, NodeInfoAdvanced, StatusPage)
  • Bundle compatibility (peer-locations, ipfs-provider, connected)
  • Documentation and migration guide

🧪 Manual Testing

  • Identity data loads on initial page visit
  • Polling works only when advanced node info expanded
  • No page flashing during updates
  • Navigation between pages reuses cached data
  • All existing functionality preserved

📚 Documentation

  • Migration Guide: Complete 3-phase migration strategy with examples
  • API Documentation: All hooks and bridge functions documented
  • Migration Checklist: Step-by-step process for future bundle migrations
  • Troubleshooting: Common issues and solutions

This establishes the foundation for migrating all redux-bundler code to modern React patterns while maintaining a working application throughout the process.

@SgtPooki SgtPooki marked this pull request as ready for review July 23, 2025 20:44
@SgtPooki SgtPooki requested a review from a team as a code owner July 23, 2025 20:44
@SgtPooki SgtPooki merged commit d1fdb87 into main Aug 12, 2025
21 checks passed
@SgtPooki SgtPooki deleted the feat/connect-provider branch August 12, 2025 17:48
ipfs-gui-bot pushed a commit that referenced this pull request Sep 17, 2025
## [4.9.0](v4.8.0...v4.9.0) (2025-09-17)

 CID `bafybeietkqxghs3hm56e3w64s4papqlvvzqzjigs4eyuy24plkpz652fee`

 ---

### Features

* add Agent Version column to peers table ([#2433](#2433)) ([614f30d](614f30d)), closes [ipfs/kubo#9465](ipfs/kubo#9465) [ipfs/js-kubo-rpc-client#342](ipfs/js-kubo-rpc-client#342) [ipfs/kubo#9465](ipfs/kubo#9465)
* add close button to file viewer for improved navigation ([#2401](#2401)) ([84969a5](84969a5))
* add diagnostics screen ([#2392](#2392)) ([f3a8179](f3a8179)), closes [#2424](#2424) [ipfs-check#102](ipfs/ipfs-check#102) [/github.com/ipfs/ipfs-check/pull/102#pullrequestreview-3214396503](https://github.com/ipfs//github.com/ipfs/ipfs-check/pull/102/issues/pullrequestreview-3214396503) [#2434](#2434)
* **files:** advanced sorting options ([#2421](#2421)) ([c9251eb](c9251eb))
* migrate Tooltip from Javascript to Typescript ([#2381](#2381)) ([dc9e9ac](dc9e9ac))

### Bug Fixes

* create redux-bundler migration helpers ([#2388](#2388)) ([d1fdb87](d1fdb87))
* display UX friendly error for missing files ([#2346](#2346)) ([d4e7fca](d4e7fca))
* **files:** rename in Grid View ([#2422](#2422)) ([e39bce6](e39bce6))
* **i18n:** prevent English replacements in translation sync workflow ([#2418](#2418)) ([323c59e](323c59e))
* macos input focus issue in draggable regions ([#2416](#2416)) ([5382688](5382688))
* migrate error boundary to typescript ([#2402](#2402)) ([b33775a](b33775a))
* **navbar:**  highlighting on browser back ([#2425](#2425)) ([cec6dfd](cec6dfd))
* Prevent layout breaks with long filenames in file preview ([#2415](#2415)) ([f82efcd](f82efcd))
* reference to `global` in browser environment ([#2408](#2408)) ([03b2e92](03b2e92))
* shared max for bandwidth chart ([#2426](#2426)) ([cd17032](cd17032))
* typecheck more files ([#2409](#2409)) ([fb967ee](fb967ee))

### Tests

* fix bring-your-own kubo node functionality ([#2396](#2396)) ([0883cfa](0883cfa))
* make e2e tests more robust ([#2438](#2438)) ([3de544b](3de544b))

### Trivial Changes

* **readme:** update links ([dc6f8f4](dc6f8f4))
* remove selectApiUrl selector ([#2412](#2412)) ([d4710e8](d4710e8))
@ipfs-gui-bot
Copy link
Collaborator

🎉 This PR is included in version 4.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants