mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3026] [Issue]: Upgrading wipes user edits to the bundled "Marinara's Universal Preset" when its bundled content hash changes #1598
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#1598
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/3026
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
On startup, the seed re-applies the bundled default preset whenever the shipped
default-preset.jsonhash differs from what was last applied. The re-apply matches the preset by name+author only, then DELETEs all of that preset's choice blocks, sections, and groups and overwrites its body from the bundle. A user who edited the bundled preset in place (changed sections, parameters, or order) without renaming it loses all those edits the first time they launch an upgraded build, with no warning or opt-out.How to reproduce (try it yourself)
packages/server/src/db/default-preset.jsondiffers (new sha256).You'll see:
seedDefaultPresetdetects the hash change andapplyBundledPresetToExistingdeletes the user's sections/groups/choice blocks and overwrites the preset body — the user's edits are gone.Expected: an in-place-customized preset is detected and preserved (or refreshed into a fresh copy), not silently wiped.
Where it is
packages/server/src/db/seed.ts—applyBundledPresetToExisting(77-166) overwrites the preset body (86-97) and unconditionally deletes child rows (99-101);seedDefaultPresetopens the destructive re-apply at the gateexistingMarinaraPreset && appliedHash !== bundled.hash(188-195); name+author match at 177-185. No "user customized this preset" guard exists.What's happening
The re-seed is keyed only on name+author and a content-hash change. It does not detect user modifications and deletes the preset's child rows before re-importing, so any in-place edits are destroyed.
Suggested fix
Detect customization before re-applying by recording a content snapshot of the seeded state and skipping the destructive re-apply when the current rows diverge. In
packages/server/src/db/seed.ts:MARINARA_PRESET_SNAPSHOT_KEY = "seed:marinara-universal-preset:snapshot-sha256".computePresetSnapshotHash(storage, presetId)that hashes ONLY content fields (preset name/description/prompts/parameters/wrapFormat/variableGroups/variableValues/defaultChoices; each section's identifier/name/content/role/enabled/group-membership/injection fields; each group's name/order/enabled/parent; each choice block's variableName/question/options/etc.; plussectionOrder/groupOrderremapped to stable identifiers), excluding row ids and timestamps, sorted deterministically before hashing.appliedHash !== bundled.hash, compare a recorded snapshot to the freshly computed one. If a snapshot exists AND diverges, treat the preset as user-customized — record the new bundle hash (so it isn't re-evaluated every launch) and return without wiping. Otherwise re-apply as today, then write the new snapshot.Regression avoided: a MISSING snapshot must be treated as "assume pristine, allow this one in-place refresh, then record the snapshot" — otherwise every legacy/untouched preset would be frozen from future updates on the first launch after this fix. The snapshot must be content-only and order-normalized, or zero-edit recomputation would never match the stored hash and would also freeze untouched presets. (Caveat: a user who customized in a PRE-fix build still loses edits once on the upgrade that introduces this fix, since there is no prior snapshot to compare against; behavior is correct from then on.)
AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed on staging in PR #3031 (merged as
f542e282). Closing manually because GitHub auto-close keywords only close issues when merged into the default branch (main), not staging.