Skip to content

fix(gui): preserve mandrel endDiameter on open/plan/save - #346

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/gui-enddiameter-roundtrip
Aug 8, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/gui-enddiameter-roundtrip

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Summary

Fixes #344 — the desktop GUI silently dropped mandrelParameters.endDiameter (schemaVersion 1.1 reducing-cone field) when opening, planning, or saving a .wind file. 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 with endDiameter deleted (data loss).

Fix

Thread end_diameter through 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 — windDefinitionToDocument preserves it on load; projectToWindDefinition emits it on save/plan and derives schemaVersion from content (1.1 for a cone, 1.0 for a cylinder) instead of hardcoding 1.0.

Cylinder documents stay byte-identical (the field is only added when a cone small-end is present). updateMandrel already merges via Object.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 emits endDiameter + bumps to 1.1; full round-trip keeps it; cylinder path unchanged; the plan-preview (visibleLayerCount) path preserves it; endDiameter: null collapses 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 future 1.2-only file would still be version-downgraded on re-save (same reserialize-architecture limitation, guarded for the VK profile case by #326); not a regression here.

Verified by an adversarial subagent review (no blocker/major findings).

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
@CameronBrooks11
CameronBrooks11 merged commit 1154454 into main Aug 8, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/gui-enddiameter-roundtrip branch August 8, 2026 05:31
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