mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2978] [Issue]: Entry-row inline toggles (enabled / status / regex) never roll back optimistic state on a failed PATCH #1552
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#1552
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/2978
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The entry row keeps optimistic local mirrors (
localEnabled,localStatus,localUseRegex, etc.) and flips them immediately, then callsupdateEntry.mutatewith noonErrorhandler. If the PATCH fails, the entries query is never invalidated (that only happens onSuccess), so theentryprop reference doesn't change and the re-sync effect never fires — the local mirror is stuck on the optimistic value with no error indication. Forenabled, the toggle shows ON while the server still has it OFF, so the entry silently won't activate during a chat scan. The folder row deliberately guards this exact case with anonErrorrollback; the entry row's analogous activation-affecting toggle has no such guard.How to reproduce (try it yourself)
lorebookKeys.entries) does not run, so the entry is not refetched.You'll see: the row keeps displaying the optimistic value (e.g. enabled = ON) while the server kept the old value (enabled = OFF); during the next generation the entry does not activate, with no indication the change failed.
Expected: the toggle rolls back to the server value (and ideally surfaces an error), as the folder row does.
Where it is
packages/client/src/components/lorebooks/LorebookEntryRow.tsx:324-329(patch, noonError),:331-338(handleStatusChange),:348-354(handleEnabledChange),:356-364(handleUseRegexToggle).:231-243.packages/client/src/hooks/use-lorebooks.ts:179-190(useUpdateLorebookEntry— noonMutate/onError, only invalidates onSuccess).packages/client/src/components/lorebooks/LorebookFolderRow.tsx:97-116(capturesprevious, passesonError: () => setLocalEnabled(previous)).What's happening
patch()callsupdateEntry.mutatewithout anonError, and the only path that reverts local state is theuseEffectre-sync keyed on theentryreference. On a failed mutation the entry query is not invalidated, soentryis unchanged and the stale optimistic local value is never corrected.Suggested fix
Mirror the folder-row pattern: capture the previous value before the optimistic flip and pass an
onErrorthat restores it (and optionally surfaces a toast), at minimum for the activation-affecting toggles (enabled, status,useRegex), e.g.const previous = localEnabled; setLocalEnabled(next); updateEntry.mutate({...}, { onError: () => setLocalEnabled(previous) });.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: inline entry toggles now roll back their local optimistic state when the PATCH fails, and drawer autosave no longer races the row-owned fields. Validated with pnpm check.