Skip to content

feat(state-manager): persist cut state in Save/Load State (closes #863 part 2)#882

Open
deveshbervar wants to merge 2 commits intoHSF:mainfrom
deveshbervar:feat/cut-state-serialization-863
Open

feat(state-manager): persist cut state in Save/Load State (closes #863 part 2)#882
deveshbervar wants to merge 2 commits intoHSF:mainfrom
deveshbervar:feat/cut-state-serialization-863

Conversation

@deveshbervar
Copy link
Copy Markdown
Collaborator

@deveshbervar deveshbervar commented Apr 14, 2026

Summary

Completes the fix for #863

PR #872 fixed cut re-application on live event switches (in-memory fix).
This PR adds the second half: cuts are now included in Save State and
fully restored by Load State, giving physicists persistent filter
configurations across sessions and page reloads.

Changes

cut.model.ts

  • Added CutJSON interface for type-safe serialization
  • Added Cut.toJSON() — serializes current slider state to a plain object
  • Added Cut.fromJSON() — reconstructs a Cut instance from saved JSON

phoenix-menu-ui.ts

  • Added getCollectionCuts() — exposes the cut registry to StateManager
  • Added setCollectionCuts() — allows StateManager to write restored cuts

ui-manager/index.ts

  • Added getPhoenixMenuUI() — exposes PhoenixMenuUI instance publicly

state-manager.ts

  • getStateAsJSON() now includes a cuts key
  • Added getActiveCutsAsJSON() — collects and serializes active cuts
  • Added restoreCutsFromJSON() — deserializes and re-applies saved cuts
  • loadStateFromJSON() calls restore when cuts key is present

Before vs After

Before: Save State → page reload → Load State silently loses all
active filters

After: Save State captures cuts; Load State re-applies them exactly.
Verified: apply η < 0.5 on Tracks → Save State → refresh page →
Load State → slider still shows 0.5, cut correctly re-applied.

Testing

  • 8 new tests in cut.model.test.ts: toJSON, fromJSON, round-trip
  • 9 new tests in state-manager.test.ts: all serialization paths
  • 202 tests passing, 0 failing
  • Manual: η < 0.5 on Tracks persists through Save → reload → Load State

Note: phoenix-ng test failures (dupMap.get is not a function) are
pre-existing on main before this branch and unrelated to this PR.

… State

- Add CutJSON interface and Cut.toJSON()/fromJSON() to Cut model
- Expose getCollectionCuts()/setCollectionCuts() on PhoenixMenuUI
- Add getPhoenixMenuUI() to UIManager public API
- Extend StateManager.getStateAsJSON() to include active cuts
- Add StateManager.restoreCutsFromJSON() called by loadStateFromJSON()
- Extend cut.model.test.ts: toJSON, fromJSON, round-trip tests (8 new)
- Extend state-manager.test.ts: cut serialization tests (9 new)

Cuts applied before Save State are now fully restored on Load State.
Works with PR HSF#872 (live re-application on event switch) to provide
complete cut state persistence across both live sessions and saved files.
202 tests passing, 0 failing.

Closes HSF#863 (part 2 - serialization)
@deveshbervar deveshbervar requested review from 9inpachi and sponce April 16, 2026 01:28
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.

1 participant