fix: preserve seed and prngAlgorithm in config migrations

**Bug:** V2→V3 and V3→V4 config migrations were dropping the seed and
prngAlgorithm fields, causing problems to regenerate on every page reload.

**Root Cause:** Migration functions explicitly listed fields to preserve
but forgot to include seed/prngAlgorithm.

**Fix:**
- Add seed and prngAlgorithm preservation to migrateAdditionV2toV3()
- Add seed and prngAlgorithm preservation to migrateAdditionV3toV4()
- Both fields are marked as CRITICAL for problem reproducibility

**Impact:**
- Problems will now persist across page reloads
- Shared worksheets continue to work correctly
- Users upgrading from V2 configs will keep their seed if it existed

**Testing:**
- Reload page → problems should remain the same
- Change a setting → new seed generated, new problems appear
- Reload again → those new problems persist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-11-17 16:53:58 -06:00
parent 8b3d019652
commit b18c412736

View File

@@ -776,6 +776,9 @@ function migrateAdditionV2toV3(v2: AdditionConfigV2): AdditionConfigV3 {
interpolate: v2.interpolate,
displayRules: v2.displayRules,
difficultyProfile: v2.difficultyProfile,
// CRITICAL: Preserve seed/prngAlgorithm for problem reproducibility
seed: v2.seed,
prngAlgorithm: v2.prngAlgorithm,
}
}
@@ -800,6 +803,9 @@ function migrateAdditionV2toV3(v2: AdditionConfigV2): AdditionConfigV3 {
showProblemNumbers: v2.displayRules.problemNumbers === 'always',
showCellBorder: v2.displayRules.cellBorders === 'always',
showTenFramesForAll: v2.showTenFramesForAll,
// CRITICAL: Preserve seed/prngAlgorithm for problem reproducibility
seed: v2.seed,
prngAlgorithm: v2.prngAlgorithm,
}
}
@@ -822,6 +828,9 @@ function migrateAdditionV3toV4(v3: AdditionConfigV3): AdditionConfigV4 {
pAnyStart: v3.pAnyStart,
pAllStart: v3.pAllStart,
interpolate: v3.interpolate,
// CRITICAL: Preserve seed/prngAlgorithm for problem reproducibility
seed: v3.seed,
prngAlgorithm: v3.prngAlgorithm,
}
if (v3.mode === 'smart') {