[PR #3349] [MERGED] fix(lorebooks): stop exporting linked lorebooks in native format #5891

Closed
opened 2026-10-23 04:04:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3349
Author: @kolacheee
Created: 7/7/2026
Status: ✅ Merged
Merged: 7/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/3345-revert-linked-lorebook-export


📝 Commits (2)

  • 5488aa8 fix(lorebooks): stop exporting linked lorebooks in native format (#3345)
  • 7a25a09 Merge branch 'staging' into fix/3345-revert-linked-lorebook-export

📊 Changes

3 files changed (+23 additions, -90 deletions)

View changed files

📝 CHANGELOG.md (+1 -1)
📝 packages/server/src/routes/characters.routes.ts (+7 -53)
📝 packages/server/src/services/import/marinara.importer.ts (+15 -36)

📄 Description

Linked issue

Closes #3345

Why this change

#3342 made native Character/Persona export bundle every linked (assigned) lorebook and re-link it on import. Linked lorebooks are shared, standalone entities — they are not supposed to travel with a card in any format. The bundling forks a genuinely-shared lorebook into a private copy on every import (a "World Rules" book assigned to 3 characters becomes a fresh copy per imported character, while the original is untouched), and it exports an embedded lorebook twice (once as character_book, once as the bundle — the double-count reported in #3344). Only an embedded lorebook (data.character_book) should export with a card; the intended, user-driven way to bake a lorebook in is Embed into card (#3341 / #3343). Compatible export already carried only character_book, so this restores native export to match.

What changed

  • packages/server/src/routes/characters.routes.ts — removed the native-export lorebook bundling added in #3342: the createLorebooksStorage import, the LorebooksStore/NativeLorebookBundle types, the readAttachedLorebooksForCharacter / readAttachedLorebooksForPersona / readLorebookBundles helpers, the lorebooksStorage param + Promise.all entry + lorebooks spread in both native envelope builders, the module-level lorebooksStorage const, and all four call-site args. This file is now identical to its pre-#3342 state.
  • packages/server/src/services/import/marinara.importer.ts — removed importBundledLorebooks and its two call sites in importCharacter/importPersona, plus the owner-threading in importLorebookPayload (ownership links revert to being read from the lorebook's own exported fields, exactly as before #3342). Kept the harmless importLorebook → importLorebookPayload split so this change stays in a different region of the function than #3347's folder-nesting fix — avoiding a needless conflict between the two PRs.
  • CHANGELOG — dropped the "native … exports now include attached lorebooks" clause from #3342's (unreleased) 2.1.1 entry; the scene-preset clause is untouched.
  • Scene-preset and Connections-panel changes from #3342 live in client files and are not touched here.
  • Supersedes #3344 (the embedded double-count is one symptom of the same root cause).
  • Rebase note for reviewers: the in-flight embed PR #3343 adds an "Embed into card" endpoint to characters.routes.ts that reintroduces a module-level lorebooksStorage (+ createLorebooksStorage import). If #3345 merges first, #3343 rebases to re-add them; if #3343 merges first, #3345 keeps that const/import (still used by embed) and removes only the bundling. Called out so the merge order is intentional, not a mistake.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Server typecheck passes locally: pnpm --filter @marinara-engine/server lint (tsc). Full pnpm check is blocked on Windows by the pre-existing v2.1.0 build.mjs execPath spawn bug, unrelated to this change.
  • Manually verify: assign a shared lorebook to two characters, export character A in Native format, and confirm the .marinara.json no longer contains a top-level lorebooks bundle; import into a fresh instance and confirm no forked standalone lorebook is created.
  • Manually verify: a character with an embedded lorebook (character_book) still exports and re-imports its embedded book exactly once (no duplicate assigned row).
  • Manually verify: a native file exported during the #3342 window (which carries a lorebooks bundle) still imports the character/persona successfully, with the stray bundle simply ignored (no crash).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG updated (edited the #3342 2.1.1 entry). No version bump.

UI evidence (if applicable)

N/A — server-side export/import logic; no UI change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3349 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 7/7/2026 **Status:** ✅ Merged **Merged:** 7/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/3345-revert-linked-lorebook-export` --- ### 📝 Commits (2) - [`5488aa8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5488aa84be5a2835cc1e367b3138c1525cceca47) fix(lorebooks): stop exporting linked lorebooks in native format (#3345) - [`7a25a09`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7a25a09436ad48c15fe17845aa6f3b4af4ca98e8) Merge branch 'staging' into fix/3345-revert-linked-lorebook-export ### 📊 Changes **3 files changed** (+23 additions, -90 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -1) 📝 `packages/server/src/routes/characters.routes.ts` (+7 -53) 📝 `packages/server/src/services/import/marinara.importer.ts` (+15 -36) </details> ### 📄 Description ## Linked issue Closes #3345 ## Why this change #3342 made native Character/Persona export bundle every **linked (assigned)** lorebook and re-link it on import. Linked lorebooks are shared, standalone entities — they are not supposed to travel with a card in any format. The bundling forks a genuinely-shared lorebook into a private copy on every import (a "World Rules" book assigned to 3 characters becomes a fresh copy per imported character, while the original is untouched), and it exports an embedded lorebook **twice** (once as `character_book`, once as the bundle — the double-count reported in #3344). Only an embedded lorebook (`data.character_book`) should export with a card; the intended, user-driven way to bake a lorebook in is **Embed into card** (#3341 / #3343). Compatible export already carried only `character_book`, so this restores native export to match. ## What changed - `packages/server/src/routes/characters.routes.ts` — removed the native-export lorebook bundling added in #3342: the `createLorebooksStorage` import, the `LorebooksStore`/`NativeLorebookBundle` types, the `readAttachedLorebooksForCharacter` / `readAttachedLorebooksForPersona` / `readLorebookBundles` helpers, the `lorebooksStorage` param + `Promise.all` entry + `lorebooks` spread in both native envelope builders, the module-level `lorebooksStorage` const, and all four call-site args. This file is now identical to its pre-#3342 state. - `packages/server/src/services/import/marinara.importer.ts` — removed `importBundledLorebooks` and its two call sites in `importCharacter`/`importPersona`, plus the `owner`-threading in `importLorebookPayload` (ownership links revert to being read from the lorebook's own exported fields, exactly as before #3342). Kept the harmless `importLorebook → importLorebookPayload` split so this change stays in a different region of the function than #3347's folder-nesting fix — avoiding a needless conflict between the two PRs. - CHANGELOG — dropped the "native … exports now include attached lorebooks" clause from #3342's (unreleased) 2.1.1 entry; the scene-preset clause is untouched. - Scene-preset and Connections-panel changes from #3342 live in client files and are **not** touched here. - Supersedes #3344 (the embedded double-count is one symptom of the same root cause). - Rebase note for reviewers: the in-flight embed PR #3343 adds an "Embed into card" endpoint to `characters.routes.ts` that reintroduces a module-level `lorebooksStorage` (+ `createLorebooksStorage` import). If #3345 merges first, #3343 rebases to re-add them; if #3343 merges first, #3345 keeps that const/import (still used by embed) and removes only the bundling. Called out so the merge order is intentional, not a mistake. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Server typecheck passes locally: `pnpm --filter @marinara-engine/server lint` (tsc). Full `pnpm check` is blocked on Windows by the pre-existing v2.1.0 `build.mjs` execPath spawn bug, unrelated to this change. - Manually verify: assign a shared lorebook to two characters, export character A in **Native** format, and confirm the `.marinara.json` no longer contains a top-level `lorebooks` bundle; import into a fresh instance and confirm no forked standalone lorebook is created. - Manually verify: a character with an **embedded** lorebook (`character_book`) still exports and re-imports its embedded book exactly once (no duplicate assigned row). - Manually verify: a native file exported during the #3342 window (which carries a `lorebooks` bundle) still imports the character/persona successfully, with the stray bundle simply ignored (no crash). ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG updated (edited the #3342 2.1.1 entry). No version bump. ## UI evidence (if applicable) N/A — server-side export/import logic; no UI change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:04:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5891
No description provided.