[PR #713] [MERGED] Round-trip persona & character native export/import (avatar, sprites, gallery) #4740

Closed
opened 2026-10-22 04:10:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/713
Author: @LukaTheHero
Created: 5/11/2026
Status: ✅ Merged
Merged: 5/11/2026
Merged by: @LukaTheHero

Base: main ← Head: fix/persona-export-import-roundtrip


📝 Commits (3)

  • 80cdb27 fix: round-trip persona & character native export/import with avatar, sprites, and gallery
  • f92894b fix: address CodeRabbit review on persona/character export round-trip
  • 93c38c2 fix: drop unused parseFailure flag in handleMarinaraImport

📊 Changes

8 files changed (+465 additions, -36 deletions)

View changed files

📝 packages/client/src/components/characters/CharacterEditor.tsx (+6 -9)
📝 packages/client/src/components/modals/ImportCharacterModal.tsx (+40 -0)
📝 packages/client/src/components/modals/ImportPersonaModal.tsx (+28 -0)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+36 -14)
📝 packages/client/src/components/ui/ExportFormatDialog.tsx (+11 -3)
📝 packages/server/src/routes/characters.routes.ts (+110 -9)
📝 packages/server/src/routes/import.routes.ts (+72 -0)
📝 packages/server/src/services/import/marinara.importer.ts (+162 -1)

📄 Description

Why

Closes #709.

Exporting a persona or character as Marinara Native and re-importing the file was dropping the profile picture and several other tab contents. The native envelope only carried the row's plain text fields — avatarPath was stripped (and the file was never embedded), sprites lived in a separate data/sprites/<id>/ directory that the export ignored, and the character gallery was a whole separate table that nothing touched. On top of that, the persona importer was throwing away comment, personaStats, altDescriptions, tags, and savedStatusOptions because those fields weren't wired into createPersona.

The user's expectation is that Marinara Native means "everything round-trips." This PR makes that true.

What changes

Native export now embeds binary data as base64 data URLs inside the JSON envelope:

  • data.avatar — the profile picture (personas and characters)
  • data.sprites — every file in data/sprites/<id>/ as { filename, data }
  • data.gallery — every character_images row + the file on disk as { filename, prompt, provider, model, width, height, data } (characters only)

Native import unpacks all three and writes them back: avatar to data/avatars/, sprites to data/sprites/<newId>/ (filenames sanitized), gallery binaries to data/gallery/characters/<newId>/ plus matching character_images rows. Image bytes are validated through isAllowedImageBuffer before anything hits disk.

Persona importer now also passes comment, personaStats, altDescriptions, tags, savedStatusOptions through to createPersona so they survive the round-trip.

Compatible JSON export/import is unchanged — it's still avatar-less and field-minimal, as expected by other tools.

Export dialog UX (characters only): a third "Compatible PNG Card" card joins Marinara Native and Compatible JSON, and the standalone PNG-card toolbar button is removed so the export menu isn't bloated. The PNG path still hits the existing /characters/:id/export-png endpoint.

Backward compat: an earlier iteration shipped a .marinara zip format briefly. The new POST /import/marinara-package multipart endpoint accepts those zips (data.json + avatar.*) so anyone who already exported one can still import it. Client modals detect the PK zip signature on dropped files and route to that endpoint automatically.

Files

  • packages/server/src/routes/characters.routes.ts — embed avatar/sprites/gallery in native envelopes
  • packages/server/src/routes/import.routes.ts — new /import/marinara-package multipart route for legacy .marinara zip files
  • packages/server/src/services/import/marinara.importer.ts — restoreSprites, restoreCharacterGallery, persona field passthrough, shared decodeImageDataUrl helper
  • packages/client/src/components/ui/ExportFormatDialog.tsx — new compatible-png choice + showPngOption prop
  • packages/client/src/components/characters/CharacterEditor.tsx — wire up PNG choice; drop the standalone toolbar button
  • packages/client/src/components/modals/ImportCharacterModal.tsx, ImportPersonaModal.tsx, panels/SettingsPanel.tsx — zip-signature detection so legacy .marinara zips still import

Validation

  • pnpm check passes (impeccable-context + lint + build).
  • Manually tested by author before opening this PR.

Out of scope / known

  • Compatible JSON intentionally still omits avatar/sprites/gallery to stay portable with other tools.
  • Personas have no native PNG-card equivalent — the third option only appears for characters.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/713 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 5/11/2026 **Status:** ✅ Merged **Merged:** 5/11/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `fix/persona-export-import-roundtrip` --- ### 📝 Commits (3) - [`80cdb27`](https://github.com/Pasta-Devs/Marinara-Engine/commit/80cdb276759bced8ac7710ca1ef4c7822ea6e413) fix: round-trip persona & character native export/import with avatar, sprites, and gallery - [`f92894b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f92894b9c1aaa4869e69d931a1de3292ade3ba79) fix: address CodeRabbit review on persona/character export round-trip - [`93c38c2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93c38c25c14b6ed573826cc9cc8f2fed79649d4b) fix: drop unused parseFailure flag in handleMarinaraImport ### 📊 Changes **8 files changed** (+465 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+6 -9) 📝 `packages/client/src/components/modals/ImportCharacterModal.tsx` (+40 -0) 📝 `packages/client/src/components/modals/ImportPersonaModal.tsx` (+28 -0) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+36 -14) 📝 `packages/client/src/components/ui/ExportFormatDialog.tsx` (+11 -3) 📝 `packages/server/src/routes/characters.routes.ts` (+110 -9) 📝 `packages/server/src/routes/import.routes.ts` (+72 -0) 📝 `packages/server/src/services/import/marinara.importer.ts` (+162 -1) </details> ### 📄 Description ## Why Closes #709. Exporting a persona or character as **Marinara Native** and re-importing the file was dropping the profile picture and several other tab contents. The native envelope only carried the row's plain text fields — `avatarPath` was stripped (and the file was never embedded), sprites lived in a separate `data/sprites/<id>/` directory that the export ignored, and the character gallery was a whole separate table that nothing touched. On top of that, the persona importer was throwing away `comment`, `personaStats`, `altDescriptions`, `tags`, and `savedStatusOptions` because those fields weren't wired into `createPersona`. The user's expectation is that Marinara Native means "everything round-trips." This PR makes that true. ## What changes **Native export now embeds binary data as base64 data URLs inside the JSON envelope:** - `data.avatar` — the profile picture (personas and characters) - `data.sprites` — every file in `data/sprites/<id>/` as `{ filename, data }` - `data.gallery` — every `character_images` row + the file on disk as `{ filename, prompt, provider, model, width, height, data }` (characters only) **Native import** unpacks all three and writes them back: avatar to `data/avatars/`, sprites to `data/sprites/<newId>/` (filenames sanitized), gallery binaries to `data/gallery/characters/<newId>/` plus matching `character_images` rows. Image bytes are validated through `isAllowedImageBuffer` before anything hits disk. **Persona importer** now also passes `comment`, `personaStats`, `altDescriptions`, `tags`, `savedStatusOptions` through to `createPersona` so they survive the round-trip. **Compatible JSON** export/import is unchanged — it's still avatar-less and field-minimal, as expected by other tools. **Export dialog UX (characters only):** a third "Compatible PNG Card" card joins Marinara Native and Compatible JSON, and the standalone PNG-card toolbar button is removed so the export menu isn't bloated. The PNG path still hits the existing `/characters/:id/export-png` endpoint. **Backward compat:** an earlier iteration shipped a `.marinara` zip format briefly. The new `POST /import/marinara-package` multipart endpoint accepts those zips (data.json + avatar.*) so anyone who already exported one can still import it. Client modals detect the PK zip signature on dropped files and route to that endpoint automatically. ## Files - `packages/server/src/routes/characters.routes.ts` — embed avatar/sprites/gallery in native envelopes - `packages/server/src/routes/import.routes.ts` — new `/import/marinara-package` multipart route for legacy `.marinara` zip files - `packages/server/src/services/import/marinara.importer.ts` — `restoreSprites`, `restoreCharacterGallery`, persona field passthrough, shared `decodeImageDataUrl` helper - `packages/client/src/components/ui/ExportFormatDialog.tsx` — new `compatible-png` choice + `showPngOption` prop - `packages/client/src/components/characters/CharacterEditor.tsx` — wire up PNG choice; drop the standalone toolbar button - `packages/client/src/components/modals/ImportCharacterModal.tsx`, `ImportPersonaModal.tsx`, `panels/SettingsPanel.tsx` — zip-signature detection so legacy `.marinara` zips still import ## Validation - `pnpm check` passes (impeccable-context + lint + build). - Manually tested by author before opening this PR. ## Out of scope / known - Compatible JSON intentionally still omits avatar/sprites/gallery to stay portable with other tools. - Personas have no native PNG-card equivalent — the third option only appears for characters. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:15 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4740
No description provided.