mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1181] [MERGED] Fix pre-refactor data migration import gaps #4963
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4963
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1181
Author: @Romuromylus
Created: 5/24/2026
Status: ✅ Merged
Merged: 5/24/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/pre-refactor-data-migration📝 Commits (7)
2239fc3Fix pre-refactor data migration import gaps68bb338Restore legacy avatar paths when assets are still staged48791f8Update legacy import tests for staging_root parameterbf92d15Read staged avatar bytes from staging dir, not data dird181d42Address CodeRabbit findings on legacy import normalizationdef54cdCoerce legacy text-encoded bool fields on imported lorebooksbc0a949Use listLorebookEntries capability for lorebook prompt assembly📊 Changes
9 files changed (+217 additions, -35 deletions)
View changed files
📝
src-tauri/src/commands/storage/imports/bulk_imports.rs(+1 -1)📝
src-tauri/src/commands/storage/imports/marinara.rs(+19 -0)📝
src-tauri/src/commands/storage/profile/assets.rs(+53 -10)📝
src-tauri/src/commands/storage/profile/legacy.rs(+59 -18)📝
src-tauri/src/commands/storage/profile/zip_import.rs(+2 -0)📝
src-tauri/src/commands/storage/shared.rs(+64 -0)📝
src/engine/generation/prompt-assembly.ts(+3 -1)📝
src/features/catalog/lorebooks/components/ImportLorebookModal.tsx(+8 -3)📝
src/features/catalog/presets/components/ImportPresetModal.tsx(+8 -2)📄 Description
Why this change
Existing users on the pre-refactor
stagingbranch cannot move their data into the Tauri refactor without hitting one of eight import or post-import gaps. The full-profile zip is rejected outright if the user has any chat images, every imported avatar lands as a broken URL, individual lorebook imports crash the editor on open, individual chat imports become unreachable, two of the seven pre-refactor envelope types silently create empty rows instead of erroring, every imported lorebook renders asGlobaleven when it was scoped, and any roleplay-mode chat with an attached lorebook fails to assemble a prompt at all. This PR fixes all eight gaps as one coherent change because they share a single theme - the refactor's importers, modals, and runtime don't yet account for the schema and envelope shapes the production app actually ships.Filed together at #1180.
What changed
src-tauri/src/commands/storage/profile/assets.rs: add"gallery"toPROFILE_ASSET_DIRS. The pre-refactor backup set includes agallery/directory for chat-image attachments; without this thesafe_profile_asset_pathallow-list rejected the entire profile zip withInvalid profile asset pathfor any user with chat images. Also thread an optionalstaging_rootthroughnormalize_legacy_profile_asset_pathsandlegacy_profile_asset_for_path, and resolve the read path off the staging dir when the install transaction hasn't committed yet. PR #1153 / #1179's atomic asset transaction moves restored files intostate.data_dironly at install time, so the previous existence check missed every just-restored avatar and the rows kept the unresolvable/api/avatars/file/<hash>.pngURLs. ExposeRestoredProfileAssets::staging_root()to support the same.src-tauri/src/commands/storage/profile/legacy.rs: read the staging root fromRestoredProfileAssetsand pass it throughimport_legacy_profile_tables/import_legacy_profile_tables_with_restored_assetsinto the per-row normalizer. Normalize legacy text-encoded array fields (tags,characterIds,personaIds) on lorebook rows then union them with the junction-table-derived link IDs, so neither source is dropped and the lorebook editor doesn't crash onformTags.map is not a function. Also normalize legacy text-encoded bool fields (isGlobal,enabled,recursiveScanning,excludeFromVectorization) on lorebook rows; pre-refactor stored these as"true"/"false"strings, which the frontend reads as truthy and renders every scoped lorebook asGlobal.src-tauri/src/commands/storage/profile/zip_import.rs: pass the staging root into the legacy branch alongside therestored_assetscount.src-tauri/src/commands/storage/imports/bulk_imports.rs: defaultimport_st_chat_texttomode = "conversation"instead of the bogus"chat". TheChatModeenum isconversation | roleplay | visual_novel | game; the old default sat outside the enum, so imported chats never showed up in any mode sidebar.src-tauri/src/commands/storage/imports/marinara.rs: inimport_marinara_lorebook, normalize legacy text-encoded array fields (tags,characterIds,personaIds) and bool fields (isGlobal,enabled,recursiveScanning,excludeFromVectorization) before writing the lorebook row, matching the legacy profile-zip path.src-tauri/src/commands/storage/shared.rs: addnormalize_legacy_text_array_fieldsandnormalize_legacy_text_bool_fieldsas the shared helpers both the marinara envelope path and the legacy profile-zip path use. The bool helper acceptstrue|1|yes|onandfalse|0|no|offas the truthy / falsy sets and coerces everything else (including malformed legacy values) tofalse.src/features/catalog/presets/components/ImportPresetModal.tsx+src/features/catalog/lorebooks/components/ImportLorebookModal.tsx: relax the strict-equality detection so anymarinara_*envelope (not only the exactly-matched type) routes to the Marinara importer instead of the permissive SillyTavern fallback. Matches the pattern the persona and character modals already use. The Rust router then rejects unsupported envelope types (marinara_chat_preset,marinara_memory_recall) with the existing "Unknown Marinara import type" error - clear failure instead of silent empty-record success.src/engine/generation/prompt-assembly.ts: inbuildActivatedEntries, use thelistLorebookEntries(lorebookId)capability instead of callingstorage.list("lorebooks/<id>/entries"). The path-style argument is a leftover from the pre-refactor HTTP API; the refactor storage layer rejects anything with a slash viavalidate_collection_name, so roleplay-mode chats with any attached lorebook surfacedInvalid collection name: lorebooks/<id>/entriesthe moment the user sent a message.Verification
pnpm checkandcargo clippy --all-targets -- -D warningspass locally.pnpm tauri devagainst a snapshot of the current production tables (31 characters, 20 personas, 32 lorebooks / 1492 entries, 5 chats with 126 messages and 24 memories, 3 chat presets, 18 connections, 9 chat-image gallery attachments):chat-preset.marinara.jsonandmemory-recall.marinara.jsonnow produce a clear "Unknown Marinara import type: " error instead of creating empty preset / lorebook rows..marinara.jsonfiles import cleanly; lorebooks open in the editor without theformTags.mapcrash..jsonlchat imports now appear under the conversation sidebar.Globalcount (5 of 32, matching the source) instead of marking every imported lorebook as global.Invalid collection nameerror; the prompt assembly fetches entries through the proper storage capability.Linked issue
Closes #1180
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.