mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2768] [Issue]: Connection/preset editors silently discard unsaved edits via background refetch / spurious effect deps #1406
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#1406
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 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2768
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Three editor data-loss bugs where in-progress, unsaved edits are silently reverted by a background refetch or a stale-state reset, with the dirty flag staying true so the user has no warning.
Sub-bug 1: PresetEditor Overview edits wiped by unrelated mutations (data-loss/new-bug)
(a) The
useEffect([data])that hydrates localName/description/wrapFormat/author/params has NO dirty guard. Any section/group/variable mutation auto-saves and invalidatespresetKeys.full, the refetch yields a newdatareference, the effect fires and overwrites the user's pending Overview edit with stale server values. The reorder optimisticsetQueryDataclobbers instantly, before any round-trip.dirtystays true so Save then persists the reverted value.(b) Rename the preset (don't Save) -> add/reorder/edit any section -> the rename silently reverts; Save persists the old name.
(c) PresetEditor.tsx:215-227 (effect, no guard), 237-256 (handleSave); use-presets.ts:220-224 (invalidate), 244-253 (optimistic setQueryData). Kind: new-bug.
Sub-bug 2: AgentEditor reset on connections refetch (data-loss/new-bug)
(a) The populate effect sets ~50 local fields and ends with
setDirty(false), and its deps array includesconnections— which is NEVER read in the effect body. AnyconnectionKeys.list()invalidation (rename/delete/move/default-toggle/save-defaults a connection) refetches, yields a new array reference, re-runs the effect, and resets all unsaved agent edits whiledbConfigis unchanged. (Window-focus does NOT trigger it —refetchOnWindowFocus:false— but explicit invalidations do.)(b) Open the Connections panel; open an agent; make unsaved edits; rename/toggle a connection in the panel -> agent edits vanish and Save goes un-dirty.
(c) AgentEditor.tsx:498-693 (effect body, ends setDirty(false)), 693 (deps includes
connections); use-connections.ts invalidations (63/72/94/102/174); use-connection-folders.ts:71. Kind: new-bug.Sub-bug 3: PresetEditor parse-failure resets params to {} (data-loss/new-bug)
(a) If stored
parametersfails JSON.parse, the populate effect catch sets localParams to {}; handleSave unconditionally sendsparameters: localParams, so the next Save (even just a rename) overwrites the stored sampler overrides with {}. There is no parameter-editing UI, so localParams only diverges via this reset. Requires a genuinely malformed stored blob (corruption/legacy), so low-probability but real silent loss.(c) PresetEditor.tsx:222-226 (catch -> {}), 246 (always sends parameters). Kind: new-bug.
Suggested Fix
dataonly when not dirty / only on first load (ref keyed on preset id), or give Overview fields the focusedRef local-draft pattern used by SectionContentTextarea.connectionsfrom the populate effect deps (it is unused there), or key the reset on agent identity only (agentDetailId/dbConfig).parametersfrom the PATCH unless actually edited).Template
pnpm checkpassesAffected files
packages/client/src/components/presets/PresetEditor.tsxpackages/client/src/components/agents/AgentEditor.tsxpackages/client/src/hooks/use-presets.tsAudit provenance
Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged
stagingtree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: HIGH.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in PR #2747.\n\nWhat changed:\n- PresetEditor now skips same-preset hydration while local overview edits are dirty, so unrelated refetches/reorders do not wipe drafts.\n- The dirty guard uses a ref so saving does not briefly rehydrate stale cached data before the fresh refetch arrives.\n- PresetEditor tracks parameter parse failure and omits parameters from PATCH in that case, preventing an unrelated save from overwriting malformed stored params with {}.\n- AgentEditor no longer depends on the connections array in its populate/reset effect, so connection-list refetches do not reset unsaved agent edits.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.