mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2602] [MERGED] feat(lorebooks): nested folders #5686
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#5686
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/2602
Author: @kolacheee
Created: 6/17/2026
Status: ✅ Merged
Merged: 6/18/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/staging-nested-lorebook-folders📝 Commits (10+)
dedf986feat(lorebooks): nested folders — server unblock + cycle guard8ca8af7feat(lorebooks): nested folders — client tree UI + ancestor-aware disable600f730feat(lorebooks): drag-to-nest folders — three-zone drag + root un-nest5dab11afeat(lorebooks): clone a folder — deep copy of sub-folders and entries916fa1dfix(lorebooks): drop entries into the innermost folder under the cursorc7cb2b9fix(lorebooks): arm folder drag synchronously so it reliably starts2688826fix(lorebooks): nest a dragged folder when dropped into another folder's bodybe3cddafix(lorebooks): stop the un-nest strip from cancelling nested-folder dragsc039951fix(lorebooks): un-nest a subfolder by dragging it down into its parent's bodyb9377d4fix(lorebooks): un-nest a folder dropped onto the root-entries area📊 Changes
10 files changed (+850 additions, -202 deletions)
View changed files
📝
packages/client/src/components/lorebooks/LorebookEditor.tsx(+320 -156)📝
packages/client/src/components/lorebooks/LorebookFolderRow.tsx(+112 -10)📝
packages/client/src/components/ui/AppDialogRenderer.tsx(+30 -15)📝
packages/client/src/hooks/use-lorebooks.ts(+16 -2)📝
packages/client/src/lib/app-dialogs.ts(+21 -1)📝
packages/client/src/stores/dialog.store.ts(+2 -0)📝
packages/server/src/routes/lorebooks.routes.ts(+37 -10)📝
packages/server/src/services/storage/lorebooks.storage.ts(+120 -8)📝
packages/shared/src/index.ts(+1 -0)➕
packages/shared/src/utils/lorebook-folder-tree.ts(+191 -0)📄 Description
Linked issue
Closes #2582
Why this change
Lorebook folders are flat today. The data layer was already stubbed for nesting (the
parent_folder_idcolumn,LorebookFolder.parentFolderId, and the Zod schemas all exist) but the routes deliberately rejected any non-null parent with a 400. This finishes the feature so users can organize large lorebooks hierarchically (folders within folders).What changed
Shared
utils/lorebook-folder-tree.ts(new) — one source of truth for server + client:canReparentFolder(no self-parent, same-lorebook, no descendant cycle via an upward parent-walk; no depth limit),buildFolderForest(flat rows → tree; a dangling/cyclic parent falls back to root),collectHiddenFolderIds(collapse hides the subtree),collectEffectivelyDisabledFolderIds(a disabled ancestor gates its descendants).Server
lorebooks.routes.ts— removed the two400 "Nested folders not supported"guards. Create now requires the parent to exist in the lorebook; move (PATCH) runscanReparentFolderand returns the specific reason on rejection.lorebooks.storage.tsremoveFolder— deleting a folder promotes its direct child folders to root (parentFolderId = null), mirroring how entries already reparent. No cascade.lorebooks.storage.tscloneFolder+POST /:id/folders/:folderId/clone— deep-clones a folder, its entries, and its whole sub-folder subtree into the same lorebook, as a sibling of the original. Folders are recreated top-down (each parent before its children); entries are then copied into the mapped new folders. ReusescreateFolder/createEntry; a seen-guard makes a malformed cycle safe.Client
LorebookEditorrenders the folder forest recursively (indent + collapse-hides-subtree + disabled-ancestor propagation; per-render cycle guard).LorebookFolderRowgained a parent-folder dropdown, filtered throughcanReparentFolderso invalid (self / descendant / cross-lorebook) targets never appear.lorebooks.storage.ts) usescollectEffectivelyDisabledFolderIds, so a disabled parent gates entries in its enabled children.canReparentFolder) and is re-checked at drop; it draws an amber ring on the target. Reparenting reuses the existing folder PATCH (no new endpoint); entry-move drag is unchanged.useCloneLorebookFolder, Copy icon beside delete) — one click deep-copies the folder and its whole subtree; only the root copy is renamed "(Copy)".Re-parenting is available two ways: the per-row parent dropdown, or drag-to-nest (above). Nesting depth is unlimited.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
canReparentFolderguard runs server-side).Docs and release impact
UI evidence (if applicable)
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.