Migrate Redux bridge toward shared universe state#14
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a transitional “shared universe” Redux state (state.universe) while keeping the legacy phData / phFocus / phUser / phSource state working, and begins routing various UI/load surfaces to read/write through the shared universe bridge.
Changes:
- Migrates the Redux store setup to RTK
configureStoreand adds a root reducer that mirrors between legacyph*state and the newuniversetree. - Adds
sharedUniverseactions/reducer/selectors plus dispatch wrappers to translate legacy dispatches into universe updates. - Updates multiple pages/components/loaders to dispatch shared-universe actions and/or read from shared-universe selectors.
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/store.tsx | Moves store creation to RTK and adds a root reducer that mirrors legacy ph* state with state.universe. |
| src/sharedUniverse/universeSlice.ts | Defines shared universe state shape, actions, reducer, and legacy-to-universe builder. |
| src/sharedUniverse/selectors.ts | Adds selectors that resolve shared universe data from either universe or legacy ph*. |
| src/sharedUniverse/legacyDispatch.ts | Adds mapping/wrapping utilities to translate legacy actions into universe actions. |
| src/sharedUniverse/index.ts | Exposes shared-universe exports via a barrel file. |
| src/pages/project.tsx | Routes local store hydration through loadLegacyUniverseSnapshot. |
| src/pages/modelling.tsx | Routes project/model loads and user/focus updates toward shared universe actions. |
| src/pages/model.tsx | Switches remote/universe load boundary dispatching to shared universe actions/builders. |
| src/pages/index.tsx | Routes local store hydration through loadLegacyUniverseSnapshot. |
| src/components/utils/workspaceUniverseAdapter.ts | Improves workspace snapshot normalization and emits universe + aligned legacy ph* state. |
| src/components/utils/ReadModelFromFile.ts | Updates file import flows to dispatch shared universe actions/snapshots. |
| src/components/utils/DispatchFromLocalStore.ts | Hydrates state via loadLegacyUniverseSnapshot instead of per-slice legacy actions. |
| src/components/Tasks.tsx | Reads metis/focus via shared-universe selector rather than direct legacy selectors. |
| src/components/Table.tsx | Reads metis/focus/source via shared-universe selector and adapts legacy props. |
| src/components/Project.tsx | Reads domain display/edit fields from shared universe domain. |
| src/components/Modelling.tsx | Wraps dispatch for legacy->universe translation and constructs “compatibility props” for legacy consumers. |
| src/components/Modeller.tsx | Routes local store hydration through loadLegacyUniverseSnapshot. |
| src/components/loadModelData/ProjectMenuBar.tsx | Updates initial load/save flows to use shared universe snapshot/actions. |
| src/components/loadModelData/LoadRecovery.tsx | Routes recovery snapshot restore through loadLegacyUniverseSnapshot. |
| src/components/loadModelData/LoadNewModelProjectFromGitHub.tsx | Routes GitHub project load snapshot through loadLegacyUniverseSnapshot. |
| src/components/loadModelData/LoadMetamodelFromGitHub.tsx | Routes metamodel load to setUniversePhData. |
| src/components/loadModelData/LoadGitHub.tsx | Routes GitHub load flows to universe actions/snapshots. |
| src/components/gojs/components/Diagram.tsx | Wraps diagram dispatch to translate legacy persistence actions into universe updates. |
| src/components/forms/ProjectDetailsForm.tsx | Routes source filename updates through setUniverseSource. |
| package.json | Updates next version and dependency ordering. |
| package-lock.json | Lockfile updates corresponding to the dependency changes. |
Comment on lines
+72
to
86
| export const makeStore = (_context?: Context) => { | ||
| const store = configureStore({ | ||
| reducer: rootReducer, | ||
| devTools: process.env.NODE_ENV !== 'production', | ||
| middleware: (getDefaultMiddleware) => | ||
| getDefaultMiddleware({ | ||
| immutableCheck: false, | ||
| serializableCheck: false, | ||
| }), | ||
| }); | ||
|
|
||
| (store as SagaStore).sagaTask = sagaMiddleware.run(rootSaga); | ||
| currentStore = store; | ||
|
|
||
| return store; | ||
| }; |
Comment on lines
+12
to
+16
| export const toSharedUniverseAction = (action: AnyAction): AnyAction => { | ||
| switch (action?.type) { | ||
| case 'LOAD_TOSTORE_DATA': | ||
| return loadLegacyUniverseSnapshot(action.data) as AnyAction; | ||
| case 'LOAD_TOSTORE_PHDATA': |
Comment on lines
160
to
165
| const res = await searchGithub(org + '/' + repo, path, file, branch, 'file') | ||
| const githubData = await res?.data | ||
| const sha = await res?.data.sha | ||
| if (debug) console.log('145 modelling githubData:', githubData, sha) | ||
| dispatch({ type: 'LOAD_TOSTORE_DATA', data: githubData }) | ||
| dispatch(loadLegacyUniverseSnapshot(githubData)) | ||
| const timer = setTimeout(() => { |
Comment on lines
74
to
86
| if (isWorkspaceUniverseSnapshot(importedfile)) { | ||
| const adaptedState = buildMimrisStateFromWorkspaceSnapshot(importedfile, { | ||
| sourceName: filename, | ||
| sourcePath: filename, | ||
| }) | ||
| if (!adaptedState?.phData?.metis?.models?.length) { | ||
| alert('No models in this file.') | ||
| resetFileInput() | ||
| return | ||
| } | ||
| dispatch({ | ||
| type: 'LOAD_TOSTORE_DATA', | ||
| data: adaptedState, | ||
| }) | ||
| dispatch(loadLegacyUniverseSnapshot(adaptedState)) | ||
| dispatch({ type: 'SET_FOCUS_REFRESH', data: { id: Math.random().toString(36).substring(7), name: filename } }) | ||
| resetFileInput() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR starts the Redux migration toward a shared
universestate while keeping the existing legacyph*state active.The branch is intentionally transitional: legacy
phData,phFocus,phUser, andphSourcecontinue to exist, while the newstate.universetree mirrors the same canonical data shape used by the workspace side.Coordination With
alpha-preThis PR targets
alpha-predirectly because concurrent work is happening there.Please coordinate carefully with work touching:
src/store.tsxsrc/sharedUniverse/*src/reducer.js/ legacyph*dispatchesCurrent architecture:
reducer.js->ph*state updated -> shareduniverserebuiltph*mirroredThis lets existing GoJS/AKMM code keep working while new code can start reading from shared
universestate.Changes
configureStorewhile preserving the legacy reducer.LOAD_TOSTORE_*actions also update shared universe state.Validation
Ran successfully before publishing:
pnpm exec tsc --incremental falsepnpm testpnpm build/model?...route smoke check returned HTTP 200Known existing build warning remains: