[GH-ISSUE #3359] [Issue]: No way to unembed a character lorebook; 🗑️ only unlinks; "Edit Linked Lorebook" edits the embedded copy #1818

Closed
opened 2026-10-21 05:42:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Jul 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3359

Originally assigned to: @kolacheee on GitHub.

Summary

The Character editor's Lorebook tab has no way to unembed a lorebook, and its embedded-vs-linked affordances are confusing. Once a lorebook is embedded in a card (data.character_book), the row's 🗑️ button only unlinks the standalone copy — it does not clear character_book, so the embedded lorebook silently persists in the card (still listed, still exports). Separately, "Edit Linked Lorebook" opens the standalone mirror, which — because it is kept in sync with character_book — reads as "editing the embedded lorebook," so the linked-vs-embedded distinction is unclear.

Expected behavior

  • A clear, in-editor way to remove an embedded lorebook from the card (clear character_book), available whenever character_book is present.
  • The 🗑️ / "Remove" affordance on an Embedded row should either also remove the embedded copy, or clearly communicate that it only unlinks the standalone and the baked-in copy remains.
  • Button labels that make the embedded-vs-linked distinction obvious.

Actual behavior

  1. No unembed affordance. Clicking 🗑️ on an "Embedded" lorebook row runs the unassign path (unassignLorebook in packages/client/src/components/lorebooks/LorebookAssignmentSection.tsx), which just removes the character from the standalone's characterIds. It never clears character_book. The embedded lorebook persists — its entries still render below ("World-building entries embedded in this character…") and it still exports with the card — yet the toast says "Removed ", implying full removal.

    • The only code path that clears character_book is clearCharacterEmbeddedLorebook, and it is triggered solely by fully deleting the standalone lorebook from the Lorebooks panel (packages/server/src/routes/lorebooks.routes.ts:496). That is non-obvious, and impossible when the character has an embedded character_book but no standalone — e.g. a freshly-imported card whose embedded book was never "imported," or (per #2 below) after unlinking — leaving an orphaned embedded book with no removal path at all.
  2. Confusing dead state after unlink. After the 🗑️ unlink, the forward pointer (extensions.importMetadata.embeddedLorebook.lorebookId) still points at the now-unlinked standalone, so "Reimport Embedded Lorebook" + "Edit Linked Lorebook" still appear and the embedded entries still show as Active — even though nothing injects them anymore (the standalone is no longer linked to this character, and character_book is inert at runtime).

  3. "Edit Linked Lorebook" naming. The button opens the standalone lorebook (openLorebookDetail(linkedLorebookId) in packages/client/src/components/characters/CharacterEditor.tsx), which is a synced mirror of character_book. Editing it effectively edits the embedded content, so the "Linked" label vs. the section's "embedded in this character" framing is muddled — users can't tell whether they are editing the linked standalone or the baked-in copy.

Steps to reproduce

  1. Import a character card carrying an embedded lorebook (character_book), or embed one via Embed into card.
  2. Click Import Embedded Lorebook so a standalone linked mirror exists (the row shows an Embedded badge, plus Reimport Embedded Lorebook / Edit Linked Lorebook).
  3. Click the row's 🗑️. → Toast "Removed "; the row leaves the assigned list — but the embedded entries still render below and the Reimport/Edit-Linked buttons persist. The embedded lorebook is still in the card and still exports, and there is no button to actually remove it.

Environment

  • Marinara Engine version: 2.1.1 (staging)
  • Install type: source
  • OS + version: Windows 11
  • Browser or app shell: web app

Logs, screenshots, or video

Before/after screenshots of clicking 🗑️ on the "Embedded" row: the row is removed from the assigned list but the embedded entries (Kaz: Speech, Instruction, Kaz: Expressions) and the Reimport/Edit-Linked buttons persist. (Attach on the GitHub issue.)

Additional context

This is a UX/labeling problem, not a data-integrity / double-injection bug. Verified in code: an embedded character_book is inert at generation time — no prompt-assembly or activation path reads it. The runtime lorebook scan (listActiveEntries in packages/server/src/services/storage/lorebooks.storage.ts, invoked from packages/server/src/services/lorebook/index.ts) reads only the standalone lorebooks / lorebookEntries tables filtered by owner links; the assembler never touches character_book. So when a lorebook is BOTH embedded and linked, a keyword match injects exactly once (from the standalone) — the embedded copy never double-injects. The problem is purely that users cannot cleanly remove/manage the embedded copy and the linked-vs-embedded labels are ambiguous.

One adjacent edge case surfaced while verifying the above (worth designing against in the same pass, though not the reported symptom): the single-standalone guarantee relies on the forward pointer importMetadata.embeddedLorebook.lorebookId surviving. If that pointer is ever dropped while a standalone still exists — e.g. a dirty-editor save that shallow-merges data and replaces extensions.importMetadata wholesale — then clicking Import Embedded Lorebook again would create a second standalone (st-lorebook.importer.ts:405-406), and two standalones would then genuinely double-inject. That is a duplicate-standalone bug, not the embedded copy activating — but the same "add an explicit unembed + tighten pointer handling" work would address it.

Suggested direction:

  • Add an explicit Remove from card / Unembed action that clears character_book + the forward pointer (reuse clearCharacterEmbeddedLorebook or add a dedicated DELETE …/embedded-lorebook endpoint), available whenever character_book is present — including the orphaned no-standalone case.
  • On an Embedded row, disambiguate 🗑️ (e.g. offer both "Unlink standalone" and "Remove from card", or make "Remove" clear the embedded copy with a warning).
  • Rename Edit Linked Lorebook to make the sync relationship explicit (e.g. "Edit Embedded Lorebook", since edits sync back to character_book), or spell out the relationship in the helper text.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Jul 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3359 Originally assigned to: @kolacheee on GitHub. ## Summary The Character editor's **Lorebook** tab has no way to *unembed* a lorebook, and its embedded-vs-linked affordances are confusing. Once a lorebook is embedded in a card (`data.character_book`), the row's 🗑️ button only **unlinks the standalone copy** — it does not clear `character_book`, so the embedded lorebook silently persists in the card (still listed, still exports). Separately, **"Edit Linked Lorebook"** opens the standalone mirror, which — because it is kept in sync with `character_book` — reads as "editing the embedded lorebook," so the linked-vs-embedded distinction is unclear. ## Expected behavior - A clear, in-editor way to **remove an embedded lorebook from the card** (clear `character_book`), available whenever `character_book` is present. - The 🗑️ / "Remove" affordance on an **Embedded** row should either also remove the embedded copy, or clearly communicate that it only unlinks the standalone and the baked-in copy remains. - Button labels that make the embedded-vs-linked distinction obvious. ## Actual behavior 1. **No unembed affordance.** Clicking 🗑️ on an "Embedded" lorebook row runs the *unassign* path (`unassignLorebook` in `packages/client/src/components/lorebooks/LorebookAssignmentSection.tsx`), which just removes the character from the standalone's `characterIds`. It never clears `character_book`. The embedded lorebook persists — its entries still render below ("World-building entries embedded in this character…") and it still exports with the card — yet the toast says "Removed <name>", implying full removal. - The **only** code path that clears `character_book` is `clearCharacterEmbeddedLorebook`, and it is triggered *solely* by fully **deleting** the standalone lorebook from the Lorebooks panel (`packages/server/src/routes/lorebooks.routes.ts:496`). That is non-obvious, and impossible when the character has an embedded `character_book` but **no** standalone — e.g. a freshly-imported card whose embedded book was never "imported," or (per #2 below) after unlinking — leaving an orphaned embedded book with no removal path at all. 2. **Confusing dead state after unlink.** After the 🗑️ unlink, the forward pointer (`extensions.importMetadata.embeddedLorebook.lorebookId`) still points at the now-unlinked standalone, so "Reimport Embedded Lorebook" + "Edit Linked Lorebook" still appear and the embedded entries still show as **Active** — even though nothing injects them anymore (the standalone is no longer linked to this character, and `character_book` is inert at runtime). 3. **"Edit Linked Lorebook" naming.** The button opens the standalone lorebook (`openLorebookDetail(linkedLorebookId)` in `packages/client/src/components/characters/CharacterEditor.tsx`), which is a synced mirror of `character_book`. Editing it effectively edits the embedded content, so the "Linked" label vs. the section's "embedded in this character" framing is muddled — users can't tell whether they are editing the linked standalone or the baked-in copy. ## Steps to reproduce 1. Import a character card carrying an embedded lorebook (`character_book`), or embed one via **Embed into card**. 2. Click **Import Embedded Lorebook** so a standalone linked mirror exists (the row shows an **Embedded** badge, plus **Reimport Embedded Lorebook** / **Edit Linked Lorebook**). 3. Click the row's 🗑️. → Toast "Removed <name>"; the row leaves the assigned list — **but** the embedded entries still render below and the Reimport/Edit-Linked buttons persist. The embedded lorebook is still in the card and still exports, and there is no button to actually remove it. ## Environment - Marinara Engine version: 2.1.1 (staging) - Install type: source - OS + version: Windows 11 - Browser or app shell: web app ## Logs, screenshots, or video Before/after screenshots of clicking 🗑️ on the "Embedded" row: the row is removed from the assigned list but the embedded entries (Kaz: Speech, Instruction, Kaz: Expressions) and the Reimport/Edit-Linked buttons persist. (Attach on the GitHub issue.) ## Additional context **This is a UX/labeling problem, not a data-integrity / double-injection bug.** Verified in code: an embedded `character_book` is **inert** at generation time — no prompt-assembly or activation path reads it. The runtime lorebook scan (`listActiveEntries` in `packages/server/src/services/storage/lorebooks.storage.ts`, invoked from `packages/server/src/services/lorebook/index.ts`) reads only the standalone `lorebooks` / `lorebookEntries` tables filtered by owner links; the assembler never touches `character_book`. So when a lorebook is BOTH embedded and linked, a keyword match injects exactly **once** (from the standalone) — the embedded copy never double-injects. The problem is purely that users cannot cleanly remove/manage the embedded copy and the linked-vs-embedded labels are ambiguous. One adjacent edge case surfaced while verifying the above (worth designing against in the same pass, though not the reported symptom): the single-standalone guarantee relies on the forward pointer `importMetadata.embeddedLorebook.lorebookId` surviving. If that pointer is ever dropped while a standalone still exists — e.g. a dirty-editor save that shallow-merges `data` and replaces `extensions.importMetadata` wholesale — then clicking **Import Embedded Lorebook** again would `create` a **second** standalone (`st-lorebook.importer.ts:405-406`), and *two* standalones would then genuinely double-inject. That is a duplicate-standalone bug, not the embedded copy activating — but the same "add an explicit unembed + tighten pointer handling" work would address it. Suggested direction: - Add an explicit **Remove from card / Unembed** action that clears `character_book` + the forward pointer (reuse `clearCharacterEmbeddedLorebook` or add a dedicated `DELETE …/embedded-lorebook` endpoint), available whenever `character_book` is present — including the orphaned no-standalone case. - On an **Embedded** row, disambiguate 🗑️ (e.g. offer both "Unlink standalone" and "Remove from card", or make "Remove" clear the embedded copy with a warning). - Rename **Edit Linked Lorebook** to make the sync relationship explicit (e.g. "Edit Embedded Lorebook", since edits sync back to `character_book`), or spell out the relationship in the helper text. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:42:59 +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#1818
No description provided.