mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2972] [Issue]: Drawer autosave silently reverts a row-header rename or regex toggle made while the drawer is dirty #1547
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#1547
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 (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2972
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
When an entry's expanded drawer has an unsaved edit (e.g. text typed into Description/Content/Keys), and the user then renames the entry or flips the regex toggle on the compact row header, the header change is saved immediately — but the drawer's debounced autosave (~850 ms later) POSTs its stale snapshot, which still carries the old
nameand olduseRegex, overwriting the just-saved header change. The user's rename / regex toggle silently snaps back. This is real data loss, not cosmetic.How to reproduce (try it yourself)
useRegex=true(or the new name).You'll see: the entry's
useRegexflips back to false (or the name reverts to the old value).Expected: both the header change and the drawer edit persist.
Where it is
packages/client/src/components/lorebooks/LorebookEntryRow.tsx:1107-1138(buildEntrySavePayload) — the drawer payload re-sendsname(1109) anduseRegex(1117) from its snapshot.:356-364(handleUseRegexToggle) and:366-373(handleNameCommit) — the compact row header is the real owner ofuseRegex/name.:1308-1328— the drawer's sync effect only refreshesformRef.currentfrom the upstreamentrywhenswitched || (!dirtyRef.current && !savingRef.current), so it refuses to refresh while the drawer is dirty.:1249-1267(saveNow) — posts the staleformRef.currentsnapshot.packages/client/src/hooks/use-lorebooks.ts:179-190(useUpdateLorebookEntry) — no optimistic update; only invalidates onSuccess.What's happening
buildEntrySavePayloadsendsnameanduseRegex, both of which are only editable on the row header (the drawer has no input for either). The drawer's sync effect won't refresh its snapshot from a freshly refetchedentrywhile the drawer is dirty, so a concurrent header patch toname/useRegexis held stale informRef.currentand re-sent on the next autosave, clobbering the newer server value.Suggested fix
Drop
nameanduseRegexfrombuildEntrySavePayloadso the drawer never persists fields the row header also writes (the cleanest fix — neither field has an input inside the drawer, so the drawer has no business sending them). Alternatively, when the refetchedentrydiffers on a field the drawer is not actively editing, merge that field intoformRef.currenteven while dirty rather than discarding the whole refresh.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in the v2.0.7 branch: drawer autosaves no longer include header-owned name/useRegex fields, so stale drawer state cannot clobber row-header edits while the drawer is dirty. Validated with pnpm check.