mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7746] [MERGED] feat(game): save and restore game chat metadata in checkpoints #7911
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#7911
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/7746
Author: @ylli-selmani
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ylli-selmani
Base:
staging← Head:feat/checkpoint-game-metadata📝 Commits (5)
8127494feat(game): checkpoints save and restore the game's chat metadatab708c2afix(game): rewind the party's characterIds mirror on checkpoint load2ad47e5fix(game): store an empty game-metadata capture as {}0673179fix(game): checkpoints capture the chat's characterIds and restore them92e970cfix(game): keep the checkpoint metadata write readable to the key sweep📊 Changes
4 files changed (+368 additions, -5 deletions)
View changed files
📝
packages/server/src/db/schema/checkpoints.ts(+8 -0)📝
packages/server/src/routes/game.routes.ts(+21 -4)📝
packages/server/src/services/game/checkpoint.service.ts(+87 -1)➕
scripts/regressions/game-checkpoint-metadata.regression.ts(+252 -0)📄 Description
Linked issue
Closes #7742. Prerequisite for #7743 (Game data in the State Editor).
Why this change
Before: a Game Mode checkpoint saved the turn's tracker snapshot, the spatial snapshot and the engine state. Loading one rewound the scene, but the party cards, NPCs, journal and inventory stayed as they were after the save, because those live in chat metadata.
After: a checkpoint also saves the game's own metadata keys, and loading it puts them back. An NPC met after the save is gone again, the party's HP and items are what they were, and the journal matches.
What changed
checkpoint.service.ts:CHECKPOINT_GAME_METADATA_KEYS, an allow-list of the keys a checkpoint saves:gameCharacterCards,gamePartyCharacterIds,gamePartySheet,gameNpcs,gameJournal,gamePlayerNotes,gameInventory,gameInventedItems,gameLootedFights,gameStartingGearTaken,gameWorldOverview,gameStoryArc,gamePlotTwists,gamePartyArcs,gamePreviousSessionSummaries,gameTime,gameWeather,gameMorale.create()copies the present ones into a newgameMetadataDatacolumn, so every caller (manual, session start/end, combat start/end) gets it. A game with none of them yet stores{}, so its load still clears keys added later.create()also stores the chat'scharacterIdscolumn (newchatCharacterIdsData). That column holds the party's library members, and session start trusts it overgamePartyCharacterIds.buildCheckpointGameMetadataRestore: on load, a captured key is restored and an allow-listed key added after the save is cleared. Two companions follow:gameInventoryTurnis dropped, because it records the tellings of stacks the load just replaced. This matches what a new session already does.POST /game/checkpoint/loadwrites those keys,gameActiveStateand the savedcharacterIdsin one queued write (patchMetadataWithCharacterIds), so a member recruited after the save doesn't come back at the next session.saveGameWorldSnapshot, the story checks), and leaving them out is the Game Mode maintainers' call (see the scope note on #7742).gameMetadataDatanull) load exactly as before.How: the capture and the restore patch are pure functions, so the regression tests them directly and then end-to-end through the load route.
Commits
8127494bbcheckpoints save and restore the game's chat metadatab708c2a34rewind the party'scharacterIdson load (CodeRabbit)2ad47e509store an empty capture as{}(CodeRabbit)067317933capture thecharacterIdscolumn itself, so saves without a party list rewind it too (CodeRabbit security review)92e970c4akeep the metadata write readable to thecapability-gm-verbskey sweep (CI)Validation
pnpm checkpasses locallyCONTRIBUTING.mdRan:
pnpm lint, servertsc --noEmit, prettier, and the regressionsgame-checkpoint-metadata(new),game-checkpoint-engine-state,checkpoint-retention,capability-gm-verbsand the othercapability-*ones,open-issues,assigned-issue-sweep,multiplayer-session-flowsandgame-inventory-turn. All pass. Local CodeRabbit also ran.Manual verification notes
There is no checkpoint screen in the client yet, so this was checked through the routes. The new regression creates a game chat, saves a checkpoint, changes cards, NPCs, inventory, journal, morale and a setting, then loads the checkpoint. The game keys are back, the later journal is cleared, and the setting keeps its new value.
Server-side edge cases covered by the regression:
characterIdstoo, with or without a party list in the save;{}and still clears later keys;The UI edge cases in the box above don't apply, since there's no UI.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/game/sessions-and-saves.mdstill says there's no screen to restore checkpoints, which stays true. It gets updated with the Load checkpoint button in #7743.UI evidence (if applicable)
None, server only.
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.