-
Notifications
You must be signed in to change notification settings - Fork 39
#398 Warn when loading saves from newer versions #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: thekingofcity <[email protected]>
Co-authored-by: thekingofcity <[email protected]>
Co-authored-by: thekingofcity <[email protected]>
thekingofcity
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Set saveVersion in ConfirmOverwriteDialogProps to be not undefined. There should be a state in open-actions and rmp-gallery-app-clip that contains the version to be loaded and is set just before opening the ConfirmOverwriteDialog
- Made saveVersion required (not optional) in ConfirmOverwriteDialogProps - Added versionToLoad state in both open-actions.tsx and rmp-gallery-app-clip.tsx - Set version state just before opening the dialog in all call sites - Updated tests to reflect non-optional saveVersion prop - All 137 tests pass Co-authored-by: thekingofcity <[email protected]>
Done in commit 1158f3c. Changed:
|
thekingofcity
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds version checking to warn users when attempting to load save files from newer versions of the application. When a save file's version exceeds the current application version (66), an orange warning message is displayed in the confirmation dialog, alerting users that loading may cause errors or undefined behavior. The implementation extracts version information early in the load process and passes it to the dialog component for display.
Key Changes
- Added
parseVersionFromSave()utility function to extract version numbers from save strings before full validation - Enhanced
ConfirmOverwriteDialogto accept asaveVersionprop and conditionally display a warning when the version is newer thanCURRENT_VERSION - Integrated version checking into both file upload and gallery/share import flows with dedicated state management
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/save.ts | Adds parseVersionFromSave() function to extract version from save strings |
| src/util/save-version.test.ts | Comprehensive test suite for version parsing (14 test cases) |
| src/components/page-header/confirm-overwrite-dialog.tsx | Adds saveVersion prop and conditional warning display for newer versions |
| src/components/page-header/confirm-overwrite-dialog.test.tsx | Tests for warning display behavior in different version scenarios |
| src/components/page-header/open-actions.tsx | Adds versionToLoad state and parses version from uploaded files and tutorial |
| src/components/page-header/rmp-gallery-app-clip.tsx | Adds versionToLoad state and extracts version from gallery/share works |
| src/i18n/translations/*.json | Adds newerVersion translation key with interpolation in all 5 languages |
Loading saves from newer versions may contain unsupported elements, causing undefined errors. The dialog now warns users when attempting to load a save with
version > CURRENT_VERSION.Changes
Added
parseVersionFromSave()insrc/util/save.tsundefinedfor invalid JSON or non-integer versionsEnhanced
ConfirmOverwriteDialogsaveVersionprop (non-optional)Updated callers with version state management
open-actions.tsx: AddedversionToLoadstate, parses version from uploaded files and sets state before opening dialogrmp-gallery-app-clip.tsx: AddedversionToLoadstate, uses version from loaded work object and sets state before opening dialogAdded translations
newerVersionkey in all 5 supported languages with version interpolationImplementation
Version is now stored in dedicated state variables (
versionToLoad) in both components and set just before opening the ConfirmOverwriteDialog:Warning appears when saveVersion (100) > CURRENT_VERSION (66):
Test coverage: 14 new tests for version parsing and dialog behavior.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.