Explain a function as a scene
Turn a function into a short, picture-first scene you can step through, then change it by asking, or open it as a board you can edit.
Before you start
- A model under Settings → AI. The scene director is an agent that reads your code.
- A function worth explaining: one with a branch, a loop or a call to another part of the system.
Explain a function#
- Ask for a scene.
Click ✦ Scene above the function, or put the caret inside it and press ⌘⌥X (Explain this function (or the file) as a scene in the command palette). With the caret outside every function, the whole file is explained.
- Read the director’s pick.
The director first says how it will tell this code and why, for example “A scene” for a function that moves data through steps. Then it writes the scene, a step at a time.
- Step through it.
The scene plays from its first step, such as 1 / 3 · The cart arrives. Use Next and Back. Each step has a picture and a line of text, and the objects in the picture are the things in your code: the cart, the price, the payment.
- Check it against the source.
Click the file and line link at the top of the scene to jump to the code. Read how the function handles the error or early return you saw in the scene.
- Change it, or tell it again.
Ask in the chat beside the canvas (“show what happens when the card is declined”) and the director edits the steps. Tell it again has it start over.
Scenes, relays and boards#
| Telling | Best for | Start it with |
|---|---|---|
| Scene | A function that moves something through steps | ✦ Scene or ⌘⌥X |
| Relay | A request handed from one part of the system to the next | ⌘⌥Y (Explain this function (or the file) as a relay) |
| Board | A picture you want to rearrange, annotate and keep | Board on a scene, or Supercanvas’s own boards |
A board opened from a scene is saved under Saved boards and keeps working with the same agent: ask it to add, move or point at anything on the canvas.
Without a model#
Scenes need a model, but the code’s own shape doesn’t. Flow or Split in a code file’s header draws the function under the caret as its control flow: branches both ways, loops going round, try and its handlers, every way out, and calls by what they call. It’s read from the syntax tree as you type, in 18 languages, with no model and no server.
How much to trust a scene#
The director reads the code it explains and cites it, but a scene is still a model’s telling. Use the file and line links to check anything that matters. To see real values on a real path, follow up with a walkthrough or the AI debugger.
Troubleshooting#
“This telling is no longer running”
The director stopped before it finished, usually because the app or the model’s CLI was closed. Click Tell it again.
The scene command is missing from the palette
It needs an open code file. Open one and put the caret inside a function.
Next steps#
Something unclear or out of date? Tell us; a person on the team reads every note.