mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2353] [MERGED] feat: nested lorebook folders #5555
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#5555
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/2353
Author: @kolacheee
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Xelvanis
Base:
refactor← Head:feat/lorebook-nested-folders📝 Commits (8)
15687d7feat: nested lorebook folders713a0ffAddress nested-folder review feedback80ea2acValidate lorebook folder ancestry at the storage path087f521Refine lorebook folder validation and forest rescue from review490a9d5Make a lorebook folder's lorebookId immutable on patchdc9ec7bAddress lorebook folder review findings9b2153aFix lorebook folder source reorder2ea62e5Tighten lorebook folder test fixtures📊 Changes
15 files changed (+1275 additions, -334 deletions)
View changed files
📝
src-tauri/src/commands/storage/commands/entities.rs(+647 -84)📝
src-tauri/src/http_dispatch.rs(+19 -0)📝
src-tauri/src/lib.rs(+1 -0)📝
src/engine/contracts/schemas/lorebook.schema.ts(+5 -3)📝
src/engine/contracts/types/lorebook.ts(+12 -10)📝
src/engine/generation/active-lorebook-scanner.ts(+37 -6)📝
src/features/catalog/lorebooks/components/editor/LorebookEditor.tsx(+19 -6)📝
src/features/catalog/lorebooks/components/editor/LorebookEntriesTab.tsx(+165 -137)📝
src/features/catalog/lorebooks/components/editor/use-lorebook-editor-drag-drop.ts(+133 -32)📝
src/features/catalog/lorebooks/components/editor/use-lorebook-entry-selection.ts(+13 -3)📝
src/features/catalog/lorebooks/components/entries/LorebookFolderRow.tsx(+71 -37)📝
src/features/catalog/lorebooks/hooks/use-lorebooks.ts(+22 -16)➕
src/features/catalog/lorebooks/lib/lorebook-folder-tree.ts(+119 -0)➕
src/shared/api/lorebook-folder-api.ts(+11 -0)📝
src/shared/api/remote-runtime.ts(+1 -0)📄 Description
Linked issue
Closes #2127 — this is the nested-folders half. (The intra-lorebook entry-duplication half shipped earlier in #2157.)
Why this change
parentFolderIdexisted but was reserved/always-null. This ships nesting end-to-end: organize a lorebook's folders into a tree, set parentage by dropdown or drag, and (the load-bearing part) extend the folder-disabled activation gate to disabled ancestors, so nesting can never silently leak gated content into the prompt.What changed
active-lorebook-scanner.ts) — activation now resolves "effective disabled" by walking each entry's folderparentFolderIdchain (with a cycle guard): a folder OR any of its ancestors being disabled gates the entry, regardless of the entry's own flag.lib/lorebook-folder-tree.ts) —canReparentFolderis the single write-time guard (same lorebook, no self-parent, no cycles, with reasons);buildFolderForestgroups folders into{ roots, childrenByParent }for rendering. A dangling/missing parent falls back to root, which auto-promotes a deleted folder's children to the top level.hooks/use-lorebooks.ts) —reorderLorebookFolderscan now also setparentFolderId, so nest/un-nest + per-parent ordering happen in one pass; reorder/reparent invalidates the activation cache.LorebookEntriesTab.tsx); a per-folder parent dropdown filtered to valid parents (LorebookFolderRow.tsx); drag-to-nest via the header (top = reorder before, middle = nest, bottom = reorder after) and via a folder's body including the empty placeholder, with the left-indent margin targeting shallower ancestors; drag to the root area to un-nest (use-lorebook-editor-drag-drop.ts,LorebookEditor.tsx).Refactor impact
Primary owner: Catalog / Lorebooks editor (frontend), plus the activation scanner (engine generation)
Impact areas reviewed:
src-tauri/src/lib.rschange.Boundary notes:
canReparentFolderas the one write-time guard and the existing generic storage gateway; no new storage collection, command, or cross-boundary path.Pressure points touched:
ModeSurface/GameSurface/shared mode UI, nosrc-tauri/src/lib.rs, no imports, no version-bearing files.Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses before PR push/handoffManual verification notes
pnpm typecheckpluscheck:architecture/check:frontend/check:rust/check:discovery/check:docs/check:launcher-safety/check:unusedall pass locally.check:line-endingsfails only on pre-existing CRLF in files this PR doesn't touch (DESIGN.md,custom_components/*.py); their committed versions are LF, so CI is unaffected.Feature Discoverability
src/features/shell/discovery/because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.Reason:
lorebooksdiscovery entry opens the panel). The registry is surface-level, not per-action, so no new entry is required andcheck:discoverypasses unchanged (same call as the entry-duplication PR #2157).Docs and release impact
README.mdCONTRIBUTING.mddocs/developer/AGENTS.mdProof
Core claim:
Verification run:
Evidence:
*.test.ts, and the template asks not to submit them as proof) cover the scanner's ancestor chain-walk and thecanReparentFolder/buildFolderForestedge cases (self, cross-lorebook, direct + deep cycles, dangling-parent→root). Happy to fold them in if the team wants them tracked.Design notes (recorded for review):
canReparentFolderruns client-side because the lorebook-folder collection is stored generically with no server-side field validation — matching how every other lorebook edit is validated. The activation scanner independently resolves disabled ancestors and guards against cycles at read time, so a malformed parent introduced by an import or a direct write can never hang generation or leak gated content. If the lorebook layer later moves into Rust, the same three checks (same lorebook, no self-parent, no cycle) port directly.buildFolderForest) rather than cascade-deleting — consistent with how an entry whose folder is gone falls back to root.Manual verification requested:
UI evidence
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.