[PR #2587] [MERGED] feat(lorebooks): duplicate lorebook entry #5673

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

📋 Pull Request Information

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

Base: staging ← Head: feat/staging-duplicate-lorebook-entry


📝 Commits (3)

  • d325599 feat(lorebooks): duplicate lorebook entry
  • eb8cdff fix(lorebooks): duplicate from current row state to avoid stale clone
  • 6d9b3df Guard lorebook entry duplication during edits

📊 Changes

2 files changed (+76 additions, -1 deletions)

View changed files

📝 packages/client/src/components/lorebooks/LorebookEntryRow.tsx (+56 -1)
📝 packages/client/src/hooks/use-lorebooks.ts (+20 -0)

📄 Description

Linked issue

Closes #2578

Why this change

  • Re-creating a near-identical lorebook entry by hand — re-typing its keys, filters, injection/activation settings, and content — is tedious. A one-click Duplicate is a pure QoL win and fully additive (no existing behavior changes). Ports the entry-duplication feature from refactor #2157.

What changed

  • useDuplicateLorebookEntry (hooks/use-lorebooks.ts) — clones an entry through the existing POST /lorebooks/:id/entries create path. The create schema drops server-managed id/createdAt/updatedAt and the route re-derives lorebookId, so the name gets a " (Copy)" suffix and every other field carries over verbatim (keys/secondaryKeys, all character/tag/trigger filters, position/depth/order, probability, timing, grouping, role, embedding, activation conditions). Invalidates the same queries as useCreateLorebookEntry.
  • Duplicate button (components/lorebooks/LorebookEntryRow.tsx) — a Copy-icon button in the per-row actions, immediately left of delete. Mirrors delete's hover-reveal pattern (always visible on mobile), neutral styling, disabled while the clone is in flight.

No backend changes — lorebook entries have no managed on-disk asset, so duplication is a pure client-side row clone over the existing create endpoint.

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

  • tsc -b + ESLint pass for the client.
  • opened a lorebook with an entry that has keys/filters/content set, clicked the new Copy button, and confirmed a "… (Copy)" entry appears with all those fields carried over
  • confirmed the original is untouched and the button is disabled mid-clone.

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)

Assessment: additive QoL — no docs/version changes expected.

UI evidence (if applicable)

Screenshots to follow.

{24689666-1BA3-4B65-B4B7-D590DE57520E} {CCCA7CB8-6305-422F-B8B6-1A523979D03E}

Summary by CodeRabbit

Release Notes

  • New Features
    • Users can now duplicate lorebook entries directly from the entry row. Duplicated entries automatically append "(Copy)" to the original name while preserving all other details. The duplicate button appears on hover or in mobile view and is disabled while the operation is processing.

🔄 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/2587 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 6/16/2026 **Status:** ✅ Merged **Merged:** 6/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/staging-duplicate-lorebook-entry` --- ### 📝 Commits (3) - [`d325599`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d3255991d4afcc0799b1341e2641b9018f74cbf0) feat(lorebooks): duplicate lorebook entry - [`eb8cdff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eb8cdff121b2a5fe78462eba72374f3321a0338e) fix(lorebooks): duplicate from current row state to avoid stale clone - [`6d9b3df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d9b3df4621d683569306b645e81c1dd8e6a8c17) Guard lorebook entry duplication during edits ### 📊 Changes **2 files changed** (+76 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/lorebooks/LorebookEntryRow.tsx` (+56 -1) 📝 `packages/client/src/hooks/use-lorebooks.ts` (+20 -0) </details> ### 📄 Description ## Linked issue Closes #2578 ## Why this change - Re-creating a near-identical lorebook entry by hand — re-typing its keys, filters, injection/activation settings, and content — is tedious. A one-click **Duplicate** is a pure QoL win and fully additive (no existing behavior changes). Ports the entry-duplication feature from `refactor` #2157. ## What changed - **`useDuplicateLorebookEntry`** (`hooks/use-lorebooks.ts`) — clones an entry through the existing `POST /lorebooks/:id/entries` create path. The create schema drops server-managed `id`/`createdAt`/`updatedAt` and the route re-derives `lorebookId`, so the name gets a `" (Copy)"` suffix and **every other field carries over verbatim** (keys/secondaryKeys, all character/tag/trigger filters, position/depth/order, probability, timing, grouping, role, embedding, activation conditions). Invalidates the same queries as `useCreateLorebookEntry`. - **Duplicate button** (`components/lorebooks/LorebookEntryRow.tsx`) — a `Copy`-icon button in the per-row actions, immediately left of delete. Mirrors delete's hover-reveal pattern (always visible on mobile), neutral styling, disabled while the clone is in flight. **No backend changes** — lorebook entries have no managed on-disk asset, so duplication is a pure client-side row clone over the existing create endpoint. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - `tsc -b` + ESLint pass for the client. - opened a lorebook with an entry that has keys/filters/content set, clicked the new Copy button, and confirmed a `"… (Copy)"` entry appears with all those fields carried over - confirmed the original is untouched and the button is disabled mid-clone. ## Docs and release impact - [x] 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) Assessment: additive QoL — no docs/version changes expected. ## UI evidence (if applicable) Screenshots to follow. <img width="616" height="89" alt="{24689666-1BA3-4B65-B4B7-D590DE57520E}" src="https://github.com/user-attachments/assets/d46143c6-5b26-4134-b8c6-964d08ff2bc6" /> <img width="636" height="489" alt="{CCCA7CB8-6305-422F-B8B6-1A523979D03E}" src="https://github.com/user-attachments/assets/39512123-b86a-4335-a3b4-5e9879116764" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Users can now duplicate lorebook entries directly from the entry row. Duplicated entries automatically append "(Copy)" to the original name while preserving all other details. The duplicate button appears on hover or in mobile view and is disabled while the operation is processing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:22 +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#5673
No description provided.