Added the ability to create a new universe when importing/linking a universe file, rather than only being able to overwrite an existing universe.
Location: Lines 2330-2500
What Changed: When a user clicks "Link Existing File" on a universe, they now get a dialog with two options:
- Link to Existing - Replace the current universe's data with the file's contents (original behavior)
- Create New Universe - Create a brand new universe from the file (new feature)
User Flow:
- User clicks "Add Local File" → "Link Existing File" on any universe
- User selects a
.redstringfile from their computer - Dialog appears: "How would you like to import [filename]?"
- Link to Existing: Overwrites the current universe with the file data
- Create New Universe: Creates a new universe using the filename as the base name
- User can also press Escape or click outside to cancel
Benefits:
- Prevents accidental data loss when users want to import a file as a new universe
- Provides flexibility in workflow - users can now import multiple universe files without overwriting existing ones
- More intuitive UX - users get to choose their intent explicitly
This flow already creates a new universe by default when using "Load → From Local File" from the universes list. No changes needed.
Git imports already create new universes by default when using the "Import From Repository" option. No changes needed.
To test the new functionality:
- Start the dev server:
npm run dev - Create or open a universe
- Click "Add Local File" → "Link Existing File"
- Select a
.redstringfile - Verify the dialog appears with both options
- Test "Link to Existing" - should overwrite current universe
- Test "Create New Universe" - should create a new universe with the file name
- Test canceling - should close without changes
- ✅ No linting errors
- ✅ Consistent with existing code patterns
- ✅ Proper error handling
- ✅ Loading states handled
- ✅ UI refresh after creating new universe
- ✅ Success messages shown to user
- Modified the
handleLinkLocalFilefunction to always show a confirmation dialog - Removed the old "name mismatch" warning (which only appeared sometimes)
- Added logic to create a new universe when user clicks "Create New Universe"
- Reused the
gitFederationService.createUniversemethod - Properly handles the new universe slug and updates the payload
- Calls
refreshState()to update the UI after creating the new universe
{
title: 'Import Universe File',
message: `How would you like to import "${file.name}"?`,
details: `• Link to Existing: Replace "${universe?.name || slug}" data with this file's contents.\n\n• Create New Universe: Make a new universe from this file.\n\n(Press Escape or click outside to cancel)`,
variant: 'default',
confirmLabel: 'Link to Existing',
cancelLabel: 'Create New Universe'
}Possible future improvements:
- Add keyboard shortcuts (e.g., Ctrl+N for new, Ctrl+L for link)
- Remember user's last choice as a default
- Add "Always ask" / "Don't ask again" option
- Show preview of file contents before importing
- Batch import multiple files at once