mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2958] [Issue]: Regenerating a message leaks the previous swipe's translation / sprite / choices / token count onto the new one #1535
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#1535
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2958
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
When you regenerate an assistant message (which creates a new swipe), the new swipe inherits the previous swipe's per-swipe display data — its translation, sprite expression, CYOA choice buttons, token count, and Gemini "thought parts." If the new generation doesn't produce its own version of that data, the stale old data stays attached to the new, unrelated text.
The worst case is Gemini: a stale
geminiPartsvalue can later be sent to the model as that message's content, silently replacing your regenerated text.How to reproduce (try it yourself)
Translation (most reliable):
You'll see: the new swipe shows the previous swipe's translation (mistranslating the now-visible new text); it survives a page refresh and auto-translate won't re-translate it.
Expected: no translation, or a fresh translation of the new text.
CYOA: in a CYOA chat, generate a message with choice buttons, then regenerate; if the new generation emits no choices, the old swipe's buttons stay under the new prose.
Gemini (the severe one):
geminiParts).You'll see: the next Gemini call sends the old generation's parts as that turn's content, discarding the regenerated text.
Expected: a fresh swipe starts with empty per-swipe data.
Where it is
packages/server/src/services/storage/chats.storage.ts—addSwipe()clearedExtraat lines 1050-1062 spreads the outgoing swipe's entire extra and nulls onlythinking/generationInfo/attachments/generationReplay, while the new swipe row is inserted withextra: {}(line 1042). So the mirrored message row keeps every other field; the swipe row is empty — they diverge at creation. Fields that every regenerate unconditionally rewrites (cachedPrompt, thinking, generationInfo, contextInjections, chatCompletionsReasoning) don't leak; the ones with no unconditional rewrite do:translation,translationHidden,spriteExpressions,cyoaChoices,tokenCount,geminiParts. For Gemini specifically,generate.routes.ts:7013isif (geminiResponseParts) extraUpdate.geminiParts = geminiResponseParts;with noelse-null (unlikethinkingat 7010-7011 andchatCompletionsReasoningat 7015-7016), so a non-Gemini regen never clears it; it's later consumed ingoogle.provider.tswhere stored parts replace the message content.What's happening
clearedExtrais an allowlist-NULL of 4 fields layered on top of a full spread of the old extra, so the message-row mirror is born carrying stale per-swipe data that the empty swipe row doesn't have. The client hydrates translation/sprites/choices from the message-row mirror, so the stale data displays and persists.Suggested fix
Invert
clearedExtra: build it by copying only the genuine message-level fields that must survive a swipe (e.g.hiddenFromAI,hiddenFromUser,reactions,isConversationStart, persona/command flags) and start everything else empty — matching the{}written to the new swipe row at line 1042. That clearstranslation,translationHidden,spriteExpressions,cyoaChoices,geminiParts,tokenCount, etc. in one place. Additionally addelse extraUpdate.geminiParts = null;atgenerate.routes.ts:7013to mirror the other reasoning fields.AI-investigated against v2.0.6; clearedExtra and the geminiParts else-branch read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in staging: new regenerated swipes start with fresh message metadata and clear provider/Gemini/per-swipe fields so prior translation/sprite/choices/token data does not leak. Validated with pnpm check and pnpm regression:prompt.