# Version history

Every test keeps its latest versions, every run remembers the version it ran, and any version can be restored.

Each time a test changes, Testsnag records a new version of it: the steps, the target URL, the variables and the test type settings. Edits you make in one sitting are grouped into a single version, so the history shows meaningful changes rather than every keystroke. A version stays open while the same person keeps editing from the same place, and closes after 10 minutes without an edit, after an hour, or as soon as a run uses it.

![The version history dialog listing versions v3, v2 and v1 on the left, with the steps of v2 on the right tagged Changed and Added.](https://testsnag.com/images/docs/building-tests/version-history-1-history.r1.jpg)

Marked on the screenshot:
- The current version, who made it and where the change came from, such as the editor or an AI assistant.
- Each version shows how many steps were added, removed, changed or moved.
- Tags show what changed in this version compared with the one before it.
- Restore puts this version back as a new version, so you can always undo it.

## Opening the history

In the test editor, click the version button in the header, shown with a clock icon and the current version number, for example v7. The list on the left shows the latest 5 versions, newest first. Pick one to see its steps on the right. Steps are tagged Added, Changed, Removed or Moved compared with the version before it, and a Settings changed list shows anything else that changed, such as the target URL. Turn on Compare with current to compare the selected version with the test as it is now instead.

## Which version a run used

Every new run is tied to the version of the test it started with, and it runs exactly that version. Runs from before version history show Version not recorded. If someone edits the test while a run is waiting in the queue, the run still uses the steps it was queued with. The run page shows the version as a chip in its header, for example Test v6, with an Edited since badge when the test has changed after that run. Click the chip to see the exact steps and settings the run used, including the contents of any blocks as they were at that moment. The runs table also shows the version under each run reference.

![A run page with the Test v1 dialog open, listing the three steps that run used, with a note that the current version is v3.](https://testsnag.com/images/docs/building-tests/version-history-2-run.r1.jpg)

> **Note:** Only the latest 5 versions appear in a test's history, but a version is kept for as long as a run that used it still exists. Opening an older run still shows the version it ran, with a note that it is no longer in the test's history.

## Restoring a version

1. **Pick the version**: Open the history from the editor and select the version you want, or open a run and click its version chip.
2. **Restore it**: Click Restore this version and confirm. The steps, target URL, variables and settings from that version are put back.
3. **Check the result**: The restore is saved as a new version, for example "Restored from v3", so the version you replaced is still in the history.

Restore refuses with a clear list when the old version uses something that no longer exists, such as a deleted file, block, script or saved API request. Secret variable values are never stored in a version. When you restore, secrets keep their current values, and if the old version used a secret that has since been removed, Testsnag tells you which ones need a value again. For mobile tests the app build stays on the current one, and only the device settings are restored.

## From an AI assistant

Assistants connected over MCP can use list_test_versions, get_test_version and restore_test_version, and get_run reports the version a run used. Edits an assistant makes appear in the history labelled AI assistant (MCP).
