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#5889
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/3343
Author: @kolacheee
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/3341-embed-lorebook-into-card📝 Commits (5)
aaa00a9feat(lorebooks): embed a linked character lorebook into the card (#3341)97f67a5fix(lorebooks): harden embed-lorebook from adversarial review (#3341)62524d5Merge branch 'staging' into feat/3341-embed-lorebook-into-card763f75dMerge branch 'staging' into feat/3341-embed-lorebook-into-carddfc2437Address embedded lorebook review feedback📊 Changes
6 files changed (+362 additions, -25 deletions)
View changed files
📝
packages/client/src/components/characters/CharacterEditor.tsx(+72 -7)📝
packages/client/src/components/lorebooks/LorebookAssignmentSection.tsx(+69 -2)📝
packages/client/src/hooks/use-lorebooks.ts(+16 -0)📝
packages/server/src/routes/characters.routes.ts(+75 -0)📝
packages/server/src/routes/lorebooks.routes.ts(+8 -6)📝
packages/server/src/services/lorebook/character-book-sync.ts(+122 -10)📄 Description
Linked issue
Closes #3341.
Why this change
Character cards can carry an embedded lorebook (V2
data.character_book) that exports with the card, but there was no way to create that from inside Marinara. A lorebook attached via Assign Lorebook is only linked — a separate row referenced by the character — and linked lorebooks are not written into the card, so they get dropped on export (/characters/:id/exportserializescharDataas-is). The only characters that exported with a working lorebook were ones imported with an embedded book already; anything you authored couldn't be shared as a self-contained card.What changed
Adds an "Embed into card" action — the inverse of the existing Import Embedded Lorebook (card → standalone). After embedding, the lorebook exports with the character (native + compatible) and future
/lorebooksedits keep the embedded copy in sync, exactly like an imported embedded book.Server
character-book-sync.ts: export the existingtoCharacterBook; addembedLorebookIntoCharacter(writescharacter_book+ theextensions.importMetadata.embeddedLorebookforward pointer in one atomic,skipVersionSnapshotupdate) andresolveEmbeddedCharacterId.POST /characters/:id/embedded-lorebook/embedwith guards: reject persona / non-character-category books (400); refuse to clobber a different embedded book in the singlecharacter_bookslot (409); additively union the character into the lorebook's links (never a bare replace) so it auto-activates and stays syncable. Returns the writtencharacter_book.Latent bug fixed in the same area (this touches the recently-fixed embedded-lorebook sync — #554/#1551/#2971):
syncCharacterBookFromLorebookand the lorebookDELETEresolved the target character from the lorebook's hydratedcharacterId, which is only the alphabetically-first linked character — wrong for a book linked to several characters. Both now resolve the embedding character via the authoritative forward pointer (resolveEmbeddedCharacterId). It's fast-path-first (the derived id, identical to the old behaviour on the common single-link path) and only scans the characters table when the book has >1 character link — so world / single-linked lorebook edits stay scan-free.Client
useEmbedLorebookhook.formDatafrom the returnedcharacter_bookso a dirty editor's next Save can't revert the embed.Hardening from an adversarial self-review (2nd commit)
formDataon embed.parseCharacterDataistry/catch-guarded so a corrupt character row can't 500 a lorebook delete.Accepted limitation (documented, not silent)
There's no reverse lorebook→characters index, so two cards can each embed the same standalone book (e.g. via character duplication, or embedding a book already embedded elsewhere). Each keeps its own
character_booksnapshot; a later entry edit refreshes the first forward-pointer match, so a second card's copy can drift until its Refresh. This matches the pre-existing multi-embed behaviour; a real exclusivity index is follow-up scope.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Done by the agent:
tsc -b ../shared && tsc --noEmit), shared typecheck, client build (tsc -b && vite build), and client ESLint all pass.pnpm checkcurrently fails at the server build step on Windows — a pre-existing v2.1.0 bug inpackages/server/scripts/build.mjs(spawns Node via an unquoted"C:\Program Files\…"path), reproduced on cleanstagingwith this branch's changes stashed. Not caused by this PR; flagged separately.Still needs manual verification (no automated server test suite in-repo):
character_bookhas 3 entries; export the card → the lorebook is present.character_bookreflects the edit.character_book(regression: the old code synced to Y).character_bookand pointer are cleared.Docs and release impact
UI evidence (if applicable)
New per-lorebook affordance on the character Lorebook tab: Embed into card → Embedded + Refresh. No other visual change. (Screenshots to be added on manual verification.)
Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.