mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #215] [MERGED] Fix message order, metadata, and game-state in branching #4509
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#4509
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/215
Author: @Xelvanis
Created: 4/24/2026
Status: ✅ Merged
Merged: 4/26/2026
Merged by: @LukaTheHero
Base:
main← Head:fix/chat-branching📝 Commits (1)
27f8102fix(chat): preserve message order, extra metadata, and game-state when branching📊 Changes
2 files changed (+130 additions, -7 deletions)
View changed files
📝
packages/server/src/routes/chats.routes.ts(+113 -7)📝
packages/server/src/services/storage/game-state.storage.ts(+17 -0)📄 Description
Why this change
Starting a new branch from a roleplay chat message caused multiple issues: message history would sometimes appear out of order, tracker metadata (date, time, location, weather, characters, stats) was completely lost, and per-message display metadata was silently discarded. This annoyed me as a very branch-happy user, since jumbled message order and losing tracker data was a bummer.
What changed
All changes are confined to the
POST /:id/branchhandler inchats.routes.ts. No client code, generation logic, or other endpoints are affected.createdAtviatimestampOverrides, preventing out-of-order display caused by same-millisecondnow()timestampsextrametadata — originalextraJSON (displayText, generationInfo, tokenCount, etc.) is merged into branched messages viaupdateMessageExtra()chatIdandmessageIds, ensuring tracker state (date, time, location, weather, characters, player stats, persona stats) carries over. Copying all snapshots (not just the latest) ensures branching a branch at an earlier point finds the correct tracker state for that specific messageswipeIndexmismatch — branched messages only have swipe index 0, so copied snapshots are now keyed toswipeIndex: 0instead of the source's possibly different indexstorage.update()resetsupdatedAttonow()so the branch appears at the top of the chat list instead of being sorted as if it was created at the last source message's original timestampValidation
pnpm check— lint + build passes cleanlyManual verification notes
Docs and release impact
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.