mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#5962
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/3497
Author: @kolacheee
Created: 7/11/2026
Status: ✅ Merged
Merged: 7/11/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3483-lorebook-folder-nesting📝 Commits (2)
3921490fix(lorebooks): preserve folder nesting in legacy profile import and the mari CLIac1ec17fix(lorebooks): validate folder graph in legacy import and document --folder-id in group help📊 Changes
3 files changed (+69 additions, -10 deletions)
View changed files
📝
packages/server/src/routes/backup.routes.ts(+38 -1)📝
packages/server/src/services/mari-db/mari-db.service.ts(+25 -5)📝
packages/shared/src/types/lorebook.ts(+6 -4)📄 Description
Linked issue
Fixes #3483
Why this change
Nested lorebook folders shipped in #2602, but two code paths still silently flatten or drop folder placement, and the shared type contract still tells every reader (human or agent) that folders are flat. That stale contract is exactly the comment class that caused #3348. This PR makes all three tell the truth: the legacy import preserves nesting, the Mari CLI can place entries in folders, and the JSDoc describes the live behavior.
What changed
packages/server/src/routes/backup.routes.ts— the legacy (pre-snapshot) branch ofPOST /import-profilecreated every folder withparentFolderId: nulleven though it already built the old→newfolderIdMap. Added a second pass that remaps parents through the fully-populated map, mirroring the exact two-pass pattern the preset-group import in the same handler already uses (including per-item try/catch and the lorebook-scopedupdateFolderoverload).packages/server/src/services/mari-db/mari-db.service.ts—mari lorebooks add-entry/update-entrynever read or assignedfolderId, so folder placement was silently dropped. Both now accept--folder-id, validated against the entry's lorebook via the samegetRawById(getMeta(...))pattern the handlers already use (unknown folder = clear error, no dangling FK written);update-entry --folder-id noneclears placement. Usage strings updated.packages/shared/src/types/lorebook.ts— theLorebookFolderJSDoc claimed "Folders are flat in v1 … the server rejects non-null values" whilelorebooks.routes.ts:752-773validates and re-parents nested folders. Both comments now describe the live contract (parent must exist in the same lorebook; self-parent and cycles rejected viacanReparentFolder).Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Runtime-validated end to end against a scratch server (fresh
DATA_DIR, port 7899), exercising the real routes and the real CLI rather than unit stubs:marinara_profile(nofileStoragesnapshot, so it takes the legacy branch) containing a three-level folder chain (Parent → Child → Grandchild) plus an entry in the grandchild. After import,GET /api/lorebooks/:id/foldersshows the chain intact with remapped ids (Child.parentFolderId= new Parent id,Grandchild.parentFolderId= new Child id) and the entry'sfolderIdpointing at the new grandchild. Before this fix, all three parents were hardcoded null.mari lorebooks add-entry <id> --folder-id <grandchild> --applyplaces the entry (verified via the entries endpoint);--folder-id not-a-real-folderis rejected with "Folder … not found in lorebook …" and writes nothing;update-entry --folder-id <parent>moves the entry and--folder-id noneclears it to null (each state verified after the call).Docs and release impact
(The in-app lorebook docs already describe nested folders; this PR makes the code and contracts match them.)
UI evidence (if applicable)
N/A — server-side import/CLI behavior; the folder tree UI is unchanged.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.