LOOK AND TYPE / STUDY / LEVEL 5 OF 5
Keeping
the past.
Typing "add a red door" asks an AI to change a thing, and an AI does not always do what I meant. If the old version were overwritten, a bad answer would destroy the work. So a change never overwrites. The thing's entry keeps a list called past: when a new version arrives, the one it replaces is pushed onto that list. The earlier versions stand behind the thing like rows in a theatre, and I can slide through them and bring one back. Bringing one back does not delete anything either: the version that was in front joins the others. The list is short on purpose. It holds the six most recent earlier versions; a seventh change drops the oldest.
One thing and its past
change it, slide the stack, bring one backClick here to use the arrow keys, Enter and Escape
Change it (each button stands in for the AI's answer to these words)
Slide the stack (in the scene: two fingers on the trackpad, or the arrow keys)
The entry
said, and past (oldest first)versions(entry), newest first, and where stackPlace puts each
A change keeps what it replaces
js/scenes/hw9/edits.jssaid is the words that produced a version. made is a time stamp: when it changes, every client rebuilds the thing's picture. slice(-MAX_PAST) is the line that limits the list to six.
Looking back, and bringing one back
js/scenes/hw9/edits.jspast is kept oldest first, because a change adds at the end. For looking back the other order is handier, so versions turns it round and puts the present one at index 0. restored takes version k out, makes it the present, and turns the rest round again.
Where each version stands
js/scenes/hw9/edits.js · stackView.jsOne function places a version from one number: d, how many steps it is behind the one I am looking at. d may be a fraction while the stack slides. The step back and up is taken from the thing's own depth and height, so versions do not stand inside one another. A version newer than the one I look at (d below 0) shrinks to nothing: nothing stands between me and what I look at.
What the AI is sent
js/scenes/hw9/edits.js · editPromptThe AI gets the thing's whole list of parts back, with the words I typed, and must return the whole list again. Its answer goes through the same validator as a new thing (Giant & Mini, level 4). Below is the prompt for the last change you made, built by the scene's own editPrompt.
What you should be able to explain
- Why a change cannot lose work.
changedbuilds a new entry. The old spec is not edited; it is put, whole, at the end ofpast. - Why restoring loses nothing. Make three changes, step back two, and bring that version back. Count the versions before and after: the same number. The one that was in front is now one step back.
- Two orders.
pastis oldest first;versionsis newest first. Watch both lists on the right while you change and restore, and say which end a new version joins in each. - The limit. Make seven changes. The first version, "a lighthouse", is no longer in the list. That is
MAX_PAST = 6, and it is the one place where something is dropped. - The house, the lamp and the cup. They were built by hand, not from a list of parts, so the AI has nothing to change. The first time one is changed, the scene replaces it by a thing made of parts that looks about the same (
ORIGINALSin edits.js). That stand-in becomes the first entry of its past.
Exercises: ① Make two changes, then press "An older one" once. What is d for each version, and what does stackPlace return for the newest? ② Step back to the oldest version and bring it back. Write down past before and after. Which line of restored produced the new order? ③ In the scene, typing a letter while looking at an older version lets the stack fall back first. Why is that safer than changing the version in view?