# Version history

Dunjii saves a version of a file each time it changes, so you can step back through a document's earlier versions and restore one.

## When Dunjii saves a version

While you type, Dunjii saves your work every 15 seconds, and again when you switch from Edit back to View. Each save that changes the file adds a version. Other changes add one too: a sync from the [desktop app](https://dunjii.com/docs/your-files/desktop-app.md), a restore, an import.

Saving every 15 seconds makes a lot of versions, so Dunjii thins out the older ones. It splits a file's history into time windows that widen with age, and in each window keeps the versions just before and just after the largest edit. A window where every edit was small (under 64 characters and under 2% of the document) keeps only its newest version.

| Version age           | Window       |
| --------------------- | ------------ |
| Under 5 minutes       | Every version is kept |
| 5 to 30 minutes       | 1 minute     |
| 30 minutes to 2 hours | 5 minutes    |
| 2 to 6 hours          | 15 minutes   |
| 6 to 24 hours         | 1 hour       |
| Over a day            | 6 hours      |

Dunjii never thins out a file's newest version, the last version of a deleted file, or a copy that lost a sync conflict before anyone has reviewed it.

## A file's history

Every document page shows when the document last changed, beside its path at the top: **Edited 4 minutes ago**. Click it to open the document's history. The line changes to name the version on screen, such as **Viewing v3 · 1m ago**, and a bar of version controls appears at the bottom of the page.

- Click ‹ and ›, or press ← and →, to step one version at a time.
- Open the list to jump to any version. Each row shows the version number, its age, when it was saved, and which sections or settings that save changed.
- The page shows the old version in place, and highlights the text that version added.
- **View** and **Edit** both work while you look at an old version. Neither lets you change it.
- Press Esc, click **Cancel**, or click the **Viewing** line again to go back to the current version.

![Version 3 of a scene, with the section it added highlighted and the version list open.](https://dunjii.com/docs-assets/your-files/version-list.webp)

A picture and its notes file share one history. When the editor has nothing left to undo (⌘Z on a Mac, Ctrl+Z elsewhere), Dunjii shows a link to the document's history.

## Restoring a version

1. Open the document's history and step to the version you want.
2. Click **Restore**.

Dunjii saves that version as the new current version. The version you replaced stays in the history, so restoring never deletes anything. A message with **Undo** appears for 10 seconds.

If the version you restore links to files that have since been deleted, Dunjii asks first: **This version links to files that aren't here any more**. Tick the files you want back, then click **Restore**.

![The version bar while you look at an old version.](https://dunjii.com/docs-assets/your-files/version-bar.webp)

## The History page

**History** in the sidebar opens **Version history**, the history of your whole workspace.

| Tab                  | What it lists |
| -------------------- | ------------- |
| **Recent changes**   | Each file that changed, newest first, with its number of versions, who changed it, and when. Click a path to open the file. |
| **Recently deleted** | Deleted files, ready to restore. See [Deleted files](https://dunjii.com/docs/your-files/trash.md). |
| **Restore log**      | Each restore, with how many files it changed. |
| **Needs review**     | Documents edited in two places at once, where Dunjii kept the later edit and saved the other copy in the document's history. The tab appears only when there is something to review. See [Desktop app and sync](https://dunjii.com/docs/your-files/desktop-app.md). |

Type a folder path in **Folder**, such as `Mistwood/Session 3`, to narrow every tab to that folder. To open the page already narrowed, right-click a folder in the sidebar and choose **Version history**. Search (⌘K on a Mac, Ctrl+K elsewhere) finds the page as **Version history**.

When you work with [co-GMs](https://dunjii.com/docs/sharing/co-gms.md), **Changed by** filters **Recent changes** to one person's edits.

![The History page narrowed to one session folder.](https://dunjii.com/docs-assets/your-files/history-page.webp)

## Restoring a folder to a point in time

The **Recent changes** tab starts with **Restore the whole workspace to a point in time**. With a folder in **Folder**, it restores that folder instead.

1. Set **At** to a date and time. Clicking a time in the **Last changed** column sets **At** to just after that change.
2. Click **Restore…**. Dunjii lists what will change: files under **Reverted** go back to the version they had then, files under **Undeleted** come back, and files under **Added later (not removed)** stay as they are.
3. Click **Restore 4 files**. The button shows how many files will change.

The versions you replaced stay in each file's history, so you can restore to a later time to undo it.

## How long versions are kept

| Plan | Kept for |
| --- | --- |
| Free | 7 days |
| Pro | 90 days |

Once a version is older than that, Dunjii deletes it for good. The current version of a file is never deleted. When a document's oldest versions are gone, the end of its version list says: **Old versions are retained for up to 90 days on the Pro plan.**

On your computer, `dunjii history <file>` lists the same versions and `dunjii restore` brings one back; see [Desktop app and sync](https://dunjii.com/docs/your-files/desktop-app.md).
