Repository navigation
fix(gui): preserve mandrel endDiameter on open/plan/save - #346
Merged
Merged
Conversation
The GUI plans and saves from a reserialized project model, but the Zod MandrelParametersSchema and the project<->wind converters only carried diameter/windLength. A reducing-cone .wind (schemaVersion 1.1, with endDiameter) opened in the GUI was therefore planned/exported as a cylinder, and Save rewrote the file with endDiameter deleted -- silent data loss. Thread end_diameter through the Mandrel type, MandrelParametersSchema, and both converter directions, and derive schemaVersion from content (1.1 when a cone small-end is present, 1.0 for a plain cylinder) instead of hardcoding 1.0. Cylinder documents stay byte-identical. Adds cone round-trip regression tests (including the plan-preview and null-endDiameter paths). Closes #344
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.
Summary
Fixes #344 — the desktop GUI silently dropped
mandrelParameters.endDiameter(schemaVersion 1.1 reducing-cone field) when opening, planning, or saving a.windfile. Because the GUI plans/saves from a reserialized project model, a cone file opened in the GUI was planned/exported as a cylinder, and Save rewrote the file withendDiameterdeleted (data loss).Fix
Thread
end_diameterthrough the three places the model dropped it:src/types/project.ts—Mandrel.end_diameter?: number | null.src/lib/schemas.ts—MandrelParametersSchema.endDiameter(accepted, not stripped).src/types/converters.ts—windDefinitionToDocumentpreserves it on load;projectToWindDefinitionemits it on save/plan and derivesschemaVersionfrom content (1.1 for a cone, 1.0 for a cylinder) instead of hardcoding1.0.Cylinder documents stay byte-identical (the field is only added when a cone small-end is present).
updateMandrelalready merges viaObject.assign, so editing diameter/length no longer wipes a loaded cone.Tests
src/types/converters-document.test.ts— cone load preserves the small-end; save emitsendDiameter+ bumps to 1.1; full round-trip keeps it; cylinder path unchanged; the plan-preview (visibleLayerCount) path preserves it;endDiameter: nullcollapses to a cylinder. Local gate green:tsc,svelte-check,vitest(332),stylelint,vite build.Scope / follow-ups
Pure data-loss fix. The GUI does not yet expose an editor for
endDiameter(a loaded cone is preserved and plans correctly, but cannot be created/edited in-GUI) — folded into the GUI mandrel-surface editing follow-up (#345). A future1.2-only file would still be version-downgraded on re-save (same reserialize-architecture limitation, guarded for the VKprofilecase by #326); not a regression here.Verified by an adversarial subagent review (no blocker/major findings).