mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6120] Duplicating a lorebook entry you switched off for one chat creates a copy that is switched off everywhere #3396
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#3396
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?
Originally created by @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6120
Originally assigned to: @SpicyMarinara on GitHub.
When you turn a lorebook entry off for a single chat and then duplicate that entry from inside the chat's lorebook list, the copy is created switched off in the shared lorebook itself - so it is dead in every other chat and for every character using that book. The switch you touched was labelled as affecting this chat only.
How to reproduce (try it yourself)
Use a throwaway lorebook - the last step writes to the shared book.
Harbor Lore. Add an entry: NameDockmaster, Keysdockmaster, ContentThe dockmaster knows every hull.Its toggle is on - that is the shared/global flag, used by every chat and character bound to this book.Harbor Loreattached (any chat mode works).Harbor Loreso the entry list appears. TheDockmasterrow's switch is on, and its tooltip reads "Only affects this chat".Dockmasteris still on there. The chat switch correctly left the shared entry alone.Dockmasterrow, click Duplicate (the copy icon at the right of the row; hover the row to reveal it on desktop, always visible on a narrow window).What you'll see: a new row
Dockmaster (Copy)appears with its switch off and greyed out, tooltip "Disabled in the shared lorebook. Enable it there before using it in this chat." You cannot turn it on from here. Open the global Lorebooks page (or any other chat usingHarbor Lore) andDockmaster (Copy)is switched off for everyone, everywhere.What should happen: the copy should be created with the original's shared/global state - on - exactly as
Dockmasterlooks on the global Lorebooks page. The per-chat off state should not follow it into the shared book.Two controls worth running: duplicating the same row from the global Lorebooks page produces an enabled copy, and duplicating from the chat with the switch left on also produces an enabled copy. Only the globally-on plus chat-off combination leaks.
Where it is
At staging
52799569c:packages/client/src/components/lorebooks/LorebookEntryRow.tsx:240-const [localEnabled, setLocalEnabled] = useState(entry.enabled && (chatEnabled?.enabled ?? true));(re-synced the same way at :280-281)packages/client/src/components/lorebooks/LorebookEntryRow.tsx:470-enabled: localEnabled,inside thehandleDuplicatepayload. This is the bug.packages/client/src/hooks/use-lorebooks.ts:343-355-useDuplicateLorebookEntryforwards that payload verbatim to the shared create routePOST /lorebooks/{id}/entries.e2e/chat-lorebook-entry-scope.e2e.ts:117- the existing sibling guard ("content edits cannot leak the chat's disabled flag"); there is no duplicate counterpart in the file.What's happening
Inside a chat, the row's
localEnabledis a combined value: the shared flag AND the chat's own override. The chat switch writes only the chat override (LorebookEntryRow.tsx:390-393), so the shared flag stays on whilelocalEnabledgoes off.handleDuplicatethen reads that combined value and puts it in a field namedenabled, which is posted straight to the shared create route - turning a chat-only choice into a permanent flag on a shared entry. The copy's own switch is then rendered disabled (:649, because the new entry is globally off), so the chat surface that caused it cannot repair it.The rest of the duplicate payload deliberately reads live row state (name, position, depth, order, probability, regex, outlet), which is correct - those fields are single-scope and their inline edits already go to the shared entry.
enabledis the only field in that payload that became dual-scope.Suggested fix
Make the duplicate carry the source entry's shared flag rather than the row's combined display state: use
entry.enabledinstead oflocalEnabledin thehandleDuplicatepayload. The new entry gets a fresh id and therefore no per-chat override, so a copy of a globally-enabled entry lands enabled. Add a short comment next to the payload noting thatenabledis the one dual-scope field here, so it is not "fixed" back for consistency with the other live-state reads.Ship the coverage with it: add a case in
e2e/chat-lorebook-entry-scope.e2e.tsbeside the existing content-edit guard - with the chat toggle off, click Duplicate and assert the created entry's sharedenabledis true. Same fixture, no extra setup. The code fix and the guard belong in one change.Context
Introduced by PR #5981 ("keep chat entry toggles scoped to their chat"), which implemented issue #5954. The duplicate line was harmless before that PR, because the row's local state used to mean the shared flag; #5981 changed what it means and the audit of its readers stopped at the content-edit path - which is why that PR's own end-to-end test guards the content-edit leak and not this one. Unreleased on staging (latest release is v2.4.4). No existing tracker covers this.
Found by an AI-assisted sweep of merged PR #5981 against issue #5954, then re-verified against staging
52799569con 2026-09-13. Please verify before fixing.@SpicyMarinara commented on GitHub (Sep 13, 2026):
@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Fixed in #6137, now merged to staging (
e044997a2). Duplicated lore entries preserve shared enabled state and pending shared edits without copying chat overrides.