Skip to content

Versions: keep them across formats, Save As and Compare - #398

Open
danyill wants to merge 5 commits into
mainfrom
fix/versions-across-formats
Open

danyill wants to merge 5 commits into
mainfrom
fix/versions-across-formats

Conversation

@danyill

@danyill danyill commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Closes #389

  • Where versions live: versions are kept in the per-user history store, keyed by the file's path, for every format. They are not inside an .rbdz, which holds the model, its results and a manifest. The Version History window now says this in a visible note.
  • Save As: a new options dialog appears when Save As would move to a new file name or format. It offers to bring the saved versions along (on by default, with a warning line when unticked), and for .rbdz whether to include the results. Nothing is dropped silently any more. Versions are copied with HistoryStore.copy_history, which keeps their ids, labels and descriptions and leaves the old file's versions untouched.
  • MCP: versions are now recorded under the file that was opened, not under the workspace's working copy. Before, they disappeared from list_versions after a close and reopen. restore_version now writes a snapshot in its own format; before, an .rbdz snapshot was written into a .rbds file.
  • Restore: restoring a version saved in another format is refused, with a tooltip explaining why.
  • Compare: the picker has a "Saved version of {name}" submenu, and both file filters accept .rbdz.

Root cause: on the desktop, reopening a .rbds kept its versions on every route tried. The loss reproduced only after Save As .rbdz followed by reopening from Recent, which now points to the .rbdz and so has no versions, and through MCP. Both are fixed.

Known gap: the What's different? label for a saved version shows the stored snapshot's file name, not the version label.

Tests run locally, with -m "":

  • Touched and neighbouring files: 352 passed.
  • UI sweeps, MCP end-to-end, generated-file, docs and i18n tests: 289 passed, 1 skipped.

HistoryStore.copy_history(src, dst) copies every version of one file into
another file's history (hard link, else copy), keeping ids, times, labels
and descriptions and noting copied_from; ids already there are skipped and
the source history is untouched. record() takes suffix= so an archive's
model text can be stored as .rbds under the archive's history.
list_versions, snapshot_version, label_version and restore_version keyed
the history on the workspace copy (models/<id>/model.rbds) as soon as a
model was edited, or at open for an .rbdz, so the versions vanished when
the file was reopened under a new model_id and the desktop never saw them.
They now use the opened file whenever it is a real model file, and fall
back to the workspace copy only for a model with no file (template,
build_model, AWB import). Unedited, a snapshot stores the opened bytes in
their own format; edited, the workspace copy is stored as .rbds under the
opened file. Workspace.edited_since_open() tells the two apart by the undo
chain's first backup.

restore_version writes the version in its own format: an .rbdz version
is written as .rbdz (it was written into an .rbds), and an .rbd as .rbd.
The open-file guard now runs after the extension is settled.

Reproduced: the MCP reopen loss (new test). The desktop reopen of an
.rbds kept its versions in every route tried; see the Save As commit.
Versions are kept per user, keyed on where the file is, so a Save As to
another name or format (.rbds to .rbdz, a rename, .rbd) started the new
file with none, without a word. Save As now asks, in a small dialog shown
only when it applies, whether to bring the old file's versions along
(checked; unchecking says the new file starts with none and the versions
stay with the old one), and for an .rbdz whether to include the results on
screen. A model-only archive skips the results, the archive-results guard
and the manifest's results; a plain Save of that archive repeats the
choice until another model is loaded. A failed copy keeps the save and
warns. Plain Save never asks.

Cause of the reported ".rbds reopen loses versions": not reproduced in the
desktop app. Close and reopen by path, plain save then reopen, and opening
through a symlink all keep the versions (regression test added). The loss
reproduced only after a Save As to .rbdz, when Recent opens the .rbdz, which
had no versions: that is what this commit fixes. The MCP route (fixed in
the previous commit) is the other confirmed cause.
The Version History dialog now says, in a visible note, that a file's
versions are kept on this computer, tied to where the file is, not inside
it (an .rbdz holds the model and its results, not its versions), and that
Save As offers to bring them along. Restore is disabled for a version
saved in another format than the open file (an MCP edit of an .rbdz is
stored as .rbds); its tooltip points to Open as copy, then Save As.
Add models now lists "Saved version of <file>" after "From a file…"
when the open file has versions: the 20 newest, each by label (or
"(no label)") and time. A chosen version is a SavedVersion entry, named
"<file> · <label or time>", run from its stored file, handed to
What's different? by its path, and listed once. Compare's and
Differences' file filters accept .rbds, .rbdz and .rbd (load_model_file
already reads all three). docs/VERSION_HISTORY.md says versions are not
inside any file, and covers Save As, the MCP rule and Compare.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versions: lost in .rbds and when converting to .rbdz; not in Compare; no save-results choice for .rbdz

1 participant