mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2157] [MERGED] feat: duplicate lorebook entries #5452
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#5452
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/2157
Author: @kolacheee
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @cha1latte
Base:
refactor← Head:feat/lorebook-entry-duplication📝 Commits (1)
4038969feat: duplicate lorebook entries📊 Changes
2 files changed (+46 additions, -1 deletions)
View changed files
📝
src/features/catalog/lorebooks/components/entries/LorebookEntryRow.tsx(+23 -1)📝
src/features/catalog/lorebooks/hooks/use-lorebooks.ts(+23 -0)📄 Description
Linked issue
Closes #2127 — Halfway, this PR is the entry-duplication part. Nested folders will follow as a separate PR.
Why this change
What changed
useDuplicateLorebookEntryhook (hooks/use-lorebooks.ts) — clones an entry through the existing genericstorageApi.create("lorebook-entries", …)path: the create schema strips the server-managedid/createdAt/updatedAt, the name gets a" (Copy)"suffix, and every other field carries over verbatim —folderId, keys/secondaryKeys, all character/tag/trigger filters, position/depth/order, probability, timing, grouping, embedding, and activation conditions. Invalidates the same queries asuseCreateLorebookEntry.components/entries/LorebookEntryRow.tsx) — aCopy-icon button in the per-row actions, immediately left of the existing delete button. Mirrors delete's hover-reveal pattern (always visible on mobile) with neutral styling; disabled while the mutation is in flight.No backend/Rust changes. Unlike
duplicate_character(which needs Rust to deep-copy the managed avatar file on disk), lorebook entries have no managed on-disk asset — their entire CRUD already rides the generic storage gateway — so duplication is a pure client-side row clone. No new Tauri command, nolib.rsregistration.Refactor impact
Primary owner: Catalog / Lorebooks editor (frontend)
Impact areas reviewed:
hooks/use-lorebooks.ts(newuseDuplicateLorebookEntrymutation) andcomponents/entries/LorebookEntryRow.tsx(the row's duplicate button). No engine, storage-contract, or Rust changes.Boundary notes:
storageApi.createand the establishedcreateLorebookEntrySchemarather than adding a parallel path; no new storage collection, command, or cross-boundary call.Pressure points touched:
ModeSurface/GameSurface/shared mode UI, nosrc-tauri/src/lib.rscommand registration, no import modules. Lorebook entry row only.Validation
pnpm typecheck,pnpm build,pnpm check:architecture,pnpm check:docs, or fullpnpm checkwhen warranted)pnpm checkpasses before PR push/handoffManual verification notes
pnpm typecheck(tsc -b) clean;check:architecture,check:frontend,check:discovery,check:docs, andcheck:unusedall pass locally."… (Copy)"entry that preserves the source's content, keys, position (↑Char), order, and probability (confirmed token count and inline controls match the original); the copy lands in the same container; repeated duplication works. Confirmed in light and dark mode, and at the mobile breakpoint (≤768px — the inline controls collapse into the⋯menu and the copy/delete buttons go always-visible, no overflow, names truncate).Feature Discoverability
src/features/shell/discovery/because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.Reason:
Docs and release impact
README.mdCONTRIBUTING.mddocs/developer/AGENTS.mdProof
Core claim:
Verification run:
pnpm typecheckpluscheck:architecture/check:frontend/check:discovery/check:docs/check:unused(all green), plus manual in-app testing in the Tauri build.Evidence:
↑Charposition,ord: 1,p: 100%, and# 12token count (identical content) — differing only by the" (Copy)"name — confirming the whole entry (not just the name) is cloned.Known behavior (intended, not a bug):
order, so it sorts immediately after the original in the common case. When several entries share the sameordervalue (e.g., all at the default), the copy lands at the end of that same-order group rather than directly beneath the source. This is deliberate: the only way to force flush placement is to renumber the whole container, which would overwrite every sibling'sorder— andorderalso drives prompt-injection priority. Non-invasive placement was chosen over exact adjacency.Manual verification requested:
UI evidence
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.