JoyPro2 Discord GitHub
Reference

Autosave, profile history and the last profile at start

Show:

From docs/profile-history.md in the repository (generated, always the current text).

JoyPro saves every change by itself, keeps every save as a version you can go back to, and opens the profile you had open last. Nothing to press, nothing lost on a crash, and the history never fills the disk.

  • GUI: top bar (Saving… / Saved ✓ chip, Undo, Redo, History, More > Save as... / Rename...), Settings > Startup ("Open the last profile at start"). User guide: GUI wiki, Top Bar.
  • CLI: engine --profile <file> profile history list | show | diff | restore | undo | redo | keep | checkpoint | prune | usage and the global --history-note <text> (CLI wiki).
  • Code: engine/ProfileHistory.cs (the store, plain C# 7.3, compiled into the engine and linked into the GUI), engine/EngineProfileHistory.cs (what a profile's items are, labels, checkpoints, the CLI), engine/CoreInternalDataManagement.cs (SaveProfileTo: atomic write + version), gui/JoyPro.Gui/Services/AutosaveScheduler.cs, gui/JoyPro.Gui/ViewModels/MainWindowViewModel.ProfileHistory.cs.

#Saving

  • The engine writes the profile atomically. SaveProfileTo serializes into memory, writes <profile>.tmp-<pid>-<id> next to the profile, flushes it to the disk and swaps it in with File.Replace (40 tries while a sync client or virus scanner holds the file). A crash, a full disk or a locked file leaves the old profile whole; temp files older than 10 minutes are removed on the next save. Before, a crash during a save could leave a half-written .pr0file.
  • Every engine command that changes the profile saves it (as before) and records a version. The GUI passes the words of its busy line as the version's name (--history-note "Adding relation"); without it the engine names the command ("Import from DCS", "Set bind").
  • What the GUI holds before it is in the profile is saved by the autosave, 2 s after the last change (AutosaveScheduler, debounced; saves never overlap, a change during a save is saved right after it):
    • axis tuning edits of the shown scope (as engine binds tuning set, the same as Save for this scope),
    • marker positions and callout tables of the Layout page's device pictures (the layout undo stays),
    • modifiers that are not on a bind yet: a profile cannot hold a modifier without a bind (the engine rebuilds the modifier list from the binds), so they go into drafts.json in the profile's history folder and come back when the profile is opened. The old layout-file editor (JoyPro 1 style .layout with a chosen output file) keeps its Save: its save writes a template and reloads it.
  • Flush: the pending edits are saved at once when JoyPro closes (the window waits for it), before another profile opens (Open, New, Open last, Close profile, the tray's "open last"), before every export or import (any engine command <area> export|import), before Undo / Redo / Restore, Rename and Save as.
  • Top bar: Saving… while an engine change runs or edits wait for the autosave, Saved ✓ afterwards (tooltip: the time), Not saved with the reason when a save failed (the edits stay pending and are tried again). Ctrl+S still saves at once.
  • New profile has no dialog: Documents\JoyPro2\profiles\My profile.pr0file, or My profile 2.pr0file, My profile 3.pr0file, ... when that name is taken (JOYPRO_PROFILES_DIR replaces the folder; tests). More > Rename... renames the file (its history goes along), More > Save as... writes a copy and goes on with it (the copy starts its own history, "Saved as a copy of ..."). Renaming onto the name of another profile asks first ("Replace the profile ...?"); yes keeps the replaced file as <name>.pr0file.bak next to it (<name>.pr0file.<date-time>.bak when a .bak is there already) together with its history, and the renamed profile, with its history, is the open one. Renaming the .bak back undoes it. No changes nothing; a replaced file that is open in another program or read-only stops the rename with a message (nothing is changed then).

#The last profile at start

Settings > Startup > "Open the last profile at start", on by default (ui-settings.json: autoOpenLastProfile; the old loadLastProfileOnStartup, off by default, is no longer read). The profile is opened after the window has drawn itself (MainWindow.OnWindowOpened posts AutoOpenLastProfileOnStartupAsync at background priority), so the start is as fast as without a profile; the busy area shows "Loading profile...". When the file is gone the Start page stays at "No profile open" with a note in the status line.

#Versions

Where: <data>\ProfileHistory\<profile id>\, data = JOYPRO_DATA_DIR or %LOCALAPPDATA%\JoyPro2 (the engine's data folder, next to GameBackups). The profile id is <file name, 32 characters>-<10 hex of the full path>.

File What
history.json the versions (id, time, kind, label, summary, content hash, size, kept, parent, from), the undo cursor, the redo stack, the time of the last clean-up
blobs\<hash>.gz one gzip copy per distinct profile content; versions with the same content share it (undo, redo, restore and an unchanged checkpoint cost nothing)
blobs\<hash>.items.gz the profile's items, one line per relation (name, action count, groups, hash of the actions, hash of kind + groups), bind (device and input, hashes of input, modifiers, tuning), modifier and settings section
drafts.json modifiers that are not on a bind yet (see above)
.lock held while a process changes the history (GUI, its engine processes and the tray host may run at the same time)

Kinds: change (a save), open (the file as it was when the history started), external (the file was changed outside JoyPro: another program, an older JoyPro, a copy put back), checkpoint (before an export or import: "Before export to DCS", "Before import from IL-2"; or profile history checkpoint), restore, undo, redo.

  • What changed comes from the items of the version and the one it was made on: "Relation 'Throttle ALL' created, 42 actions added", "Relation 'Gear' renamed to 'Landing gear'", "'Flaps' moved from Stick JOY_BTN2 to Stick JOY_BTN3", "'Pitch': axis tuning changed", "Modifier 'Shift' created on Stick JOY_BTN5", "Force feedback settings changed". More than two changes are counted ("12 relations created, 380 binds set"). Details / show lists every change of a version, Compare / diff the changes between two versions.
  • A burst is one version: saves within 2 s of the last one (one click that runs several engine commands) replace it; the labels are joined ("Adding relation + Setting bind").
  • Nothing is lost when the file changed outside JoyPro: before a save, an undo or a restore the file on disk is compared with the version the history is at; a different file is kept as an external version first (the engine also reads its items, so it is described; in the engine server from the graph it already keeps of that file). A profile moved or renamed in Explorer finds its history by its content (the newest version's hash, profile file gone).
  • Unchanged saves (same content as the version the profile is at) make no version.

#Undo, redo, restore

Undo / Redo (Ctrl+Z, Ctrl+Y or Ctrl+Shift+Z) walk the versions like an editor's undo, also after a restart:

  • a change's parent is the version it was made on; Undo writes the parent's content back and records an undo version (from = the parent), the undone version goes on the redo stack;
  • Redo writes the newest entry of the redo stack back (redo version); any new change clears the redo stack;
  • Restore of an older version (GUI: Roll back to here) is a change of its own (parent = the state before it): the profile becomes that version, so every change after it is taken back in one step, and one Undo returns to the state before the restore; its label is "Rolled back to the version of