mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2956] [Issue]: Branching a chat throws away every alternate swipe — only the one you're viewing survives #1530
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#1530
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/2956
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
When you branch a chat ("fork from here"), each copied message keeps only its currently-active swipe. Every alternate generation (the other swipes you generated) is silently dropped and is gone for good in the new branch. So branching — which users expect to be a faithful copy — quietly loses data.
How to reproduce (try it yourself)
1/3); optionally swipe to swipe 2 so it's the active one.You'll see: the counter shows
1/1— only the swipe that was active at branch time exists; the other alternates are gone.Expected: the branched message keeps all 3 swipes (with the same one active), so you can still swipe between the alternates.
(The active swipe's text is copied correctly — it's only the alternates that are lost. Note the JSONL export path already emits all swipes, so the branch path is the inconsistent one.)
Where it is
packages/server/src/routes/chats.routes.ts— the branch copy loop at lines 3024-3064 resolves only the active swipe's content (3027-3032) and callsstorage.createMessagewith a singlecontent(3034).storage.createMessage(packages/server/src/services/storage/chats.storage.ts:710-740) is a single-swipe constructor: it always inserts the message withactiveSwipeIndex: 0and exactly onemessageSwipesrow. The loop never callsstorage.getSwipes(msg.id). (Relatedly, the game-state snapshot copy at ~3120-3122 hardcodes the targetswipeIndexto 0.)What's happening
Because the branch loop only ever passes the single active-swipe content into the single-swipe
createMessage, the new message is born with one swipe. The storage layer already has a multi-swipe path (createMessagesBatchaccepts aswipesarray, used elsewhere for full-swipe cloning) — the branch path just doesn't use it.Suggested fix
In the branch loop, fetch
const swipes = await storage.getSwipes(msg.id)and recreate all of them, preserving each swipe's content, sanitizedextra,createdAt, and the originalmsg.activeSwipeIndex— easiest viastorage.createMessagesBatchwith a per-message{ activeSwipeIndex, swipes }payload (orcreateMessagethenaddSwipethe rest in index order, thensetActiveSwipe). Also re-key the game-state snapshot copy to each swipe's real index instead of hardcoding 0.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in staging: branching now copies every swipe, preserves the active swipe index, and rekeys Game/turn-game snapshots to matching branched swipe indexes. Validated with pnpm check and pnpm regression:prompt.