[GH-ISSUE #1551] [Issue]: Reimporting a character embedded lorebook creates duplicate linked lorebooks #796

Closed
opened 2026-10-20 17:33:30 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1551

Originally assigned to: @Promansis on GitHub.

Summary

Reimporting a character's embedded lorebook creates a new linked lorebook every time instead of updating/reusing the existing linked lorebook.

Expected behavior

After a character's embedded lorebook has been imported once, clicking "Reimport Embedded Lorebook" or calling character_embedded_lorebook_import again should either update/replace the existing linked lorebook or clearly ask before creating a duplicate. The API's reimported field should accurately reflect the behavior.

Actual behavior

Native Tauri QA created a character with one embedded character_book entry. The first character_embedded_lorebook_import call created and linked a lorebook correctly. A second call created a second lorebook for the same character, moved the character metadata pointer to the new lorebook, left the previous lorebook behind, and still returned reimported: false.

Steps to reproduce

  1. Create or import a character whose data.character_book.entries contains at least one entry.
  2. Import the embedded lorebook from the character Lorebook tab, or call character_embedded_lorebook_import for that character id.
  3. Confirm the character gets data.extensions.importMetadata.embeddedLorebook.lorebookId pointing at the created lorebook.
  4. Import/reimport the embedded lorebook again.
  5. Query lorebooks where characterId or sourceCharacterId is the character id.
  6. Observe multiple linked lorebooks for the same embedded book, while the API reports reimported: false.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: origin/refactor at f120eb33
  • Run mode: Tauri desktop
  • OS + version: Windows desktop, exact version not captured
  • Node + pnpm versions: Node v24.16.0, pnpm 10.33.2
  • Rust version, if relevant: rustc 1.95.0
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No public screenshot needed. Native QA proof showed first import returning one lorebookId, second import returning a different lorebookId, and two lorebooks remaining with the same character id linkage.

Regression notes

Not checked against an older branch. Found during the Lorebooks native QA pass on the current refactor branch.

Additional context

Likely owner is src-tauri/src/commands/storage/exports.rs::import_character_embedded_lorebook(...). The current path appears to always create a new lorebooks record, then patches data.extensions.importMetadata.embeddedLorebook to the latest id.

Acceptance criteria:

  • Reimporting uses an explicit contract: update/replace the existing linked lorebook, or intentionally create a duplicate only through a user-visible duplicate action.
  • reimported is true when an existing embedded lorebook link is reused/replaced.
  • Existing stale linked lorebooks are not silently orphaned by the reimport path.
  • Add regression coverage for first import and reimport.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1551 Originally assigned to: @Promansis on GitHub. ## Summary Reimporting a character's embedded lorebook creates a new linked lorebook every time instead of updating/reusing the existing linked lorebook. ## Expected behavior After a character's embedded lorebook has been imported once, clicking "Reimport Embedded Lorebook" or calling `character_embedded_lorebook_import` again should either update/replace the existing linked lorebook or clearly ask before creating a duplicate. The API's `reimported` field should accurately reflect the behavior. ## Actual behavior Native Tauri QA created a character with one embedded `character_book` entry. The first `character_embedded_lorebook_import` call created and linked a lorebook correctly. A second call created a second lorebook for the same character, moved the character metadata pointer to the new lorebook, left the previous lorebook behind, and still returned `reimported: false`. ## Steps to reproduce 1. Create or import a character whose `data.character_book.entries` contains at least one entry. 2. Import the embedded lorebook from the character Lorebook tab, or call `character_embedded_lorebook_import` for that character id. 3. Confirm the character gets `data.extensions.importMetadata.embeddedLorebook.lorebookId` pointing at the created lorebook. 4. Import/reimport the embedded lorebook again. 5. Query lorebooks where `characterId` or `sourceCharacterId` is the character id. 6. Observe multiple linked lorebooks for the same embedded book, while the API reports `reimported: false`. ## Impact area - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `origin/refactor` at `f120eb33` - Run mode: Tauri desktop - OS + version: Windows desktop, exact version not captured - Node + pnpm versions: Node `v24.16.0`, pnpm `10.33.2` - Rust version, if relevant: `rustc 1.95.0` - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No public screenshot needed. Native QA proof showed first import returning one `lorebookId`, second import returning a different `lorebookId`, and two lorebooks remaining with the same character id linkage. ## Regression notes Not checked against an older branch. Found during the Lorebooks native QA pass on the current refactor branch. ## Additional context Likely owner is `src-tauri/src/commands/storage/exports.rs::import_character_embedded_lorebook(...)`. The current path appears to always create a new `lorebooks` record, then patches `data.extensions.importMetadata.embeddedLorebook` to the latest id. Acceptance criteria: - Reimporting uses an explicit contract: update/replace the existing linked lorebook, or intentionally create a duplicate only through a user-visible duplicate action. - `reimported` is true when an existing embedded lorebook link is reused/replaced. - Existing stale linked lorebooks are not silently orphaned by the reimport path. - Add regression coverage for first import and reimport. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:33:30 +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#796
No description provided.