Skip to content

Sync model mutations into shared universe state - #20

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

Sync model mutations into shared universe state#20
SnorreFossland merged 3 commits into
alpha-prefrom
codex/shared-universe-model-mutations

Conversation

@SnorreFossland

Copy link
Copy Markdown
Contributor

Summary

  • Carry forward the shared focus sync and model-page review-fix commits that did not land in the previous merge.
  • Mirror legacy model-suite mutation actions into universe.world.worldModel.metis for project/model/modelview property updates and model/modelview reordering.
  • Keep legacy reducer behavior intact so existing GoJS/AKMM dispatch paths continue to work while shared selectors stay current.

Verification

  • npm run build passed.
  • npm test passed.

Notes

  • This intentionally does not migrate object, objectview, relationship, or relationship-view mutations yet. Those are the next, larger GoJS/AKMM write-path slice.

@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 11:19pm

@SnorreFossland
SnorreFossland marked this pull request as ready for review June 3, 2026 23:20
Copilot AI review requested due to automatic review settings June 3, 2026 23:20
@SnorreFossland
SnorreFossland merged commit e0d9eaf into alpha-pre Jun 3, 2026
2 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 extends the “shared universe” Redux state so it stays in sync with legacy model-suite mutations (focus updates, project/model/modelview property updates, and model/modelview reordering) while preserving the existing legacy reducer/dispatch paths used by the GoJS/AKMM code.

Changes:

  • Run the shared universeReducer on every action and only fall back to rebuilding universe-from-legacy when the universe reducer does not handle the action.
  • Add shared-universe handling for legacy focus actions and selected model-suite mutation actions (UPDATE_*_PROPERTIES, REORDER_*) by mutating world.worldModel.metis and (when applicable) focus.
  • Adjust /model username fetching to avoid dispatching setUniverseUser with potentially stale phUser state.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/store.tsx Updates the root reducer to always reduce the shared universe state and rebuild-from-legacy only when needed.
src/sharedUniverse/universeSlice.ts Adds handling to mirror legacy focus + model/modelview mutations into world.worldModel.metis (and focus when applicable).
src/pages/model.tsx Refactors username fetch flow to stage the fetched name before dispatching setUniverseUser.

Comment on lines +325 to +344
if (action.type === 'UPDATE_MODEL_PROPERTIES' || action.type === 'UPDATE_TARGETMODEL_PROPERTIES') {
const metis = asRecord(state.world.worldModel.metis);
const models: any[] = Array.isArray(metis.models) ? metis.models : [];
if (!models.length) return state;

const patch = asRecord(action.data);
const modelIndex = findModelIndex(models, asRecord(state.world.focus), patch.id);
if (modelIndex < 0 || !models[modelIndex]) return state;

const nextModels = replaceArrayItem(models, modelIndex, {
...models[modelIndex],
...patch,
});
const focus = updateFocusedItem(asRecord(state.world.focus), 'focusModel', patch);

return updateMetis(state, {
...metis,
models: nextModels,
}, focus);
}
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