Versions and Smart Undo

Each deploy is recorded as a version of its route, with a screenshot. You can compare versions, restore one into the playground, open the history of any deployment from its URL, and step back through deployed versions with Undo. This guide covers the version viewer, Smart Undo and the edge.versions() API.

What a version is

When you deploy, RTEdge.net records what was deployed as a version: the playground state that reopens the route, your source, the document that was served, the exported files and the worker code. A screenshot of the page is archived next to it. A version appears a few seconds after the deploy, because it is written in the background. Deleting a deployment records a deletion in the history.

You see your own history. The lists show the versions of the routes you own, including the saves of your editors, and the versions you saved as an editor on someone else's route. A route you neither own nor ever saved shows nothing. In the viewer, ✏️ marks a save by an editor, and πŸ”‘ shows the owner. edge.versions(), Smart Undo and Code Size read the newest 100 versions. The viewer loads 100 at a time and can load more.

After you delete a deployment, the versions older than the deletion are hidden from your lists, so a route that you deploy again starts a fresh history. A delete removes the deployment, not its recorded history.

Notes

A message you give when you deploy with a message is kept with the version as one line, with every run of whitespace collapsed to a single space. It shows as πŸ’¬ in the rows of the viewer, where long notes are cut to 25 characters and …, in the tooltip with the whole message, in the digest, in the message field of edge.versions(), and in Code Size. There is no enforced length. Keep a note short, about 200 characters.

Browse versions online

Open the version viewer

Append ?? to any URL of a deployed host. You are redirected to the version viewer of its route. This works for any route, even one that was never deployed, because the redirect is decided before the deployment is read.

plain
https://name.rt.ht/??        goes to https://rtcode.io/code/versions/#r=name
https://name.rt.ht/docs/??   goes to https://rtcode.io/code/versions/#r=name%2Fdocs
https://example.com/??       goes to https://rtcode.io/code/versions/#r=example.com

The #r= key takes the route: a bare name for name.rt.ht, the host for a custom domain, and the host or name plus the path for a path route, with the slash written as %2F. A file URL maps to its route, so name.rt.ht/nav.js?? opens #r=name. The viewer asks you to sign in.

  • In the playground, Code: Versions… (Alt+V / βŒ₯+V) opens the viewer for the first route, and Code: Versions (All Routes)… (Alt+Shift+V / βŒ₯+⇧+V) opens one viewer for each route. The menu item, File β–Έ Code β–Έ Versions, opens the first route. It is hidden when you are signed out and when the playground is embedded, and it is disabled when there are no routes.
  • The Recent Deployments drawer has a Versions button for each route, and the * index has a πŸ•’ action.
  • The ::v suffix redirects to ??. Experimental

Open the viewer from the playground when you want to restore a version, because a restore needs the playground that opened it.

Compare two versions

The viewer has two selectors. The left one is the original, and the right one the modified side. Each lists the versions newest first, with the time between deploys, the editor when someone else saved, and the note. Two more entries compare against what you have now. Playground ⚑ is the source of the playground that opened the viewer, and it follows your edits. Clipboard πŸ“‹ is the text that was on your clipboard when the viewer opened, when the browser allowed reading it.

The two sides open in a diff editor, and both sides are editable. Hover a row, or focus it while the list is open, to see the full commit message. Right-click a row to copy the full SHA of the version. The viewer keeps its selections in the URL, so you can share a comparison.

ControlWhat it does
Left and right selectorChoose the versions to compare. Opened with Alt+V, the right side starts as the playground, and otherwise both sides start as the newest version.
↩️ left and rightRestore that side into the playground. See Restore a version.
πŸ“Έ / πŸ“„Switch between the screenshots and the code.
↕️ / ↔️Stack the screenshots, or place them side by side.
⬇️ / ➑️Collapse or expand the unchanged regions of the diff. They start collapsed.
↔️ / ↕️Show the diff inline and compact, or side by side.
πŸ”Zoom, from 0.1 to 2.
The time between the selectorsClick it, or press Enter, to open the digest.

Each toggle shows the icon of what you switch to. The digest has one line for every deployment between the two selections, both ends included: the time, the time since the previous deploy, the short SHA, the note and the editor. Its πŸ“‹ button copies the digest. The header of the diff shows its statistics: the line delta, the old and new line counts, the added and removed lines, and the characters before and after.

Compare screenshots

The πŸ“Έ toggle lists the archived screenshots of the route instead of its source. They appear side by side, or stacked with the layout toggle. Double-click to switch to an overlay with a draggable divider. At rest the overlay blends the two images in difference mode, so identical pixels show as black. In overlay mode, a single click on a side keeps that screenshot on top after about 0.9 seconds. Screenshot rows carry no notes. See The screenshot.

Restore a version

The ↩️ button copies the current text of its side, including any edits you made in the diff, into the playground that opened the viewer. The playground applies it as one undoable edit, so Ctrl+Z / ⌘+Z takes it back, then forces a sync of the output and takes focus. Deploy afterwards to publish the restored source.

Smart Undo

Smart Undo carries Undo and Redo past the editor's own history into the deployed history of the first route.

Undo and redo through deployments

  • Undo (Ctrl+Z / ⌘+Z), when the editor has nothing left to undo, loads the previous deployed version whose source differs.
  • Redo (Ctrl+Y / ⌘+Y, or Ctrl+Shift+Z / ⌘+⇧+Z), when the editor has nothing to redo, moves to newer versions. At the end it returns to the editor state from before you started walking back.
  • The same actions are in the Playground menu (Alt+J / βŒ₯+J) under Input β–Έ Code β–Έ Edit β–Έ Undo and Redo. The menu stays open for repeated clicks.

Smart Undo needs at least one route, because it always uses the first one. It needs you to be signed in, since the history comes from your versions: signed out, the first step past the local history shows "Unauthenticated." For the keys, keyboard focus has to be in the editor.

Skip Same compares only the HTML source with the current one. Identical versions are skipped, and a notification lists them as "Skipped same-content version" or "Skipped N same-content versions", so every step changes the source.

A restore loads the whole saved state of that version: the source and also the title, the routes, the editors, the selections, the folds, and the layout and output settings. Then it forces a full sync of the output. Because the routes come back too, a restored state carries the routes it was deployed with.

One Deployment history notification reports what happens. It shows "Loading history..." and "Smart skipping..." while it works, "Restored deployment version." with how many versions into the past you went, "Returned to editor state before deployment-history undo." at the end, and the warnings "No deployment history found.", "No older different deployment found." and "No newer different deployment found."

Roll back a deployment

  1. Press Ctrl+Z / ⌘+Z past your local edits until the notification shows the version you want.
  2. Check the Routes field. The restored state brings back the routes it was deployed with.
  3. Press Ctrl+S / ⌘+S. That state is deployed as the newest version.

Leaving history

  • Editing while you are in history makes the restored content the new present. Redo can no longer return to the state from before the walk, and the next Smart Undo past your local edits starts a new walk from the newest deployment that differs.
  • Deploying the route also ends history mode.
  • The position lives in memory, for each tab. After a reload the URL still holds the restored content, but the way back is gone.
  • Every deploy ends the current group of local undo steps, so a local undo never spans a deploy.

Versions from code

edge.versions() lists the newest 100 versions you own or saved for a route, newest first. Its route option defaults to the first route and takes the route form, such as name, name/docs or example.com. edge.versions.load() writes one version's source into a file of the shared folder. It needs an active Agent Folder Share.

js
await edge.versions()        // [{ n: 0, sha: 'a1b2c3d', date: '…Z', editor: '', message: 'Hero: …', deleted: false }, …]
await edge.versions.load(1)  // { file: 'πŸ•.1.<sha7>.html', n: 1, sha: '<sha7>', date, message, ok: true }
n

The index of the version in the list, with 0 for the newest. It is relative to the list at the time of the call: after new deploys the same version has a higher n, so key your files on the SHA.

sha

The first 7 hexadecimal characters of the version's id.

date

When the version was recorded, as an ISO string. This is a little later than the deploy time that pages send in their deploy header.

editor

The email of the editor who saved the version, when you are the owner, and an empty string otherwise.

message

The deploy note, or an empty string.

deleted

Whether the version is a deletion. In practice it is false, because the versions up to a deletion are hidden from the list.

load() takes an index or a string. A string is a prefix of a version's SHA, and the first, newest match wins, with no check for ambiguity. A string such as '2' is therefore a SHA prefix and not the index 2. The file πŸ•.<n>.<sha7>.html lands in the root of the work folder and holds the version's HTML source, the same shape as πŸ“„.html. Loading never touches the editor, the output or the undo history. Read and diff these files with local tools, for example against πŸ“„.html, and do not return their contents through eval results. See Agent files.

Return to the deployed state

Code: Revert Changes (Ctrl+I, R / ⌘+I, R, or File β–Έ Edge β–Έ Load) asks "Revert all changes since the last deployment?" and adds "Use the browser's back button to undo this." On Revert, this tab opens <first route>?, which reopens the latest deployed state of the first route in the playground. The browser's Back button returns to the state before the revert. Code: Revert Changes in New Window… (Ctrl+I, W / ⌘+I, W) opens it in a new tab without asking, and your current tab keeps its changes.

Revert always loads the latest deployment. To pick an older version, use Smart Undo or the viewer. To reopen a route that has a path, open its URL ending in /?, such as https://name.rt.ht/docs/?. Opening ? follows the access rules of the source: a visitor who may not open it is sent to sign in or sees a 401 or 403 page. See Restricting access.

Note: Load in the Edge menu means Revert Changes. It is not the Load command of the Sync menu, which reloads the output.

See also