Skip to content

Migrate Redux bridge toward shared universe state#14

Merged
SnorreFossland merged 9 commits into
alpha-prefrom
codex/rtk-shared-universe
Jun 3, 2026
Merged

Migrate Redux bridge toward shared universe state#14
SnorreFossland merged 9 commits into
alpha-prefrom
codex/rtk-shared-universe

Conversation

@SnorreFossland

Copy link
Copy Markdown
Contributor

Summary

This PR starts the Redux migration toward a shared universe state while keeping the existing legacy ph* state active.

The branch is intentionally transitional: legacy phData, phFocus, phUser, and phSource continue to exist, while the new state.universe tree mirrors the same canonical data shape used by the workspace side.

Coordination With alpha-pre

This PR targets alpha-pre directly because concurrent work is happening there.

Please coordinate carefully with work touching:

  • src/store.tsx
  • src/sharedUniverse/*
  • src/reducer.js / legacy ph* dispatches
  • GoJS / AKMM dispatch paths
  • model, project, and modelling load boundaries

Current architecture:

  • legacy action -> reducer.js -> ph* state updated -> shared universe rebuilt
  • shared action -> shared universe reducer -> legacy ph* mirrored

This lets existing GoJS/AKMM code keep working while new code can start reading from shared universe state.

Changes

  • Migrated store setup to RTK configureStore while preserving the legacy reducer.
  • Added shared universe state/actions/selectors.
  • Added compatibility bridging between legacy dispatches and shared universe actions.
  • Routed modelling/project/table/task surfaces toward shared universe selectors.
  • Routed file loaders and load boundaries through shared universe actions.
  • Wrapped GoJS legacy dispatches so LOAD_TOSTORE_* actions also update shared universe state.

Validation

Ran successfully before publishing:

  • pnpm exec tsc --incremental false
  • pnpm test
  • pnpm build
  • Local /model?... route smoke check returned HTTP 200

Known existing build warning remains:

WARNING: a go object on the root object is already defined. version: 3.1.10, replaced with version: 3.1.10

@vercel

vercel Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mimris Ready Ready Preview, Comment Jun 3, 2026 3:44pm

@SnorreFossland SnorreFossland marked this pull request as ready for review June 3, 2026 15:47
Copilot AI review requested due to automatic review settings June 3, 2026 15:47
@SnorreFossland SnorreFossland merged commit 89dccfc into alpha-pre Jun 3, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 configureStore and adds a root reducer that mirrors between legacy ph* state and the new universe tree.
  • Adds sharedUniverse actions/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 thread src/store.tsx
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 thread src/pages/modelling.tsx
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()
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