Save snapshots and channels
Save snapshots and channels turn game progress into a versioned line that can move between play sessions and devices. A channel names one playthrough of one ROM file. Its current snapshot points to the latest save and state set, while older snapshots preserve restore points for the owner and for approved sharing. This page is a child of Play and client services and relates to Play sessions and saves, Remote library sync, and Netplay and streaming.
Snapshot lifecycle
The snapshot service accepts a manifest that describes a complete logical game state. It resolves that manifest against a parent snapshot, stores only content that is not already known, and records the resulting state as a new version in a channel.
Channels
A channel is the mutable current pointer for one user's playthrough of one ROM file. The ROM-file link prevents progress for a different file from silently entering the same line. A channel can start empty, start from an existing save, or start from another snapshot as a fork. References: backend/…/channel.py• L17-59, backend/…/channels.py• L49-93, frontend/…/ChannelsPanel.vue• L369-375, frontend/…/ChannelsPanel.vue• L412-455
The channel has a label and a current snapshot. It can be private or public. A public channel exposes its snapshots and their usable content to other users who can see the ROM. ROM visibility still limits access, so sharing a channel does not make a hidden game visible. References: backend/…/channels.py• L96-105, backend/…/snapshots.py• L208-224, backend/…/snapshots.py• L249-264
Snapshot contents
A snapshot is a fixed checkpoint made from one optional save and a bank of emulator states. The bank is grouped by core and slot. A hardcore snapshot keeps the save but has no state bank. The service can carry a save from the parent and replace a listed core's state bank, which lets a session send only its changed progress. References: backend/…/snapshot.py• L36-100, backend/…/snapshot.py• L103-123, backend/…/manifest.py• L29-75
Each snapshot points to stored save and state rows instead of storing duplicate bytes. A channel or branch snapshot freezes the rows it holds. This keeps an older checkpoint stable even when older save APIs continue to receive uploads. Content can be shared by hash when it already belongs to the channel, while a cross-user copy gets its own row and ownership. References: backend/…/write.py• L299-410, backend/…/write.py• L634-653, backend/…/write.py• L1271-1294
Content identity
The system uses two related identities. A save or state has a content hash for finding the same file bytes. A snapshot has a digest for the resolved save and state bank as one logical checkpoint. The digest is built from canonical JSON, so the same logical contents produce the same snapshot identity even when a push carries no new files. References: backend/…/manifest.py• L45-95, backend/…/write.py• L255-272, backend/…/write.py• L343-351
The client sends file parts only for hashes that it thinks the server does not hold. The server checks every received part against the manifest before it accepts the snapshot. A hash match can therefore avoid a file transfer, but it cannot bypass ownership, ROM visibility, or missing-content checks. References: frontend/…/snapshot.ts• L13-19, frontend/…/snapshot.ts• L40-69, backend/…/snapshots.py• L552-634
Manifest pushes
A push names the ROM file, channel, expected current, parent, save hash, and state-bank hashes. It may include the matching save, state, and screenshot files. Omitting a save carries the parent's save. Listing a core replaces that core's bank, so a slot omitted from the listed bank is removed.
This diagram shows how a client turns session progress into a versioned channel entry.
flowchart LR
P[Play session] --> H[Hash save and state files]
H --> M[Build manifest from parent]
M --> U[Upload missing parts]
U --> R[Resolve complete snapshot]
R --> D[Compute snapshot digest]
D --> C{Expected current still matches?}
C -->|yes| N[Move channel current]
C -->|no| B[Keep branch and return conflict]
The server reports an unchanged result when the resolved contents already match the channel current. Otherwise it creates a channel snapshot or a branch. The browser queues pushes from one session in order, so its later state builds on the result of its earlier push. References: backend/…/snapshots.py• L514-536, backend/…/write.py• L727-832, frontend/…/snapshotSession.ts• L293-368
Retention and restore
Version history balances recovery with storage use. The service removes content only after no retained snapshot needs it, and it keeps enough metadata to prevent a removed version from being offered back to a legacy device.
Retention
After a channel push, retention keeps the configured number of newest channel snapshots. It never removes the current snapshot or a pinned snapshot. Branches created by device races expire on a separate lifetime. Detached channels are not pruned because their ROM file is no longer present and may be attached again. References: backend/…/snapshots_handler.py• L1035-1071, backend/…/retention.py• L41-65, backend/…/prune_snapshots.py• L7-20
When a snapshot is removed, its save, states, and screenshots are removed only if no other snapshot still holds them. An archival snapshot can remain after channel deletion when it is the current or the owner's pinned version. An archival snapshot with no ROM and no file hash cannot be found again, so scheduled cleanup removes it. References: backend/…/snapshots_handler.py• L963-1033, backend/…/snapshots_handler.py• L1073-1086, backend/…/snapshots_handler.py• L1110-1146
Restore and fork
Restore does not rewrite an old snapshot. It creates a new snapshot on the target channel whose parent is the selected checkpoint. If the target already has the required content rows, the restore can send only hash references. This keeps the selected checkpoint intact and makes the restore part of the target channel's new history.
The game-detail view offers restore on an older snapshot, fork into a new channel, and save-over into another channel on the same ROM file. It also lets the owner remove one state slot by creating a new snapshot without that slot. References: frontend/…/snapshots.ts• L108-159, frontend/…/SnapshotViewer.vue• L166-225, frontend/…/ChannelsPanel.vue• L254-300
Save conversion
Restore uses the selected emulator and platform rules to turn a stored save into files that a core can read. Native save units can be used as stored. Other supported platforms can use a conversion service. Multi-file and folder units remain archives when the target core cannot consume them directly. References: backend/…/restore.py• L23-70, backend/…/restore.py• L110-146
Conflict handling
The expected current is the concurrency boundary for a channel. A device push declares the snapshot it used as its base. If another writer moved the channel before the commit, the new data is preserved as a branch instead of replacing the newer current.
Branch outcomes
A branched push returns HTTP 409 with both the channel current and the new branch. The reason distinguishes a push that lost a move from one that started from an older snapshot and also lost a later move. The writing device then continues from its branch, while the current channel remains the other writer's version. References: backend/…/snapshot.py• L27-34, backend/…/write.py• L753-832, backend/…/snapshots.py• L514-536, backend/…/snapshots.py• L117-125
The browser treats a branch as accepted progress rather than as a failed upload. It advances its local session base to the returned branch. The game-detail controls use a simpler stale response: they refresh the channel before asking the user to act again. References: frontend/…/snapshotSession.ts• L287-368, frontend/…/ChannelsPanel.vue• L214-251
Hardcore transitions
A softcore push cannot replace a hardcore channel current without explicit approval. The API returns a separate conflict marker. The UI asks for confirmation and retries with approval only after the user accepts. References: backend/…/write.py• L747-761, frontend/…/snapshotSession.ts• L217-221, frontend/…/ChannelsPanel.vue• L225-241
Push recovery
A push can also fail because its parent was pruned or because the server lacks a referenced file. The session retries with a safer parent or removes missing carried entries when the client did not send those files. It does not silently discard a file that the push explicitly tried to upload. References: frontend/…/snapshotSession.ts• L224-281, backend/…/snapshots.py• L618-634
Device synchronization
Device synchronization records what each device knows and holds for each channel. It does not create a separate channel per device. This lets several clients share one version line while the server can tell whether an upload is based on current knowledge.
Device state
For each device and channel, the service tracks a held snapshot and the latest current snapshot the device has seen. Listing a channel records the current as known. Reading or downloading a snapshot with hold semantics records that snapshot as held. A successful device push also records the new snapshot as held. References: backend/…/device_channel_sync.py• L12-40, backend/…/snapshots_handler.py• L516-553, backend/…/snapshots_handler.py• L1174-1230, backend/…/snapshots.py• L319-377
The device marker is also the default source for an omitted expected current. A push first uses the device's latest known current and then uses its held snapshot as the parent when no parent is named. This allows a client to continue from the version it downloaded without sending the full history each time. References: backend/…/write.py• L230-252, backend/…/channels.py• L49-75, frontend/…/snapshotSession.ts• L58-105
Legacy save synchronization
The older save and sync APIs share channel history with snapshot clients. A slot upload can become the channel current while carrying forward the current state bank. Negotiation can offer a channel-held save to a legacy device, and a device that is behind the channel is told to negotiate before it overwrites progress. Neutral saves and incompatible emulator data stay outside that legacy restore path. References: backend/…/bridge.py• L26-85, backend/…/test_sync_snapshot_channels.py• L255-289, backend/…/test_sync_snapshot_channels.py• L330-364
Device privacy
Snapshot responses identify the origin device only to its owner. Other viewers receive an anonymous device reference. The held_by list is limited to the viewer's own devices, so public channel history does not expose another user's device inventory. References: backend/…/snapshots.py• L24-31, backend/…/snapshots.py• L129-135, backend/…/snapshots.py• L217-225
Game-detail save workspace
The game-detail save area presents ordinary backup files and versioned channels as different forms of progress. It uses ROM data for the initial channel list, then loads channel history only when the player opens a channel or the timeline view.
Channel browser
The save-data tab separates owned channels from community channels. Owned channels support creation, rename, sharing, deletion, and detached-channel reattachment. Community channels are browse and download views. A channel can be shown as tiles or as a timeline, and its history is paged from the snapshots API. References: frontend/…/SaveDataTab.vue• L98-139, frontend/…/ChannelsPanel.vue• L94-165, frontend/…/ChannelsPanel.vue• L516-602
Snapshot viewer
The snapshot viewer shows the checkpoint thumbnail, parent, origin device, save, state bank, and status badges. It enables actions only when the viewer owns the channel or the channel is public. Play, restore, fork, pin, download, and save-over actions are mapped to the snapshot or channel APIs. References: frontend/…/SnapshotViewer.vue• L54-145, frontend/…/SnapshotViewer.vue• L166-225, backend/…/snapshots.py• L70-110
Play handoff
When a player starts from a snapshot, the game route receives the snapshot id and an optional state id. The player then builds later save and state pushes from that snapshot's channel, parent, bank, and save hash. This keeps a launch from an older checkpoint connected to the same version line instead of creating an unrelated save. References: frontend/…/ChannelsPanel.vue• L202-211, frontend/…/snapshotSession.ts• L44-105, frontend/…/EmulatorJSPlayer.vue• L99-128
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the manifest carry rules aligned between backend/…/manifest.py, the snapshot API payload, and frontend/…/snapshotSession.ts. A missing save or state bank can mean “carry” or “remove.”
- Keep content hashes, the resolved snapshot digest, and the stored save or state rows aligned. A mismatch can create duplicate content or make a valid hash reference look missing.
- Keep the expected-current and parent rules aligned with device markers. A change can turn a safe concurrent push into an overwrite or an unnecessary branch.
- Keep channel visibility, ROM visibility, and content visibility coupled. Public channel rows and thumbnails must not outlive the access rules that expose them.
- Keep pruning and released-content cleanup in one lifecycle. A snapshot must not lose a file still held by another snapshot or offer a deleted legacy version again.
- Keep restore, fork, and save-over manifests tied to the target ROM file. These actions should create history on the selected channel rather than mutate the source checkpoint.
- Keep the legacy save bridge compatible with channel current and state-bank rules. Slot uploads and snapshot pushes must remain one line of history.
- Keep the game-detail response shapes aligned with channel history paging and viewer actions. A stale channel or snapshot must cause a refresh rather than a write to the wrong version.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A push expects an old current | The new data becomes a branch and the channel current stays unchanged | Locked channel commit and HTTP 409 conflict response |
| A push names a hash whose file is not held or uploaded | The snapshot is rejected with the missing part names | Manifest content lookup and missing-content response |
| Uploaded bytes do not match their manifest hash | The push is rejected and temporary files are removed | Server-side content-hash check |
| A softcore push targets a hardcore current | The channel is not downgraded without user approval | Explicit hardcore conflict and confirmed retry |
| Retention reaches an old pinned snapshot | The snapshot remains available and its content remains held | Per-user snapshot pins |
| A channel's ROM file is removed | The channel becomes detached instead of being pruned | Detached-channel retention and same-platform attach flow |
| A device uploads after another device moved the channel | Legacy sync reports a conflict or snapshot push records a branch | Held/latest-known device markers and expected-current check |
| A public channel belongs to a hidden ROM | The channel and snapshots are not readable | ROM visibility checks on channel and snapshot access |
| A user views another user's snapshot origin | The device identity is hidden | Viewer-scoped device references |
| A selected snapshot is no longer offered | The UI can attempt a stale write or launch missing data | Current channel refresh and server parent/content checks |
Key files
| File | Why to read it |
|---|---|
| backend/…/channel.py | Defines the playthrough channel and its current pointer |
| backend/…/snapshot.py | Defines snapshot kinds, content links, pins, and conflict reasons |
| backend/…/device_channel_sync.py | Defines per-device knowledge and held-snapshot state |
| backend/…/channels.py | Exposes channel listing, creation, sharing, attachment, and deletion |
| backend/…/snapshots.py | Defines snapshot history, push, read, pin, and conflict API behavior |
| backend/…/manifest.py | Defines manifest carry rules and snapshot digest identity |
| backend/…/write.py | Coordinates content reuse, conflict-safe writes, and current movement |
| backend/…/snapshots_handler.py | Defines channel history, device markers, visibility, pruning, and content release |
| backend/…/retention.py | Applies history and branch retention and removes released files |
| backend/…/restore.py | Defines platform and emulator save restore behavior |
| backend/…/bridge.py | Connects legacy save uploads to channel snapshots |
| backend/…/snapshots.py | Defines the channel and snapshot data sent to clients |
| frontend/…/snapshot.ts | Defines client calls and multipart snapshot push shape |
| frontend/…/snapshotSession.ts | Tracks a play session's channel base and handles push conflicts |
| frontend/…/ChannelsPanel.vue | Coordinates channel history, sharing, restore, fork, and device-facing UI actions |
| frontend/…/SnapshotViewer.vue | Presents snapshot contents and available user actions |
| frontend/…/SaveDataTab.vue | Places channels beside backup saves and community save data |