mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3027] [Issue]: Prompt-override editor's reverse-substitution silently drops ${cellHeight} when two variables share an example value (512), corrupting the saved sprite-sheet template #1596
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#1596
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/3027
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The Prompt Overrides editor reconstructs an editable
${var}template by string-replacing each variable's example value back into its token. When two variables share the same example value, every occurrence of that value is replaced with the FIRST variable's token and the second variable's token never appears. For the Sprites Expression Sheet key,cellWidthandcellHeightboth have example value512, so the editable template shows${cellWidth}four times and no${cellHeight}. If the user edits and saves, the persisted override hascellHeight's slots bound to${cellWidth}, so at render time the cell-height instruction uses the cell-width value whenever they differ. The bug is silent — the preview re-expands${cellWidth}back to 512, so it looks byte-identical to the original.How to reproduce (try it yourself)
${cellWidth}x${cellWidth} pixelsandevery ${cellWidth} pixels ... every ${cellWidth} pixels—${cellHeight}is absent.You'll see: both cell dimensions in the image prompt render as the cellWidth value; the persisted override has no
${cellHeight}.Expected: the editable default never silently binds
cellHeight's slots to${cellWidth}.Where it is
packages/client/src/components/panels/settings/PromptOverridesEditor.tsx:59-79(buildEditableDefaultTemplate; consumed at 191-194; preview masking at 81-97; dirty/canSave guard at 199-200). Shared example values inpackages/server/src/services/prompt-overrides/registry/sprites.ts:71-81(exampleContext) emitted at lines 51 and 57. Runtime corruption viasprites.routes.ts:1146->loadPrompt->renderTemplate(packages/server/src/services/prompt-overrides/template.ts:40-51), cellWidth/cellHeight atsprites.routes.ts:233-234. Same collision also affectssprites.fullBodySheet(cellCount/poseCount both 6).What's happening
The value->token reverse substitution has no guard for two variables sharing an example value. After the first token replacement consumes all instances of the shared value, the second variable's replacement finds nothing. The PUT route only rejects unknown variables, never missing ones, so a template lacking
${cellHeight}saves cleanly.Suggested fix
Make
buildEditableDefaultTemplatecollision-aware on the client: a value is reverse-substituted to its${token}only when it maps to EXACTLY ONE variable. When two or more variables share the same example value, leave the literal number in the editable default for all of them (the user can wire it via the existing "Available variables" chips). Concretely, count how many variables resolve to each example string and skip any example with count > 1 in the replacement loop (keep the existinglength > 1filter and longest-first sort). This fixes both the confirmedcellWidth/cellHeightcase and thecellCount/poseCounttwin, with no server change.Regression avoided: do NOT use the tempting "run defaultBuilder with variable names wrapped as tokens" approach —
sprites.fullBodySheetdoes arithmetic (Math.max(0, ctx.cellCount - ctx.poseCount)) and value-gated conditionals, so a token-string context yields NaN and silently drops whole instruction lines. The collision-aware client transform keepsdefaultTemplatebyte-stable so the dirty/canSave/reset guards and the preview round-trip keep working, and leaves keys without shared example values unchanged.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.