mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #3348] [MERGED] fix(lorebooks): preserve nested folders on native import #5892
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#5892
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/3348
Author: @kolacheee
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3347-lorebook-folder-nesting-import📝 Commits (2)
df66f3efix(lorebooks): preserve nested folders on native import (#3347)b1d02d7Merge branch 'staging' into fix/3347-lorebook-folder-nesting-import📊 Changes
5 files changed (+48 additions, -14 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/db/schema/lorebooks.ts(+4 -3)📝
packages/server/src/services/import/marinara.importer.ts(+36 -6)📝
packages/server/src/services/storage/lorebooks.storage.ts(+2 -1)📝
packages/shared/src/schemas/lorebook.schema.ts(+5 -4)📄 Description
Linked issue
Closes #3347
Why this change
Lorebook folders can be nested — you drag one folder into another in the editor, the server validates the move with
canReparentFolder, andcloneFolderdeep-copies subtrees. A native (.marinara.json) lorebook export records every folder'sparentFolderId, so the nesting is present in the exported file. But the importer hardcodedparentFolderId: null, so on import every nested folder was flattened to the top level — silently losing structure the user built. This hits the standalone lorebook native round-trip (and any path throughimportLorebookPayload).What changed
packages/server/src/services/import/marinara.importer.ts— folder restore is now two passes: pass 1 creates every folder at root and builds the old→new id remap (a child can be listed before its parent, so parents can't be set inline); pass 2 re-parents each folder through the remap. Every move is validated withcanReparentFolder(the same guard the folderPATCHroute uses), so a malformed or hand-edited export can never persist a cycle — an unresolvable or cyclic parent just leaves that folder at root, matching the editor'sbuildFolderForestbehavior.db/schema/lorebooks.ts), the canonical shared Zod folder schema (packages/shared/src/schemas/lorebook.schema.ts),createFolderinlorebooks.storage.ts, and the importer. Nesting shipped after those comments were written.No schema or API change. Entries' folder assignment already round-tripped correctly (via the same
folderIdRemap) and is unchanged.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm --filter @marinara-engine/server lint(tsc). Fullpnpm checkis blocked on Windows by the pre-existing v2.1.0build.mjsexecPath spawn bug, which is unrelated to this change.folders, or folders withoutparentFolderId) still imports with all entries at root and no error.parentFolderIdimports without hanging — the cyclic folder lands at root.Docs and release impact
CHANGELOG updated with a Fixed entry. No version bump.
UI evidence (if applicable)
N/A — server-side import logic; no UI change.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.