Add back pre-2025-11-28 old format import support#8556
Conversation
- Move file format code into `src/file-format/` (export, import, remove-visual-info, old-formats) - Replace manual type guards with Zod schemas for import validation, matching clipboard types pattern - Add versioned file format envelope (version, meta.generator) to exports - Fix stale closure bug: run ELK layout before createNewNet so positions are baked into the data - Add `onlyMissingPositions` option to calculateGraphLayout for partial re-layout - Add ImportErrorDialog showing Zod validation errors with "Create empty net" fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Zod schema required iconSlug and displayColor on color types, but these fields are stripped by "export without visual info". Make them optional in the schema and fill defaults on import, matching how missing x/y positions are already handled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move old format Zod schema into old-formats/pre-2025-11-28/ - Integrate old format parsing into parseSDCPNFile so pre-2025-11-28 files are validated and converted during import (previously dead code) - Reject versioned files from legacy fallback path to prevent silently accepting unsupported future versions - Remove dead convertOldFormatToSDCPN call from editor-view - Remove unnecessary useCallback (React Compiler handles memoization) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the unsupported-version rejection from a Zod .refine() (which never worked because z.object() strips unknown keys first) into parseSDCPNFile where we can inspect the raw data. Remove unused SDCPNFileFormat type export. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Cap Open submenu height using --available-height CSS var - Sort Open menu by most recently updated net - Clean up empty nets from storage when switching away - Update lastUpdated timestamp on net mutation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix export spread order so explicit title cannot be overwritten - Fix stale closure in loadPetriNet by moving check inside updater - Show actual Zod errors for supported version with invalid structure - Split hasMissingPositions from type visual info check - Remove pre-2025-11-28 old format import support - Add 19 unit tests for parseSDCPNFile Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove old-formats directory and all related exports/types - Simplify localStorage types (no more OldFormat union) - Remove old format conversion logic from init effect - Remove onlyMissingPositions from calculateGraphLayout, always do full layout Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
PR SummaryMedium Risk Overview
Written by Cursor Bugbot for commit 517e9c2. This will update automatically on new commits. Configure here. |
🤖 Augment PR SummarySummary: Restores import compatibility for SDCPN JSON files saved before 2025-11-28 by adding an explicit old-format schema + converter. Changes:
Technical Notes: Conversion maps renamed keys (e.g. 🤖 Was this summary useful? React with 👍 or 👎 |
| } | ||
|
|
||
| // Try the pre-2025-11-28 old format (different field names) | ||
| const oldFormat = oldFormatFileSchema.safeParse(data); |
There was a problem hiding this comment.
There are strong unit tests for the versioned/legacy parsing paths, but nothing that exercises this pre-2025-11-28 fallback. Without a test, regressions in oldFormatFileSchema/convertOldFormatToSDCPN (field renames, nullability) could slip through unnoticed.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| return { | ||
| ok: true, | ||
| sdcpn: converted, | ||
| hadMissingPositions: false, |
There was a problem hiding this comment.
This old-format branch hardcodes hadMissingPositions: false and returns converted without running through fillMissingVisualInfo. If old-format files can omit positions or type visual fields (like the legacy/versioned schemas allow), this could change import behavior in subtle ways—was that intentional?
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| dynamicsEnabled: z.boolean(), | ||
| differentialEquationCode: z.object({ refId: z.string() }).nullable(), | ||
| visualizerCode: z.string().optional(), | ||
| x: z.number(), |
There was a problem hiding this comment.
oldPlaceSchema requires x/y (and oldColorSchema requires iconId/colorCode), but the importer generally supports files exported without visual info by defaulting these later. If old-format exports could also omit this visual data, this schema may reject otherwise-importable files—does the old format guarantee these fields are always present?
Severity: medium
Other Locations
libs/@hashintel/petrinaut/src/file-format/old-format.ts:58libs/@hashintel/petrinaut/src/file-format/old-format.ts:59libs/@hashintel/petrinaut/src/file-format/old-format.ts:43libs/@hashintel/petrinaut/src/file-format/old-format.ts:44
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| hadMissingPositions: false, | ||
| }; | ||
| } | ||
|
|
There was a problem hiding this comment.
Error message shows irrelevant legacy format diagnostics
Low Severity
When all three parse attempts (versioned, legacy, old format) fail, the final error message still reports legacy.error.issues. A user providing a nearly-valid old-format file (e.g., with a minor field error) sees misleading diagnostics referencing legacy field names like colorId instead of the old-format names (type, differentialEquationCode) that their file actually uses. The insertion of the old-format fallback between the legacy failure and this error return changed the semantic context of the message without updating it.
Additional Locations (1)
Consolidated old format schema, types, and conversion into a single file (old-format.ts) and integrated it as a last-resort fallback in parseSDCPNFile, after versioned and legacy formats fail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0d50cc9 to
517e9c2
Compare


🌟 What is the purpose of this PR?
Re-adds support for importing SDCPN files saved in the pre-2025-11-28 format, which used different field names (
typeinstead ofcolorId,differentialEquationCodeinstead ofdifferentialEquationId,iconIdinstead oficonSlug, etc.).🔗 Related links
🔍 What does this change?
old-format.ts— a single consolidated file containing the Zod schema, types, and conversion logic for the pre-2025-11-28 format (previously spread across 4 files)parseSDCPNFile— tried after versioned and legacy formats both failPre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
❓ How to test this?
typeinstead ofcolorId, etc.)