Repository navigation
fix(event-display): keep a cut's default range over clone and save/load - #1037
Merged
EdwardMoyse merged 1 commit intoSep 15, 2026
Merged
EdwardMoyse merged 1 commit into
EdwardMoyse merged 1 commit into
Conversation
A Cut captures the bounds it is constructed with as the values `reset()` restores. Both `clone()` and `fromJSON()` rebuild a Cut through that same constructor using its *current* bounds, so any narrowing the user has applied silently becomes the new default. For `fromJSON` this sits on the state-restore path: `restoreCutsFromJSON` rebuilds every cut that way and hands the result to the menu, which is what the "Reset cuts" button operates on. So after saving a state with pT narrowed to 40-60 and loading it back, "Reset cuts" returns to 40-60 rather than the collection's configured 0-100, and the full range cannot be recovered without reloading the event. Widening back out after narrowing in is the point of the button, and since the value shown is the one the user saved, it reads as the button being dead rather than the range having been lost. `CutJSON` had nowhere to carry the defaults, so add an optional `defaults` block and populate it in `toJSON`. `fromJSON` constructs from those defaults and then applies the saved active values on top. The field is optional and falls back to the active values, so state files written before this change still load with exactly today's behaviour. `clone()` gets the same treatment, building from the source's defaults rather than its current values. It is called once per collection at load time from pristine cuts, so it does not misbehave today, but it is the same defect. Added tests for reset-after-clone, reset-after-round-trip, and the legacy no-defaults fallback. The first three fail before this change. Updated the existing exact-shape toJSON assertion for the new field; the neighbouring test asserting no private `defaultMinValue` / `defaultMaxValue` keys leak still holds, since the defaults are nested under their own key. Fixes HSF#1036
|
🚀 Preview deployed: http://phoenix-pr-1037.surge.sh Built from 19ad5cd. |
This branch was successfully deployed
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.
Fixes #1036
Problem
A
Cutrecords the bounds it was constructed with as the valuesreset()restores.clone()andfromJSON()both rebuild a Cut through that constructor using its current bounds, so any narrowing the user applied silently becomes the new default.fromJSONsits on the state-restore path —StateManager.restoreCutsFromJSONrebuilds every cut that way and hands the result to the menu, which is exactly what the Reset cuts button operates on:0–100to40–60, save the state, reload, load it back.40–60.40–60. The configured range is gone and cannot be recovered without reloading the event.Widening back out after narrowing in is the point of that button. Because the number shown is the one the user saved, it reads as the button being broken rather than the range having been lost.
Fix
CutJSONhad nowhere to carry the defaults, so:defaultsblock (minValue,maxValue,minCutActive,maxCutActive) toCutJSON, populated bytoJSON().fromJSON()constructs from those defaults, then applies the saved active values on top — so the restored cut reads what the user saved but resets to the collection's real range.clone()does the same, building from the source's defaults rather than its current values.Backward compatibility
defaultsis optional and falls back to the active values:State files written before this change load exactly as they do today — no migration, no error. There is a test pinning that.
On
clone()clone()is called once per collection at load time from cuts still at their configured values (phoenix-loader.ts#L253), so it does not misbehave today. I fixed it anyway because it is the same defect and would bite the first time a cut is cloned after adjustment — but flagging it so reviewers know only thefromJSONhalf is a live user-facing bug.Tests
Added to
cut.model.test.ts:reset()gives40where0is expected)I also updated one existing assertion:
toJSONhad an exact-shapetoEqualthat now needs thedefaultskey. Worth noting that the neighbouring test asserting no privatedefaultMinValue/defaultMaxValuekeys leak into the JSON still passes unchanged, since the defaults are nested under their own key rather than flattened onto the object.Verification
phoenix-event-display: 44 suites / 399 tests passed, 0 failures.phoenix-ng: 62 suites / 221 tests passed, 0 failures.eslintclean on both changed files.tsc --noEmitreports one error insrc/tests/helpers/webgl-mock.ts(three.modulehas no default export). It is pre-existing — identical on a clean tree — and unrelated to this change.